Toggle Custom Fill Demo
A thumbs-up toggle button whose icon starts as an outlined thumb and fills with the accent-foreground color when the toggle is selected, with a 300ms color transition. It is a ready-made demo built on the @kanpeki/toggle primitive.
Installation
Requires @kanpeki in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { ToggleCustomFillDemo } from "@/components/examples/toggle/toggle-custom-fill-demo";export default function Page() { return <ToggleCustomFillDemo />;}- Use for an icon-only 'like' or 'favorite' toggle where a solid fill clearly signals the on state.
- Use when you want a subtle animated selected state instead of a background-color change.
- Use as a reference for overriding the child SVG fill from a parent Toggle via the selected: variant selector.
- Avoid when the toggle needs a visible text label; add a text child or use a different demo.
Examples
Basic usage
Render the demo component directly. It takes no props.
import { ToggleCustomFillDemo } from "@/components/examples/toggle/toggle-custom-fill-demo";export default function Example() { return <ToggleCustomFillDemo />;}Rating row with several like toggles
Places multiple instances in a row, each toggling independently.
import { ToggleCustomFillDemo } from "@/components/examples/toggle/toggle-custom-fill-demo";export default function LikeRow() { return ( <div className="flex items-center gap-2"> <ToggleCustomFillDemo /> <ToggleCustomFillDemo /> <ToggleCustomFillDemo /> </div> );}Beside a label
Pairs the toggle with a text label for context in a list item.
import { ToggleCustomFillDemo } from "@/components/examples/toggle/toggle-custom-fill-demo";export default function BookItem() { return ( <div className="flex items-center justify-between gap-4"> <span className="text-sm">Clean Code</span> <ToggleCustomFillDemo /> </div> );}API reference
Accessibility
- The toggle has aria-label "Toggle book", so screen readers announce it even though it has no visible text. Fork the file to give it a more specific label per instance.
- The base Toggle is a button and communicates pressed state via aria-pressed / data-state, so assistive tech hears its on/off state.
- The icon is decorative; the accessible name comes from aria-label, so the SVG needs no separate text.
- Keep the selected state distinguishable beyond color alone if the fill change is the only cue, for example by pairing with a label or tooltip, to support users with low color contrast perception.
- The 300ms color transition is a motion effect; respect prefers-reduced-motion by disabling transition-colors in your own override if needed.
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.
Use the "Toggle Custom Fill Demo" component (kanpeki/toggle-custom-fill-demo) from its shadcn registry.1. Install it with: npx shadcn@latest add @kanpeki/toggle-custom-fill-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: (none), aria-label (internal), className (internal).Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { ToggleCustomFillDemo } from "@/components/examples/toggle/toggle-custom-fill-demo";export default function Page() { return <ToggleCustomFillDemo />;}```Files & dependencies
- src/registry/examples/toggle/toggle-custom-fill-demo.tsx
Looks similar, elsewhere
There is no screenshot of this item to compare yet.