cauldron
cauldron copied to clipboard
Add Switch Component
Switch components are a component indicating a boolean state (typically on/off) to activate or deactivate a particular setting. They differ slightly from Checkboxes in that typically the outcome of the state change usually takes effect immediately.
The component should follow general APG guidelines for the html checkbox input: https://www.w3.org/WAI/ARIA/apg/patterns/switch/examples/switch-checkbox/
The general guidelines are:
- The input element should use
role="switch" - The checkbox will be visually hidden, but the visual component of the switch can be styled with sibling selectors (i.e.
.Switch input[type="checkbox"] ~ .Toggle { ... })
Interface
type SwitchProps extends Omit<React.HTMLAttributes<InputElement>, 'role'> {
label: ContentNode
}
Design
[!NOTE]
The design requirements have changed slightly in the "off" state no longer should be indicated with an "x" icon. Only the on state should have a checkbox icon. Additionally, the label should be aligned to the right of the switch.
~- UXPin example: https://preview.uxpin.com/520e80315786a67ba43a3ca50598e6d69782627c#/pages/164060049?mode=cvidm~ ~- Light component: https://preview.uxpin.com/design-system/c933c74928e2195cc540/6814111,light-toggle~ ~- Dark component: https://preview.uxpin.com/design-system/c933c74928e2195cc540/6814112,dark-toggle~
~Design is in the Tag component in uxpin https://preview.uxpin.com/4052c8b6f05ce03e28813f28deb3a682950c2ac6#/pages/140808128/simulate/sitemap~
Outdated, new designs above
~You can achieve this today using the following component, <Button variant="tag" role="switch" aria-checked="true" /> but it would be good to elevate this to a top level component.~
Outdated, new specs coming soon.
Notes from working session:
- Remove "x" indication from off state
- Left aligned "toggle switch" with right aligned "label"
- @ezirlingerDQ will update designs to reflect above changes
Created the updated component in Figma. Asked the design team to review prior to attaching here.
@ezirlingerDQ it was pointed out that the disabled color in dark mode is not significantly different than the resting state