Toggle
When to use it
Section titled “When to use it”- To turn a single setting on or off, such as a notification (“Check in reminders”, “Price drop alerts”).
- For a setting that takes effect immediately, without a Save button.
- Use size md in settings lists, with the label and helper text on the left and the toggle on the right; use size sm in dense tables, such as the Email, Push and SMS columns.
- Use a disabled state for a setting the user can’t change, such as booking confirmations that are always sent.
Where the built component differs. Item 3 (145:824) above is copied from Figma as written, and assumes a label and helper text laid out beside the toggle. Toggle.tsx renders one element, the <input type="checkbox" role="switch"> (Toggle.tsx:14-19), with no label or helper-text slot, and the Figma component description says “No built-in label: place the setting’s label beside it.” (node 144:20).
When not to use it
Section titled “When not to use it”- For a choice submitted together with a form, such as agreeing to terms: use the Checkbox component instead.
Instead: Checkbox - When the user must choose one of several options: use the Radiocard component instead.
Instead: Radiocard - To trigger an action, such as saving or sending: use the Button component instead.
Instead: Button
Best practice
Section titled “Best practice”From the Figma documentation page (usage node 145:712), as written. These items aren’t carried into Toggle.intent.json, which has no field for them.
- Always pair the toggle with a visible label that names the setting, not its state (“Price drop alerts”, not “On”).
- Apply the change straight away; don’t make the user press Save afterwards.
- Leave optional notifications and marketing off by default.
- Explain why a disabled toggle can’t be changed in the helper text (for example, “Always on, cannot be changed”).
- Make the whole row clickable, not only the switch.
- Give the toggle the switch role and its label for assistive technology (role=“switch” with aria-checked).
Where the built component differs. Items 4 (145:872) and 5 (145:878) are copied from Figma as written. They describe helper text and a clickable whole row, which Toggle.tsx doesn’t provide: it renders only the bare switch, one <input> (Toggle.tsx:14-19), with no helper-text slot and no row to click. The label goes beside it, as the Figma component description says (node 144:20).
Item 6 (145:884) names role="switch" with aria-checked. Toggle.tsx sets the role on a native checkbox input (Toggle.tsx:16) and never sets aria-checked. The control is a native <input type=“checkbox”> with role=“switch”, so keyboard, focus and disabled behaviour are the browser’s own, and the checked state maps natively to the switch state (no manual aria-checked).
From the release review, as written:
Usage lines the built component doesn’t provide. Use-when item 3 (carried verbatim into the intent file) says to put “the label and helper text on the left and the toggle on the right”; Best Practice items say to explain a disabled toggle “in the helper text” and to “make the whole row clickable”. Toggle is the bare switch: no label, helper text or row, and Figma draws only the switch. Owner: the designer (draw the row or trim the lines); the engineer builds it if drawn.
Best Practice says aria-checked; the code doesn’t set it. The native <input type=“checkbox” role=“switch”> maps checked to the switch state without aria-checked, as the intent’s first a11y entry says. Mechanism differs from the Figma wording only.
What each variant is for
Section titled “What each variant is for”| Property | Value | What it is for |
|---|---|---|
size |
md |
default; settings lists |
size |
sm |
dense tables |
Accessibility
Section titled “Accessibility”- The control is a native <input type=“checkbox”> with role=“switch”, so keyboard, focus and disabled behaviour are the browser’s own, and the checked state maps natively to the switch state (no manual aria-checked).
src/components/Toggle/Toggle.tsx:16 - There is no built-in label; callers supply aria-label or wrap the input in a <label> to give it an accessible name.
src/components/Toggle/Toggle.stories.tsx:12
What this version promises
Section titled “What this version promises”From Versioning (VERSIONING.md at b9ffb76):
0.3.0 adds six components on top of 0.2.1: Calendar, Card, Form, Modal, SideBar and Table. It contains twenty-three components, each exported from the package root with its props type: Avatar, Breadcrumbs, Button, ButtonGroup, Calendar, Card, Checkbox, Chip, Dropdown, File, Form, Header, Image, Link, Logo, Modal, ProgressBar, RadioCard, SearchBar, SideBar, Stepper, Table, Toggle. Textfield is exported from the package root as well, with TextfieldProps and TextfieldState, and is public like the others (see decisions.md, 2026-10-07, Textfield). It commits you to their props, prop values and defaults, their hz- class names, the tokens in tokens.css and the three entry points (., ./styles.css, ./tokens.css). Everything in 0.3.0 beyond 0.2.1 is an addition: nothing from 0.2.1 was changed, removed or renamed. A change that breaks any of these on 0.x bumps the version to 0.4.0.
Two things about this release are worth knowing:
- Form, Modal and Table each passed release review with their literal sizes covered by a ruling in decisions.md (Card, SideBar and Calendar have their own), because no size tokens exist for them. Those literals are accepted until the designer adds matching tokens, so a later change to use tokens at the same rendered sizes would be a patch, not a breaking change.
- Dark theme is not verified for Table, and its warning tag has low contrast. The Table docs page says so. Neither is a breaking-change risk, but a fix that changes a token’s value is a patch and is listed in the changelog.
Stories
Section titled “Stories”All Variants
Section titled “All Variants”The single-variant stories (MdOff, SmOff, MdOn, SmOn, MdDisabledOff, SmDisabledOff, MdDisabledOn, SmDisabledOn) are cells of the variant matrix; the Design tab links each one.
Import
Section titled “Import”import { Toggle } from "@layerbasesystemic/horizon-design-system";import type { ToggleProps, ToggleSize } from "@layerbasesystemic/horizon-design-system";@layerbasesystemic/horizon-design-system/tokens.css and @layerbasesystemic/horizon-design-system/styles.css must be loaded too; see Developing.
| Prop | Type | Default | Description |
|---|---|---|---|
size |
ToggleSize |
"md" |
md 44x24 (default), sm 40x22. |
ToggleProps also extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" \| "size" \| "role" \| "children">, so native attributes pass through to the element (Toggle.tsx:6).
Union types
Section titled “Union types”ToggleSize: md, sm
Tokens it needs
Section titled “Tokens it needs”Every CSS custom property Toggle.css reads, with its value in the token build at b9ffb76.
| Token | Light | Dark |
|---|---|---|
--border-width-md |
2px |
same as light |
--color-bg-elevated |
#f9fafb |
#4d5361 |
--color-border-strong |
#c8d2dd |
#6a7180 |
--color-primary-default |
#2b5ad6 |
#6692f8 |
--color-state-disabled-bg |
#e5e7ed |
#4d5361 |
--radius-full |
999px |
same as light |
This matches required_tokens in Toggle.intent.json exactly.
Figma node
Section titled “Figma node”Page Toggle (57:1638), documentation frame ❖ toggle (145:2), component set toggle (144:20). The file is shared with the team only, so the frame and the link ask anyone outside it to sign in.
Variant matrix
Section titled “Variant matrix”size (2) × state (4) = 8 cells. The documentation frame (145:2) lays out size (rows: md, sm) against state (columns: off, on, disabled-off, disabled-on). The component set (144:20) publishes all 8 variants, named size=md, state=off (144:4) through size=sm, state=disabled-on (144:18). In Figma, state is one combined property.
size |
state=off |
state=on |
state=disabled-off |
state=disabled-on |
|---|---|---|---|---|
md |
MdOff144:4 |
MdOn144:8 |
MdDisabledOff144:12 |
MdDisabledOn144:16 |
sm |
SmOff144:6 |
SmOn144:10 |
SmDisabledOff144:14 |
SmDisabledOn144:18 |
Each cell is the Storybook story for that combination and its Figma variant node. ToggleSize is the union type listed on the Code tab. state is not a prop of Toggle, and the code has no state union type. The Toggle.stories.tsx header comment says: “Figma’s combined state maps to the native props: off = unchecked; on = checked; disabled-off = disabled + unchecked; disabled-on = disabled + checked.” (Toggle.stories.tsx:3-4). Each state column is the story that sets those native attributes. The story that isn’t a single cell (AllVariants) is embedded on the Examples tab.
Themes
Section titled “Themes”The toggle component set renders every cell once, in one theme. It has no separate light and dark frames.
The token build defines 179 tokens for light and redeclares 50 for dark; the Code tab shows Toggle’s tokens in both.
Values Figma never bound
Section titled “Values Figma never bound”Values on the Figma node that aren’t bound to a variable, and what Toggle.css at b9ffb76 does with each.
| Layer | Property | Figma value | In the code |
|---|---|---|---|
| track, size=md (144:4, 144:8, 144:12, 144:16) | height | 24px |
height: 24px; |
| track, size=sm (144:6, 144:10, 144:14, 144:18) | height | 22px |
height: 22px; |
| track, state=disabled-on (144:16, 144:18) | fill: primary colour at 40% alpha | 40% |
background-color: color-mix(in srgb, var(--color-primary-default) 40%, transparent); |
| track, size=md (144:4, 144:8, 144:12, 144:16) | width (the code reproduces 44px with aspect-ratio, not a width literal) | 44px |
aspect-ratio: 11 / 6; |
| track, size=sm (144:6, 144:10, 144:14, 144:18) | width (the code reproduces 40px with aspect-ratio, not a width literal) | 40px |
aspect-ratio: 20 / 11; |
| knob, size=md (the 24px track less the 2px inset on each side) | diameter (the code fills the track height, not a size literal) | 20px |
height: 100%; |
| knob, size=sm (the 22px track less the 2px inset on each side) | diameter (the code fills the track height, not a size literal) | 18px |
height: 100%; |
| track, all 8 variants | knob inset (the code uses a border, not a size literal) | 2px |
border: var(--border-width-md) solid transparent; |
Figma variables against the token build
Section titled “Figma variables against the token build”| Figma variable | Figma value | Token in the build | Built light value | Agrees |
|---|---|---|---|---|
--color-bg-elevated |
#f9fafb |
--color-bg-elevated |
#f9fafb |
yes |
--radius-full |
999 |
--radius-full |
999px |
yes |
--color-border-strong |
#c8d2dd |
--color-border-strong |
#c8d2dd |
yes |
--color-primary-default |
#3b71f2 |
--color-primary-default |
#2b5ad6 |
no |
--color-state-disabled-bg |
#e5e7ed |
--color-state-disabled-bg |
#e5e7ed |
yes |
1 colour variable in Figma still holds a different value from the token build, so the design file and the shipped component render --color-primary-default differently.
Design gaps recorded against it
Section titled “Design gaps recorded against it”- 2026-10-02 · Toggle track heights and disabled alpha with no token (decisions.md). These literals in src/components/Toggle/Toggle.css are accepted, because they are what the Figma node specifies, until the designer adds matching size and opacity tokens. Accepted values:
24px(height (md track),the md switch track, line 16);22px(height (sm track),the sm switch track, line 21);40%(alpha in color-mix(in srgb, var(–color-primary-default) 40%, transparent) (disabled-on track only),the disabled and checked switch track, line 45). Not ruled: Any other literal value, including a var() fallback. These values in any other component. A change to these values: a different number needs a new ruling or a token. The on track, which uses –color-primary-default (#2b5ad6) and differs from the #3b71f2 Figma shows: that is the user’s choice to use the bound token, not a gate finding. The low contrast of the off track and of the knob on the disabled-off track as Figma draws them, which the user chose to build as drawn: that needs the designer. Any state Figma does not draw (hover, pressed, error, loading).
Every commit to src/components/Toggle up to b9ffb76, newest first, with the published version that carries it.
| Commit | Date | Version | Change |
|---|---|---|---|
9ea16b9 |
2026-10-02 | 0.2.0 | Toggle: variant_intent keys from ToggleSize only |
c84e63f |
2026-10-02 | 0.2.0 | Toggle: intent usage from Figma 145:712 |
c70925e |
2026-10-02 | 0.2.0 | Toggle: build from Figma 144:20 |