Appearance
Switch
Bật/tắt tức thì (~28×48).
ts
import { Switch } from "@minap/ui";Examples
Mẫu sống trong Preview; chọn View code khi cần copy.
Usage
tsx
import * as React from "react";
import { Label, Switch } from "@minap/ui";
export function Example() {
const [notify, setNotify] = React.useState(true);
return (
<>
<div className="flex min-h-touch items-center justify-between gap-3">
<Label htmlFor="emb-sw">Notify (controlled)</Label>
<Switch id="emb-sw" checked={notify} onCheckedChange={setNotify} />
</div>
<p className="text-xs text-muted-foreground">onCheckedChange → {notify ? "true" : "false"}</p>
<div className="flex min-h-touch items-center justify-between gap-3">
<Label htmlFor="emb-sw-uc">Uncontrolled</Label>
<Switch id="emb-sw-uc" defaultChecked />
</div>
<div className="flex min-h-touch items-center justify-between gap-3">
<Label htmlFor="emb-sw2">Disabled</Label>
<Switch id="emb-sw2" disabled />
</div>
</>
);
}Props / API
| Prop / API | Type | Default | Notes |
|---|---|---|---|
checked / defaultChecked | boolean | — | |
onCheckedChange | (checked: boolean) => void | — | |
disabled | boolean | false | |
id | string | — | Ghép với Label htmlFor |
Behavior
- touch-manipulation
- focus ring