Turns a setting on or off at once.
import { Field, Switch } from "@usememos/ui";
<Field.Root>
<Field.Label>
<Switch checked={publicByDefault} onCheckedChange={save} /> Make new notes public
</Field.Label>
</Field.Root>interface SwitchProps extends BaseSwitch.Root.Props {
size?: Size; // 16, 18, 20px tall
}Wraps Base UI's Switch root with its thumb built in: checked, defaultChecked, onCheckedChange, disabled, name pass through.
- Name it with a
Field.Labelaround it, oraria-label. - Use it where each change saves at once (settings pages). In a form with a Save button, use Checkbox.
- A pill well with a round knob and a quiet
edgeat rest; the well fills withprimarywhen on. The track keeps its quiet boundary and fill on hover. Keyboard focus uses a fine 1px contrasting boundary. - Height = checkbox box + 2px; width = height × 1.7.
- The knob is flat
text, inset 2px;on-primarywhen on. Only its position slides withease-settlewhen the state changes, without growing on press; all colors change immediately. Under reduced motion it has no transition. Disabled switches keep the knob position, but use a quietedgeand atext-disabledknob. The track keeps the same dimensions and margins for mouse and touch input.