SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

ariaChecked

Keeps aria-checked on a native checked-state control in sync with its live checkedness, since the attribute is static and won't follow a control's state on its own.

tsx
import { ariaChecked } from "@sdxc/ui/mixins";

Usage

Adds aria-checked to a checkbox, switch, or radio, syncing it from the host's own render-time state and again on every change. Apply the mixin to every radio in a shared group — a change refreshes only the ones that carry it.

Signature

typescript
ariaChecked(): MixinDescriptor<HTMLInputElement>

Returns a mixin descriptor for a checkbox's, switch's, or radio's mix prop.

Examples

tsx
<Switch name="notifications" defaultChecked mix={[ariaChecked()]}>
	{t("settings.notifications.label")}
</Switch>
tsx
<Checkbox name="terms" mix={[ariaChecked()]}>{t("signup.acceptTerms")}</Checkbox>
tsx
<input type="radio" name="shipping" value="express" mix={[ariaChecked()]} />

The events, constants and types its module publishes, each imported from @sdxc/ui/mixins too.

Function

syncAriaChecked

Rewrites CHECKED_ATTRIBUTE on control, and on its sibling radios, since picking one radio unchecks another with no change event of its own. Call this directly after a programmatic checked/indeterminate write or a form reset, neither of which fires change.

typescript
syncAriaChecked(control: HTMLInputElement): void
ParameterTypeDefaultRequiredDescription
controlHTMLInputElement—YesMounted checkbox or radio whose attribute is brought back in line.
tsx
selectAll.indeterminate = someButNotAllSelected;
syncAriaChecked(selectAll);
@sdxc/ui

Can’t find it? Contact us