For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
/
144
Sponsor

Switch

A switch with track fill and sliding thumb animations.

Customize

Installation

$ pnpm dlx shadcn@latest add @framecn/switch

Usage

import { Switch } from "@/components/ui/switch";
<Switch label="Enable notifications" state="checked" />

Smooth transitions

The docs preview animates checked → unchecked via useSwitchTransition. Forward primary into the hook when using style so the track fill tracks the color prop:

import { Switch } from "@/components/framecn/switch";
import { useSwitchTransition } from "@/components/framecn/use-switch-transition";
 
const style = useSwitchTransition(
  [
    { at: 18, state: "checked", duration: 14 },
    { at: 78, state: "unchecked", duration: 12 },
  ],
  { primary: "#171717" }
);
 
<Switch label="Enable notifications" style={style} />;

style takes precedence over state when both are provided.

API Reference

Switch

PropTypeDefault
state"unchecked" | "checked""unchecked"
styleSwitchStyle- (takes precedence over state)
labelstring-
size"sm" | "default" | "lg""default"
themePartial<FramecnTheme>-
primarystring-
classNamestring-