Rime

IconButton

A square action with only an icon, a required accessible label and a tooltip-friendly hit area.

IconButton is for compact, well-known actions (close, more, print, remove) where a label would crowd the layout. It takes the same variants as Button, minus the danger secondary, and a pressed state for toggles.

Installation

npx shadcn@latest add KezLahd/rime/icon-button

Also installs: base, spinner.

Usage

import { IconButton, IconX } from "@/components/ui";

<IconButton label="Close" icon={<IconX size={18} />} onClick={onClose} />

Examples

Variants and states

API

Generated from the component's TypeScript types and JSDoc (scripts/gen-ui-registry.mjs), so it always matches the source.

IconButton

IconButton props
PropTypeDefaultDescription
labelRequiredstringRequired: an icon-only control has no other accessible name.
iconRequiredReactNode
variant"ghost" | "secondary" | "primary" | "danger""ghost"
size"sm" | "md" | "lg""md"
loadingboolean
pressedbooleanMakes it a toggle button (aria-pressed).
asChildbooleanRender the single child element (a Next <Link>, an <a>) with the icon button's look; pass the icon inside the child.

Also accepts the native attributes of AriaAttributes, ButtonHTMLAttributes, DOMAttributes, HTMLAttributes.

Theme tokens

Per-component tokens are undeclared by default, so the default shown is the fallback the CSS uses. Set one at :root (or in theme.css) to restyle every instance. Live values are read from this page, so they follow the Rime Studio.

IconButton per-component tokens
TokenDefaultLive value
--button-height-lgvar(--control-h-lg)…
--button-height-mdvar(--control-h-md)…
--button-height-smvar(--control-h-sm)…
--icon-button-radiusvar(--r-xs) / var(--r-sm) / var(--r-md)…

System tokens it reads

IconButton system tokens
TokenDefaultLive value
--blur-callouttokens.css…
--brand-gradienttokens.css…
--control-h-lgtokens.css…
--control-h-mdtokens.css…
--control-h-smtokens.css…
--danger-filltokens.css…
--danger-inktokens.css…
--durtokens.css…
--easetokens.css…
--focus-ringtokens.css…
--glass-edge-strongtokens.css…
--glow-mdtokens.css…
--glow-md-hovertokens.css…
--glow-smtokens.css…
--ink-brandtokens.css…
--ink-disabledtokens.css…
--ink-headingtokens.css…
--ink-inversetokens.css…
--ink-mutedtokens.css…
--r-mdtokens.css…
--r-smtokens.css…
--r-xstokens.css…
--rgb-brand-deeptokens.css…
--rgb-contacttokens.css…
--rgb-dangertokens.css…
--rgb-whitetokens.css…
--shadow-controltokens.css…
--shadow-speculartokens.css…
--shadow-specular-darktokens.css…
--surface-solidtokens.css…
--wash-activetokens.css…
--wash-subtletokens.css…

Accessibility

  • label is required and becomes the accessible name (aria-label); the icon is hidden from assistive tech.
  • pressed sets aria-pressed for toggle buttons.
  • sm is 28px: only inside dense rows. Use md (36px) or lg (44px) where it is the main target on touch.

Do and don't

Do

  • Pair an unfamiliar icon with a Tooltip carrying the same label.

Don't

  • Don't use an IconButton for the primary action of a screen; it needs words.

For AI agents

This page as markdown, rendered from the same registry entry. Point an agent at it (or add .md to this page's URL), or at /llms.txt for the index.

Open icon-button.md

Related: button, tooltip