Toggle

Two-state button for toolbar actions, filters, and formatting controls.

Installation

npx shadcn@latest add @iconiq/r-toggle

File Structure

Usage

"use client";

import { Bold } from "lucide-react";
import { useState } from "react";
import { Toggle } from "@/components/ui/r-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>
  );
}

Props

Props
Description
pressed

Controlled pressed state. Pass this when the parent owns whether the toggle is on.

Type boolean

defaultPressed

Initial pressed state for uncontrolled usage. The component manages future toggles internally.

Type boolean·Default false

onPressedChange

Called with the next pressed state whenever the toggle is activated or deactivated.

Type (pressed: boolean) => void

variant

Visual treatment. Outline adds a border for toolbar or segmented layouts.

Type "default" | "outline"·Default "default"

size

Height, padding, and icon sizing preset for compact toolbars or larger action rows.

Type "default" | "sm" | "lg"·Default "default"

disabled

Disables interaction and dims the control while preserving its pressed appearance.

Type boolean

className

Merged onto the root button for local spacing, width, or color overrides.

Type string

Contact

Additionally, if you find any bug or issue, feel free to raise an issue.

Ship therelease notes