• CMSnpm version

    • Overview
    • ContentBuilder
    • InviteUserForm
    • LoginForm
    • RenewPasswordForm
    • WysiwygInput
  • UInpm version

    • Overview
    • Accordion
    • AlertBubble
    • AnnouncementBar
    • Avatar
    • AvatarFileInput
    • Badge
    • Button
    • ButtonGroup
    • ButtonList
    • Calendar
    • Checkbox
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • Chip
    • ColorRadio
    • ColorRadioGroup
    • Combobox
    • DatePicker
    • DatePickerInput
    • DateRangePicker
    • DateRangePickerInput
    • DatetimePicker
    • DatetimePickerInput
    • Dialog
    • Dropdown
    • Dropzone
    • ErrorMessage
    • FileInput
    • FlashMessages
    • FormComponent
    • Icon
    • IconButton
    • ImageGallery
    • InfoBox
    • Input
    • Label
    • Layout
    • Lightbox
    • ListItem
    • Loader
    • Lozenge
    • Menu
    • Message
    • Modal
    • ✅ ModalDialog
    • ✅ ModalHeader
    • MultiCombobox
    • MultiSelect
    • Pagination
    • Paper
    • Popover
    • Radio
    • RadioGroup
    • RasterImage
    • Select
    • Switch
    • ✅ Tabs
    • TextInput
    • TextLink
    • Textarea
    • TimePicker
    • TimePickerInput
    • Toggle
    • Tooltip
    • Typography
  • Formnpm version

    • Overview
    • AvatarFileInput
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • ColorRadioGroup
    • Combobox
    • DatePickerInput
    • DateRangePickerInput
    • DatetimePickerInput
    • Dropzone
    • FileInput
    • Form
    • FormRenderer
    • GpsInput
    • MoneyInput
    • MultiCombobox
    • MultiSelect
    • NumberInput
    • PasswordInput
    • RadioGroup
    • Select
    • TextInput
    • Textarea
    • TimePickerInput
    • Toggle
  • DataGridnpm version

    • Overview
    • DataGrid
    • DataGridCustomExample
    • ExportButton
    • FilterList
    • Filters
    • FiltersButton
    • FulltextInput
    • HiddenColumns
    • HiddenColumnsButton
    • Pagination
    • RowCounts
    • RowsPerPageSelect
    • SelectedRowsToolbar
    • TableV2
    • ToolbarControl
    • ToolbarCustoms
    • ToolbarTabs
  • Wysiwygnpm version

    • Overview
  • Resizernpm version

    • Overview
  • Routernpm version

    • Overview
  • Corenpm version

    • Overview
  • Core-Reactnpm version

    • Overview
  • DnDnpm version

    • Overview
  • Stylesnpm version

    • Overview
  • Localizenpm version

    • Overview
  • Analyticsnpm version

    • Overview
  • Datepickernpm version

    • Overview
  • Icons-generatornpm version

    • Overview
  • Smart-addressnpm version

    • Overview
  • E2Enpm version

    • Overview
  • E2E-Playwrightnpm version

    • Overview
View source on GitLab

Switch

The bare switch: track, knob, states, nothing else. It is to Toggle what Checkbox is to CheckboxInput.

Reach for Toggle for an ordinary form field — it owns the label, its layout and its variants. Reach for Switch when the label already exists somewhere else (a table column heading, a toolbar) or when composing a new labelled variant.

Usage

import { Switch } from "@uxf/ui/switch";

<Switch aria-label="Notifications" name="notifications" onChange={setValue} value={value} />;

CSS: @uxf/ui/css/switch.css.

Naming it

Switch renders a control with no text of its own, so it has no accessible name unless one is given. Pass aria-label, or aria-labelledby pointing at the element that already names it.

Both are optional, and nothing enforces that one is present: requiring "one of them" through a union type would break the Omit<…Props, …> composition the @uxf/form wrappers rely on, because Omit does not distribute over a union. Naming the control is the caller's job.

Props

PropTypeNote
valueboolean | undefined
onChange(value: boolean) => void
namestring
aria-label / aria-labelledbystringAccessible name, see above
isDisabledbooleanNot focusable, not submitted
isReadOnlybooleanFocusable and announced, value locked
isInvalidbooleanRed outline, red track when on
size"sm" | "default"
id, className, style

No indeterminate, deliberately

A switch has only on and off. aria-checked="mixed" is valid on checkbox and invalid on switch, and the visual promises a binary that flips right now, which a half state cannot honour. Where a tri-state is wanted — a parent over N children, "all notifications" — the control is a checkbox: use CheckboxInput, which supports indeterminate and announces it as mixed. A row of switches with one checkbox in it looks inconsistent; a switch claiming to be half on is wrong.

Default
Open in new tab
Sizes
Open in new tab
States
Open in new tab