svelte-os-themes
Version:
[Svelte](https://svelte.dev/) 5 theme helper.
50 lines (49 loc) • 1.14 kB
TypeScript
import type { HTMLButtonAttributes } from 'svelte/elements';
import type { Theme } from './types.js';
export interface CreateThemeProps {
/**
* @default 'system'
*/
fallback?: Theme;
/**
* @default 'class'
*/
attribute?: 'class' | `data-${string}`;
/**
* @default 'theme'
*/
storageKey?: string;
/**
* @default false
*/
system?: boolean;
/**
* @default true
*/
colorScheme?: boolean;
nonce?: string;
}
export type ThemeTriggerProps = {
value: Theme;
} | {
value: 'auto';
/**
* @default
* ['light', 'dark', 'system']
*/
sequence?: Theme[];
};
export interface CreateThemeReturn {
get current(): Theme;
set current(value: Theme | null | undefined);
getTriggerProps(props: ThemeTriggerProps): HTMLButtonAttributes;
}
export declare function createTheme(props: CreateThemeProps): CreateThemeReturn;
export declare namespace createTheme {
var style: (props: CreateThemeProps) => {
readonly value: string;
};
var script: (props: CreateThemeProps) => {
readonly value: string;
};
}