Indigo Pill Toggle
Small 32px pill switch with indigo fill and white knob, paired with a grey 'Billed yearly' label.
Rebuilt from linear.app/pricing in the Obsidian Precision style.
npx shadcn@latest add https://justyoink.it/r/obsidian-precision-5cbef2/blocks/indigo-billing-toggle.json
Looks exactly like linear.app: brings its fonts and colours, namespaced so your own theme stays untouched.
npx shadcn@latest add https://justyoink.it/r/obsidian-precision-5cbef2/mine/indigo-billing-toggle.json
Restyled to your project: uses your shadcn colours, fonts and radius, so it matches the rest of your app. Layout, type sizes and motion stay as designed.
Usage
Props: label (text beside the switch), defaultChecked (initial state, default true), onChange(checked) callback, className. The switch is uncontrolled and toggles on click or keyboard.
components/indigo-billing-toggle.tsx
import { useState } from "react"; type Props = { label?: string; defaultChecked?: boolean; onChange?: (checked: boolean) => void; className?: string; }; export default function IndigoPillToggle({ label = "Billed yearly", defaultChecked = true, onChange, className = "", }: Props) { const [checked, setChecked] = useState(defaultChecked); const toggle = () => { const next = !checked; setChecked(next); onChange?.(next); }; return ( <div className={`inline-flex items-center gap-2 bg-canvas p-4 font-sans ${className}`}> <button type="button" role="switch" aria-checked={checked} aria-label={label} onClick={toggle} className={`relative h-5 w-8 shrink-0 rounded-pill border transition-colors duration-[160ms] ease-[cubic-bezier(0.25,0.46,0.45,0.94)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-indigo focus-visible:ring-offset-2 focus-visible:ring-offset-canvas ${ checked ? "border-accent-indigo bg-accent-indigo" : "border-hairline bg-surface-raised" }`} > <span aria-hidden="true" className={`absolute top-1/2 left-0.5 h-4 w-4 -translate-y-1/2 rounded-full bg-white shadow-low transition-transform duration-[160ms] ease-[cubic-bezier(0.25,0.46,0.45,0.94)] motion-reduce:transition-none ${ checked ? "translate-x-3" : "translate-x-0" }`} /> </button> <span className="text-ui text-tertiary">{label}</span> </div> ); }import { useState } from "react"; type Props = { label?: string; defaultChecked?: boolean; onChange?: (checked: boolean) => void; className?: string; }; export default function IndigoPillToggle({ label = "Billed yearly", defaultChecked = true, onChange, className = "", }: Props) { const [checked, setChecked] = useState(defaultChecked); const toggle = () => { const next = !checked; setChecked(next); onChange?.(next); }; return ( <div className={`inline-flex items-center gap-2 bg-background p-4 font-sans ${className}`}> <button type="button" role="switch" aria-checked={checked} aria-label={label} onClick={toggle} className={`relative h-5 w-8 shrink-0 rounded-full border transition-colors duration-[160ms] ease-[cubic-bezier(0.25,0.46,0.45,0.94)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background ${ checked ? "border-primary bg-primary" : "border-border bg-secondary" }`} > <span aria-hidden="true" className={`absolute top-1/2 left-0.5 h-4 w-4 -translate-y-1/2 rounded-full bg-foreground shadow-obsidian-low transition-transform duration-[160ms] ease-[cubic-bezier(0.25,0.46,0.45,0.94)] motion-reduce:transition-none ${ checked ? "translate-x-3" : "translate-x-0" }`} /> </button> <span className="text-obsidian-ui text-muted-foreground">{label}</span> </div> ); }
Quality checks
Automated, in a real browser · 4d ago- Accessible: passedNo serious accessibility problems (axe-core): readable contrast, labelled buttons and images.
- Responsive: passedRenders at phone (390px), tablet (768px) and desktop width without sideways scrolling.
- Dark mode: passedStill readable when installed in your theme and switched to dark mode.
- Themeable: passedUses design tokens rather than hard-coded colours, so it follows your theme cleanly.
- Animates cleanly: doesn't applyDoesn't animate, so there's nothing to check.