Forms & inputs / Toggles

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.

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>
  );
}

Quality checks

Automated, in a real browser · 4d ago
—

More from Obsidian Precision

The whole style →

Bold Colour Testimonial Cards

Testimonials

Mono Uppercase Feature Tab List with Document Preview

Tab bars

Nested Initiatives Table

Tables

Quarterly Roadmap Board

Cards

Blur-In Word Hero with Floating App Window

Heroes

Frosted Hairline Header

Headers & nav bars