@dojo-ng/switch
v0.1.2
Published
Dojo NG switch web component
Readme
@dojo-ng/switch
<dj-switch> — A form-associated on/off toggle (role="switch") composing <dj-label>.
Part of Dojo NG, a framework-agnostic web component library built on Lit. BSD-3-Clause.
Modeled like a checkbox; the checked flag is checked (the Dojo widget called it value — renamed here for consistency with checkbox/radio). Parts: control, label.
Install
npm install @dojo-ng/switchUsage
Import the package to register the custom element, then use the tag.
Modeled like a checkbox; the flag is checked.
<dj-switch name="notify" checked>Email notifications</dj-switch>Properties
↻ marks an attribute reflected to the DOM; a dash means the property is set in JavaScript only.
| Property | Attribute | Type | Default |
|---|---|---|---|
| checked | checked ↻ | boolean | false |
| value | value | string | "on" |
| name | name ↻ | string | — |
| disabled | disabled ↻ | boolean | false |
| readonly | readonly ↻ | boolean | false |
| labelHidden | label-hidden | boolean | false |
Slots
- default slot
CSS parts
controllabel
Events
change
Methods
checkValidity(): booleanreportValidity(): booleanfocus(options: FocusOptions)restoreFormState(state: File | string | FormData | null)
Theming
Styled with Dojo NG --dj-* design tokens and exposes ::part() hooks for targeted overrides.
Accessibility and i18n
Follows the project's WCAG 2.2 AA and localization conventions.
More
Live, interactive examples are at play.dojo-ng.com. For the full API reference, theming, accessibility, and localization guides, see the Dojo NG documentation.
