Knit UI
GitHub

Playground

Loading playground…

false
true
Playground
<Switch
  label="Switch"
  size="sm"
  disabled={false}
  withThumbIndicator
  labelPosition="right"
/>

Examples

Sizes

All seven sizes side by side for a quick visual comparison.

Loading example…

SizesSourceStorybook

Shadows

Elevation shadow ladder applied to the track via the inherited shadow prop.

Loading example…

ShadowsSourceStorybook

Disabled

Disabled state — the switch is non-interactive and visually dimmed.

Loading example…

DisabledSourceStorybook

Track Labels

On/off labels rendered inside the track, behind the thumb.

Loading example…

Track LabelsSourceStorybook

Thumb Icon

An icon rendered inside the thumb replaces the default dot indicator.

Loading example…

Thumb IconSourceStorybook

Themes

Accent colour comes from the Tamagui theme prop.

Loading example…

ThemesSourceStorybook

Label Left

Label placed to the left of the track.

Loading example…

Label LeftSourceStorybook

With Description And Error

Description and error slot — rendered below the label when provided.

Loading example…

With Description And ErrorSourceStorybook

Controlled

Fully controlled switch — the parent manages checked state via React.useState.

Loading example…

ControlledSourceStorybook

Group

Switch.Group manages a set of switches as a multi-select; maxSelectedValues caps the selection.

Loading example…

GroupSourceStorybook

Group Read Only

A read-only Switch.Group keeps the current values visible but prevents toggling them.

Loading example…

Group Read OnlySourceStorybook

Controlled Group

Controlled Switch.Group — parent tracks the selected values array.

Loading example…

Controlled GroupSourceStorybook

Styles

Per-slot styles targets individual parts — here the track, thumb and label.

Loading example…

StylesSourceStorybook

Props

PropTypeDefaultDescription
aria-describedbystring | undefinedIds of external description elements; merged with description/error ids.
aria-labelstring | undefinedAccessible label when no visible label is provided.
aria-labelledbystring | undefinedId of an external label element. Defaults to the visible label id.
checkedboolean | undefinedControlled checked state.
defaultCheckedboolean | undefinedfalseInitial checked state for the uncontrolled case.
descriptionReactNodeDescription rendered below the label.
disabled systemboolean | undefinedfalseDisables the switch.
errorReactNodeError rendered below the description (string nodes get the error theme).
idstring | undefinedId used to bind the control and label; auto-generated when omitted.
labelReactNodeSwitchLabel content rendered next to the control.
labelPosition"left" | "right" | undefined
left · right
'right'Position of the label relative to the track.
offLabelReactNodeInner label shown in the track when unchecked.
onChange((checked: boolean) => void) | undefinedCalled with the next checked state. Mirrors Mantine's `onChange` name; the payload is a boolean (not a DOM event) because the kit is cross-platform.
onCheckedChange((checked: boolean) => void) | undefined
onLabelReactNodeInner label shown in the track when checked.
radius systemstring | number | undefined
rootRefRef<TamaguiElement> | undefinedRef of the root wrapper element.
shadow system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined
size system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined
xxs · xs · sm · md · lg · xl · xxl
'sm'Controls the height, width and thumb dimensions of the track.
styles systemSlotStyles<SwitchStyles> | undefinedUniform per-slot style passthrough — sugar over the composable parts. Own slots: `track` / `thumb` / `thumbIndicator` / `trackLabel`; plus the inherited chrome slots `label` / `description` / `error` / `root` forwarded to the `InlineControl`.
theme systemThemeName | null | undefinedApplies a theme to this element
thumbIconReactNodeIcon rendered inside the thumb.
valuestring | undefinedValue reported to a surrounding `Switch.Group`.
withThumbIndicatorboolean | undefinedtrueShow a coloured dot inside the thumb.

Style slots

Every part of Switch can be styled through the styles prop. Explicit props on the component always win over slot styles.

SlotUsage
descriptionstyles={{ description: { … } }}
errorstyles={{ error: { … } }}
labelstyles={{ label: { … } }}
rootstyles={{ root: { … } }}
thumbstyles={{ thumb: { … } }}
thumbIndicatorstyles={{ thumbIndicator: { … } }}
trackstyles={{ track: { … } }}
trackLabelstyles={{ trackLabel: { … } }}
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<TamaguiElement> | undefined

Plus 495 inherited style props from Box — the full Tamagui/React Native style surface, including token shorthands like p, mx, bg and c. See Tokens for the scales they accept, or the full list.