imitation
Toggle
A button that stays pressed or not.
Text styleEach button keeps its own pressed state
In context
Project headerA Watch toggle beside the primary action
Harbour rebrandDue 24 Oct
You get an update when tasks move.
Props
| Prop | Type | Required | Default |
|---|---|---|---|
pressed | boolean | undefined | No | — |
defaultPressed | boolean | undefined | No | false |
onPressedChange | ((pressed: boolean) => void) | undefined | No | — |
size | "sm" | "md" | "lg" | undefined | No | md |
bionic | boolean | undefined | No | — |
bionicOptions | BionicOptions | undefined | No | — |
Icon-only usage needs an aria-label
Same convention as Button: if children is icon-only with no visible text, pass an explicit aria-label yourself — Toggle has no built-in fallback label.
data-rebar-* attributes
data-rebar-component="toggle", data-rebar-pressed (boolean), data-rebar-size.
Migrating to Ant Design
Not codemod-covered — AntD has no direct single-toggle-button primitive of its own (its closest analog is a plain Button with type="primary" conditionally applied by hand). On migration, a Toggle becomes a Button whose type prop is computed from the pressed state.