Toggle

Two-state toggle button on Base UI with sm, default and lg sizes and a pressed style. A shadcn-compatible Toggle for toolbar actions like bold or mute in React.

src/registry/ui/toggle.tsx/r/toggle.json

Installation#

bash
npx shadcn@latest add @minidev/toggle

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/toggle.json

Usage#

tsx
import { Toggle } from "@/components/ui/toggle"

export function Example() {
  return (
    <Toggle aria-label="Bold"><BoldIcon className="size-4" /></Toggle>
  )
}

API reference#

Toggle props
PropTypeDefault
size"sm" | "default" | "lg""default"

Also accepts every prop of TogglePrimitive props, passed through to the root element.

Dependencies#

npm

@base-ui/reactclass-variance-authority

Built from

No other MiniDev files

Examples#

All button components

Learn more