Two-state button for toolbar actions, filters, and formatting controls.
npx shadcn@latest add @iconiq/r-toggle"use client";
import { Bold } from "lucide-react";
import { useState } from "react";
import { Toggle } from "@/components/ui/b-toggle";
export function TogglePreview() {
const [bold, setBold] = useState(false);
return (
<div className="flex min-h-[18rem] items-center justify-center px-4 py-6">
<p className="flex flex-wrap items-center justify-center gap-x-2.5 gap-y-2 text-balance font-medium text-lg text-neutral-800 leading-snug tracking-tight sm:text-xl dark:text-neutral-100">
<span>Ship the</span>
<span
className={
bold
? "font-bold text-neutral-950 transition-[font-weight,color] duration-200 dark:text-neutral-50"
: "text-neutral-800 transition-[font-weight,color] duration-200 dark:text-neutral-100"
}
>
release notes
</span>
<span className="inline-flex translate-y-px items-center align-middle">
<Toggle
aria-label="Toggle bold"
className="size-8 min-h-8 min-w-8 shrink-0 px-2 py-2"
onPressedChange={setBold}
pressed={bold}
size="sm"
variant="outline"
>
<Bold className="size-4" />
</Toggle>
</span>
</p>
</div>
);
}pressedControlled pressed state. Pass this when the parent owns whether the toggle is on.
Type boolean
defaultPressedInitial pressed state for uncontrolled usage. The component manages future toggles internally.
Type boolean·Default false
onPressedChangeCalled with the next pressed state whenever the toggle is activated or deactivated.
Type (pressed: boolean) => void
variantVisual treatment. Outline adds a border for toolbar or segmented layouts.
Type "default" | "outline"·Default "default"
disabledDisables interaction and dims the control while preserving its pressed appearance.
Type boolean
childrenIcon, text label, or icon-plus-label content. Children sit in normal document flow so labels expand the control width naturally.
Type React.ReactNode
classNameMerged onto the root button for local spacing, width, or color overrides.
Type string
Pressed state drives a horizontal liquid wipe, a one-shot light sheen, and tactile icon motion.
Built on Radix toggle primitives while preserving the same bouncy fill pop, icon snap, and press scale as the Base UI version.
The muted fill wipes in from the left when pressed and retracts to the right on release with a heavy spring.
Each state change sends a diagonal sheen across the surface once. Outline keeps the same outer border in both states.
Icons scale and squash on press with a spring settle.
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together.
Dependencies: radix-ui, class-variance-authority, motion.
Installs a Radix toggle with inline spring fill, sheen sweep, and press-scale motion in the same file.
Uses Radix toggle primitives under the same spring background, content lift, and press scale shell.
The generated registry file is /r/r-toggle.json.
Contact
Additionally, if you find any bug or issue, feel free to raise an issue.