dequelabs / dequelabs/cauldron

Add Switch Component

Open
#223 5 comments 0 reactions 0 assignees View on GitHub
enhancement rfc ux debt
Dominant language
TypeScript
Stars
127
Forks
31
Avg merge
2d 12h
Merged PRs (30d)
8

Description

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

```ts
type SwitchProps extends Omit, '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~

![light and dark theme toggle examples](https://github.com/dequelabs/cauldron/assets/1062039/c89c033a-c846-4124-a938-5e02d1e66843)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.