Toggles
Design System - Toggle component
The Toggle component enables users to switch easily between two or more options. Consistent with DIGIT’s Design System, it prioritises clarity, responsiveness, and accessibility—assisting users in making quick, deliberate choices through visually distinct and intuitive controls.

// Sample code
<CheckBox
label="Label"
onChange={(e)=>{console.log(e.target.checked}}
/>
Anatomy

Variants

Basic
The Basic variant provides a clean, minimal toggle with clear labels, optimised for scenarios where the user needs to select one option from a small set. It appears with a neutral background and border by default.
Properties
Label Describe the purpose of each toggle item, ensuring clarity of intent.

Number of toggle items Supports multiple items in a single row, typically used to offer 2–4 selectable choices.

Property Configuration Table
Each design component offers a range of configurable options. These options are intentionally platform-agnostic, allowing implementations to adapt and tailor them to align with the specific requirements of the chosen framework.
selectedOption
text
-
onSelect
text
no
options
yes/no
no
optionsKey
yes/no
-
additionalWrapperClass
number
-
disabled
yes/no
-
inputRef
yes/no
no
style
yes/no
no
name
yes/no
no
Interaction State
Default State Neutral styling; inactive and ready to be interacted with.

Hover State
Highlights the toggle boundary or text to indicate it’s interactive.

Mousedown State
A pressed visual state indicating that the toggle is being clicked.

Active State
Highlights the selected toggle with a strong fill color to show selection.

Behaviours

Single Selection Logic
Only one toggle item can be selected at a time. Selecting another will deselect the current one.

Responsive Layout
Toggle items adjust spacing or wrap to fit various screen sizes.
Usage Guide

Use toggles for binary actions
Use toggles when users need to quickly switch between options without needing additional confirmation. They should indicate the selected state and allow easy navigation between choices. Avoid using toggles for critical actions. Since toggles are meant for quick, reversible selections, using them for irreversible actions can lead to accidental mistakes without a clear confirmation step.

Changelog
Dec 15, 2024
v-0.0.2
This component is added to the website. This component is now individually versioned.
Design Checklist
All interactive states - Includes all interactive states that are applicable (hover, down, focus, keyboard focus, disabled).
Accessible use of colours - Colour is not used as the only visual means of conveying information (WCAG 2.1 1.4.1)
Accessible contrast for text - Text has a contrast ratio of at least 4.5:1 for small text and at least 3:1 for large text (WCAG 2.0 1.4.3).
Accessible contrast for UI components - Visual information required to identify components and states (except inactive components) has a contrast ratio of at least 3:1 (WCAG 2.1 1.4.11).
Keyboard interactions - Includes all interactive states that are applicable (hover, down, focus, keyboard focus, disabled).
Screen reader accessible - All content, including headings, labels, and descriptions, is meaningful, concise, contextual and accessible by screen readers.
Responsive for all breakpoints - Responsiveness for 3 breakpoints - Mobile, Tablet and Desktop
Usage guidelines - Includes a list of dos and don'ts that highlight best practices and common mistakes.
Content guidelines - Content standards and usage guidelines for writing and formatting in-product content for the component.
Defined variants and properties - Includes relevant variants and properties (style, size, orientation, optional iconography, decorative elements, selection states, error states, etc.)
Defined behaviours - Guidelines for keyboard navigation and focus, layout management (including wrapping, truncation, and overflow), animations, and user interactions.
Design Kit - Access to the design file for the component in Figma, multiple options, states, colour themes, and platform scales.
Last updated
Was this helpful?