Skip to main content

Switch

A labelled on/off switch built on the Radix Switch primitive. The label is a real label element tied to the control, so clicking the text toggles it, and the optional description is exposed through aria-describedby.

This is a function exported by @mapcairn/map, checked against version 0.2.0.

Signature​

import { Switch } from "@mapcairn/map";

function Switch(input: SwitchProps): JSX.Element;

Description​

The on state is shown three ways: the thumb slides, the track fills with the accent, and the thumb carries a tick, so it never relies on colour alone. The row is at least 48px tall, and the control itself, not only its row, is a target at least 44px tall around the smaller visible track.

Parameters​

  • { label, description, checked, onCheckedChange, disabled, className, "data-testid": testId, }
  • input (SwitchProps)

Returns​

JSX.Element

See also​

Source: packages/map/src/ui/Switch/Switch.tsx:37