melt
Version:
The next generation of Melt UI. Built for Svelte 5.
47 lines (46 loc) • 1.39 kB
TypeScript
import type { MaybeGetter } from "../types";
export type ToggleProps = {
/**
* The value for the Toggle.
*
* When passing a getter, it will be used as source of truth,
* meaning that the value only changes when the getter returns a new value.
*
* Otherwise, if passing a static value, it'll serve as the default value.
*
*
* @default false
*/
value?: MaybeGetter<boolean>;
/**
* Called when the value is supposed to change.
*/
onValueChange?: (value: boolean) => void;
/**
* If `true`, prevents the user from interacting with the input.
*
* @default false
*/
disabled?: MaybeGetter<boolean | undefined>;
};
export declare class Toggle {
#private;
readonly disabled: boolean;
constructor(props?: ToggleProps);
get value(): boolean;
set value(value: boolean);
/** The trigger that toggles the value. */
get trigger(): {
readonly "data-melt-toggle-trigger": "";
readonly "data-checked": "" | undefined;
readonly "aria-pressed": boolean;
readonly disabled: true | undefined;
readonly onclick: () => void;
};
/** A hidden input field to use within forms. */
get hiddenInput(): {
readonly "data-melt-toggle-hidden-input": "";
readonly type: "hidden";
readonly value: "on" | "off";
};
}