Switch

An on/off control with a visible label.

import { Switch } from '@brand-studio/ui';

export default function SwitchDemo() {
  return <Switch label="Email me when my order ships" defaultChecked />;
}

Installation

pnpm add @brand-studio/ui

Usage

import { Switch } from '@brand-studio/ui';
<Switch label="Email me when my order ships" />

Examples

Description and disabled

A description is linked with aria-describedby.

One email on Monday with new roasts.

Not available in your region yet.

import { Switch } from '@brand-studio/ui';

export default function SwitchDescription() {
  return (
    <div style={{ display: 'grid', gap: 20, maxWidth: 360 }}>
      <Switch label="Weekly digest" description="One email on Monday with new roasts." />
      <Switch label="Text messages" description="Not available in your region yet." disabled />
    </div>
  );
}

Accessibility

  • Renders a native <button role="switch">, so Space and Enter toggle it.
  • The visible label is a real <label>; clicking it toggles the switch.

API Reference

PropTypeDefault
labelstring
description?string
checked?boolean
defaultChecked?boolean
onCheckedChange?((checked: boolean) => void)
disabled?boolean
name?string
className?string''

Still, Deskhand and Hollis are fictional brands. The coffee photographs are original generated artwork. @brand-studio/ui is MIT licensed.