Turn a setting on or off.
import { useState } from 'react';
import { Switch } from '@vrum/ui';
export default function Demo() {
const [checked, setChecked] = useState(false);
return (
<Switch
checked={checked}
disabled={false}
aria-label={"Email notifications"}
onCheckedChange={setChecked}
/>
);
}Copy code| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | none | Controlled selection state. |
defaultChecked | boolean | none | default checked configuration. |
required | boolean | none | required configuration. |
onCheckedChange | ((checked: boolean) => void) | none | Called when the selection changes. |
asChild | boolean | none | as child configuration. |
disabled | boolean | none | Disable user interaction. |
name | string | none | name configuration. |
type | "submit" | "reset" | "button" | none | type configuration. |
value | string | number | readonly string[] | none | Controlled value. |
defaultValue | string | number | readonly string[] | none | Initial value for an uncontrolled component. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | aria-label configuration. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLButtonElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLButtonElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLButtonElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLButtonElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLButtonElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLButtonElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLButtonElement> | none | on select configuration. |