Skip to content
Pebble Pro is here at $49 one timeSee what’s included ↗
Pebble
ComponentsDocsMCPPricing
⌕ Find a component↗Log in
All components 673

Categories

Core inputs & forms46Buttons & actions33Navigation36Overlays & feedback49Data display33Charts & data viz40Cards & layout43Marketing blocks38App shells & pages37AI interfaces40Text & typography effects33Backgrounds & visual effects38Motion & transitions32Numbers & counters32Media34E-commerce333D & interactive36Themed sets40
Start with the essentials.Installation guide ↗Connect your agent ↗
← All componentsButtons & actions

Icon Button Set

Icon buttons that always carry a name and tooltip, with toggle states, three sizes, a grouped toolbar tray and a two-step destructive confirm.

Preview

Ship the empty states before the walkthrough.

Field recording No. 4

Tomás Rey · 1:42 / 4:05

Sizes

sm · 28px
md · 32px
lg · 40px
Q4

Q4 roadmap

Edited 3 min ago by Priya

Install

Add the editable source with the shadcn CLI. Your project also needs the shared theme tokens this component uses. Setup and requirements. The Pebble installer is not published yet.

npx shadcn@latest add https://pebbleui.com/r/icon-button-set.json

Props

PropTypeDefaultDescription
labelstring—IconButton. Accessible name and tooltip text. Required.
iconReactNode—IconButton. The glyph. Required.
variant"ghost" | "secondary" | "primary" | "danger""secondary" (ghost inside a group)Look. danger is a quiet red that fills on hover.
size"sm" | "md" | "lg""md" (or the group size)28, 32 or 40 px.
pressedboolean—Makes it a toggle with aria-pressed.
shortcut / tooltipSide / tooltipAlign / defaultTooltipOpenstring / side / align / boolean— / "top" / "center" / —Shortcut shown in the tooltip, its placement, and an open-by-default tooltip.
confirm / confirmTimeout / defaultArmedboolean | string / number / boolean— / 3000 / —Two-step destructive confirm: first press arms (red key, 'Click again to…'), second runs onClick.
IconButtonGroup{ size?, orientation?, role?: "group" | "toolbar" }—A recessed tray of ghost icon buttons; IconButtonDivider separates clusters.
Build notes
- Variant defaults come from a group context, so `<IconButton>` inside a tray
  turns ghost and takes the tray's size without props.
- Pressed in a tray = the raised pebble recipe (card, hairline ring, xs
  shadow, top highlight); pressed standalone = an inset shade with an ember
  icon.
- Each button carries its own Tooltip provider (300 ms delay), so it works
  anywhere without app-level setup. The tooltip is controlled so an armed
  button can keep it open as the "click again" prompt.
- Armed state uses the `--danger-key-*` tokens; a timeout effect disarms it.
- Demo: an editor toolbar (pressed/unpressed toggles, disabled redo), a media
  row (lit-key play between ghost toggles), labelled sizes, and a card header
  whose delete is armed, its tooltip opening downward, end-aligned, inside the
  frame.

<!-- PEBBLE-LICENSE -->
View source

registry/button/icon-button-set/icon-button-set.tsx

"use client";

/* PEBBLE-LICENSE
Built by Pebble. Component: icon-button-set.

First-party license: MIT

The following first-party terms apply only to original Pebble material.

MIT License

Copyright (c) 2026 Praxys Solutions LLC (Pebble)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
END PEBBLE-LICENSE */

import * as React from "react";

import { cn } from "@/lib/utils";
import {
  Tooltip,
  TooltipContent,
  TooltipProvider,
  TooltipTrigger,
} from "@/registry/overlay/tooltip/tooltip";

const variants = {
  // Flat until hovered: for dense toolbars.
  ghost:
    "text-muted-foreground hover:bg-muted hover:text-foreground active:bg-muted/80 aria-pressed:bg-card aria-pressed:text-foreground aria-pressed:shadow-raised-xs aria-pressed:ring-1 aria-pressed:ring-hairline aria-pressed:inset-shadow-highlight",
  // A raised pebble on its own.
  secondary:
    "bg-card text-foreground ring-1 ring-hairline shadow-raised-xs inset-shadow-highlight hover:bg-muted/60 active:shadow-none active:inset-shadow-none aria-pressed:bg-muted aria-pressed:text-accent-strong aria-pressed:shadow-[inset_0_1px_2px_var(--hairline)] aria-pressed:inset-shadow-none",
  // The lit key.
  primary:
    "bg-linear-to-b from-key-top to-key-bottom text-primary-foreground ring-1 ring-key-edge shadow-[var(--key-shine),var(--elevation-sm)] active:bg-linear-to-t active:shadow-[var(--key-press)] aria-pressed:bg-linear-to-t aria-pressed:shadow-[var(--key-press)]",
  // Destructive: quiet red that fills on hover, so it never looks like the default action.
  danger: "text-danger-strong hover:bg-danger/10 active:bg-danger/15 focus-visible:ring-danger/60",
} as const;

const sizes = {
  sm: "size-7 rounded-md [&_svg]:size-3.5",
  md: "size-8 rounded-md [&_svg]:size-4",
  lg: "size-10 rounded-lg [&_svg]:size-[18px]",
} as const;

type Size = keyof typeof sizes;

const GroupContext = React.createContext<{ inGroup: boolean; size?: Size }>({ inGroup: false });

export type IconButtonProps = Omit<React.ComponentProps<"button">, "children"> & {
  /** Accessible name; also the tooltip text. */
  label: string;
  icon: React.ReactNode;
  variant?: keyof typeof variants;
  size?: Size;
  /** Makes it a toggle (`aria-pressed`). */
  pressed?: boolean;
  /** A shortcut shown in the tooltip, e.g. "⌘B". */
  shortcut?: string;
  tooltipSide?: "top" | "right" | "bottom" | "left";
  /** Tooltip alignment along that side; use `end` near a container's right edge. */
  tooltipAlign?: "start" | "center" | "end";
  /** Show the tooltip from the start (static previews). */
  defaultTooltipOpen?: boolean;
  /**
   * Two-step destructive confirm: the first press arms the button (solid red,
   * relabelled), a second press within `confirmTimeout` runs `onClick`.
   * `true` uses "Click again to <label>"; a string sets the armed label.
   */
  confirm?: boolean | string;
  confirmTimeout?: number;
  /** Start armed (static previews). */
  defaultArmed?: boolean;
};

/** An icon-only button that always has a name and a tooltip. */
export function IconButton({
  label,
  icon,
  variant,
  size,
  pressed,
  shortcut,
  tooltipSide = "top",
  tooltipAlign = "center",
  defaultTooltipOpen,
  confirm,
  confirmTimeout = 3000,
  defaultArmed = false,
  className,
  type,
  onClick,
  onBlur,
  ...props
}: IconButtonProps) {
  const group = React.useContext(GroupContext);
  const v = variant ?? (group.inGroup ? "ghost" : "secondary");
  const s = size ?? group.size ?? "md";
  const [armed, setArmed] = React.useState(!!confirm && defaultArmed);
  // An armed button disarms on its own after a while, or when focus leaves.
  React.useEffect(() => {
    if (!armed || defaultArmed) return;
    const timer = setTimeout(() => setArmed(false), confirmTimeout);
    return () => clearTimeout(timer);
  }, [armed, confirmTimeout, defaultArmed]);
  const armedLabel =
    typeof confirm === "string"
      ? confirm
      : `Click again to ${label.charAt(0).toLowerCase()}${label.slice(1)}`;
  const name = armed ? armedLabel : label;
  // Controlled so an armed button can hold its tooltip open as the prompt.
  const [tipOpen, setTipOpen] = React.useState(!!defaultTooltipOpen);
  return (
    <TooltipProvider delayDuration={300}>
      <Tooltip open={armed || tipOpen} onOpenChange={setTipOpen}>
        <TooltipTrigger asChild>
          <button
            type={type ?? "button"}
            data-slot="icon-button"
            data-variant={v}
            aria-label={name}
            aria-pressed={pressed}
            data-armed={armed || undefined}
            onClick={(event) => {
              if (confirm && !armed) {
                event.preventDefault();
                setArmed(true);
                return;
              }
              setArmed(false);
              onClick?.(event);
            }}
            onBlur={(event) => {
              onBlur?.(event);
              setArmed(false);
            }}
            aria-keyshortcuts={shortcut}
            className={cn(
              "inline-flex shrink-0 cursor-pointer items-center justify-center [&_svg]:shrink-0",
              "transition-[background-color,box-shadow,color,transform] duration-(--motion-fast) ease-enter active:scale-[0.94] motion-reduce:transition-none motion-reduce:active:scale-100",
              "[&_svg]:transition-transform [&_svg]:duration-(--motion-fast) aria-pressed:[&_svg]:scale-105",
              "focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
              !group.inGroup && "focus-visible:ring-offset-2 focus-visible:ring-offset-background",
              "disabled:pointer-events-none disabled:opacity-40",
              variants[v],
              // Armed: the danger key, so the second press is unmistakable.
              armed &&
                "bg-linear-to-b from-danger-key-top to-danger-key-bottom text-danger-key-foreground shadow-[var(--danger-key-shine),var(--elevation-xs)] ring-1 ring-danger-key-edge hover:bg-linear-to-b hover:text-danger-key-foreground",
              sizes[s],
              className,
            )}
            {...props}
          >
            {icon}
          </button>
        </TooltipTrigger>
        <TooltipContent
          side={tooltipSide}
          align={tooltipAlign}
          className="flex items-center gap-1.5"
        >
          {name}
          {shortcut && <span className="font-mono text-[11px] opacity-70">{shortcut}</span>}
        </TooltipContent>
      </Tooltip>
    </TooltipProvider>
  );
}

export type IconButtonGroupProps = React.ComponentProps<"div"> & {
  size?: Size;
  orientation?: "horizontal" | "vertical";
};

/** A recessed tray of ghost icon buttons: the grouped toolbar look. */
export function IconButtonGroup({
  size,
  orientation = "horizontal",
  className,
  role = "group",
  ...props
}: IconButtonGroupProps) {
  return (
    <GroupContext.Provider value={{ inGroup: true, size }}>
      <div
        role={role}
        data-slot="icon-button-group"
        aria-orientation={role === "toolbar" ? orientation : undefined}
        className={cn(
          "inline-flex w-fit gap-0.5 rounded-lg bg-muted/60 p-0.5 ring-1 ring-hairline ring-inset dark:bg-muted/40",
          orientation === "vertical" && "flex-col",
          className,
        )}
        {...props}
      />
    </GroupContext.Provider>
  );
}

/** A thin rule between clusters inside an IconButtonGroup. */
export function IconButtonDivider({ className }: { className?: string }) {
  return <span role="none" className={cn("mx-0.5 my-1 w-px self-stretch bg-border", className)} />;
}
Pebble

Small details.
Better interfaces.

React components to explore, make your own, and build on.

Library

  • Components
  • Installation
  • Pricing

Resources

  • For agents
  • About
  • Support

Legal

  • License
  • Terms
  • Privacy
  • Final sale

Built by Pebble

A product of Praxys Solutions LLC ↗

Pebble Pro is live

$49 one time, lifetime updates ↗