Skip to content

Switch

A switch that feels like a small physical toggle.

Download
Customize

The thumb is a raised bead in a filled well: it widens when pressed, stretches toward where it is going and settles round with a slight squash. Turning on, the accent floods the track from behind the thumb and drains back when turned off. It can be dragged or clicked, and Space toggles it. Three sizes and an optional description line.

Install

npx shadcn@latest add https://obsydeui.com/r/switch.json

Usage

Import it from where the CLI puts it, or copy the files below by hand.

import { Switch } from '@/components/obsyde/ember/switch/Switch';

export function Example() {
  return (
    <Switch label="Heat" />
  );
}

Files

Plain React, TypeScript and CSS. No dependencies. The download keeps these paths.

  • ember/switch/Switch.tsxcomponent
  • ember/switch/switch-demo.cssstyles
  • ember/switch/switch.cssstyles
  • ember/switch/SwitchDemo.tsxdemo
  • ember/actions-kit/kit.tsshared
  • ember/shared/accent.tsshared
  • ember/shared/spring.tsshared
  • ember/shared/ember.cssshared

API

PropTypeDefault
accentAccent'ember' | 'volt' | 'arc''ember'
checkedOnbooleanfalse
labelLabelstring'Heat'
descriptionDescriptionstring—
sizeSize'sm' | 'md' | 'lg''md'
disabledDisabledbooleanfalse