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.

example · no preview
This item cannot be built as published, so there is no live preview: build: ✗ Build failed in 258ms
See how it was built

Installation

pnpm dlx shadcn@latest add @kanpeki/toggle-custom-fill-demo

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

Usage

usage.tsx
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.

basic-usage.tsx
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.

rating-row-with-several-like-toggles.tsx
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.

beside-a-label.tsx
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

PropTypeDefaultDescription
(none)——ToggleCustomFillDemo takes no props. It renders a fixed Toggle with aria-label "Toggle book" and a ThumbsUpIcon child.
aria-label (internal)string"Toggle book"Hard-coded on the internal Toggle in the source. Not configurable through this component's API; fork the file to change it.
className (internal)string"selected:[&_svg]:fill-accent-foreground"Hard-coded on the internal Toggle in the source. Applies the accent fill to the child SVG when selected. Fork the file to change it.

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.

prompt.md
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
dependencieslucide-react
registryDependencies@kanpeki/toggle

Looks similar, elsewhere

There is no screenshot of this item to compare yet.