Halo Switch Demo

A demo showing HaloSwitch, a toggle with a spring-animated thumb and an enlarged tap target, in default and small sizes. It is wired to local React state and renders a status label beside each switch.

Halo Switch Demo
LIVE · running in a sandboxed iframe
Installed with shadcn add · 1 workaround · theme neutral (none shipped)
  • resolved dependency "halo-switch" from the item's own registry
See how it was built

Installation

pnpm dlx shadcn@latest add @cult-ui/halo-switch-demo

Requires @cult-ui in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { useState } from "react"import { HaloSwitch } from "@/components/ui/halo-switch"export default function Example() {  const [enabled, setEnabled] = useState(true)  return (    <HaloSwitch checked={enabled} onCheckedChange={setEnabled} translucent />  )}
  • Showing an on/off setting such as notifications, where immediate toggling is expected.
  • Placing a compact switch in dense toolbars or settings rows by using size="sm".
  • Building touch-friendly controls that need a larger tap target.
  • Previewing HaloSwitch variants before installing the halo-switch base component.

Examples

Default switch with label

A default-size switch bound to a boolean state, with a text label that reflects the current value.

default-switch-with-label.tsx
"use client"import { useState } from "react"import { HaloSwitch } from "@/components/ui/halo-switch"export default function NotificationsRow() {  const [notifyOn, setNotifyOn] = useState(true)  return (    <div className="flex items-center gap-4">      <HaloSwitch checked={notifyOn} onCheckedChange={setNotifyOn} translucent />      <span className="text-muted-foreground text-sm">        Notifications {notifyOn ? "on" : "off"}      </span>    </div>  )}

Small switch in a compact settings row

The size="sm" variant for dense settings lists.

small-switch-in-a-compact-settings-row.tsx
"use client"import { useState } from "react"import { HaloSwitch } from "@/components/ui/halo-switch"export default function CompactModeRow() {  const [compact, setCompact] = useState(false)  return (    <div className="flex items-center gap-4">      <HaloSwitch        checked={compact}        onCheckedChange={setCompact}        size="sm"        translucent      />      <span className="text-muted-foreground text-sm">        Compact mode {compact ? "on" : "off"}      </span>    </div>  )}

API reference

PropTypeDefaultDescription
checkedboolean—Controlled checked state of the switch, passed as the value from the demo's useState hook.
onCheckedChange(checked: boolean) => void—Called with the new checked value when the user toggles the switch. The demo passes the state setter directly.
translucentboolean—Boolean flag used in the demo to render the translucent style. Its exact default is defined in the halo-switch source, which is not included here.
sizestring—Size variant. The demo uses "sm" for a smaller footprint. Other accepted values are defined in the halo-switch source, which is not included here.

Accessibility

  • The demo renders a visible text label next to each switch that states its on or off state, so the state is not conveyed by color or motion alone.
  • The switch relies on the halo-switch base component for its role and aria-checked semantics. Verify these in that component's source.
  • The enlarged tap target is intended to help touch users. Keep a visible label adjacent to the control so screen reader users get context.
  • The spring animation is decorative. Respect reduced-motion preferences in the base component if it animates the thumb.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Halo Switch Demo" component (cult-ui/halo-switch-demo) from its shadcn registry.1. Install it with: npx shadcn@latest add @cult-ui/halo-switch-demo2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: checked, onCheckedChange, translucent, size.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { useState } from "react"import { HaloSwitch } from "@/components/ui/halo-switch"export default function Example() {  const [enabled, setEnabled] = useState(true)  return (    <HaloSwitch checked={enabled} onCheckedChange={setEnabled} translucent />  )}```

Files & dependencies

  • registry/default/example/halo-switch-demo.tsx
registryDependencieshalo-switch

Looks similar, elsewhere