IconButton

A square, icon-only button for toolbars, dismiss actions and dense rows. Because there is no visible text, label is required and becomes the aria-label.

StableSource

Import

tsx
import { IconButton } from "@merid/react";

Examples

Variants

ghost (the default) is transparent until hovered — right for toolbars and card corners. secondary gives the button a visible surface; primary uses the accent fill and should be as rare as a primary Button.

Sizes

Squares of 32px (sm), 36px (md, default) and 40px (lg).

Disabled

API reference

Forwards its ref to the <button> and passes native button attributes through, except children and aria-label (use label). type defaults to "button".

PropTypeDefaultDescription
labelRequiredstring–Accessible name, rendered as aria-label.
iconRequiredReactNode–The icon. Rendered inside an aria-hidden span.
variant"ghost" | "secondary" | "primary""ghost"Visual style.
size"sm" | "md" | "lg""md"Square size: sm 32px, md 36px, lg 40px.
type"button" | "submit" | "reset""button"Native button type.
disabledboolean–Native disabled attribute.

Styling

HookValues
.mrd-icon-buttonRoot <button>
.mrd-icon-button__iconIcon wrapper (aria-hidden)
data-variantghost · secondary · primary
data-sizesm · md · lg

Component variable: --mrd-icon-button-size, set per size from the --mrd-icon-button-sm/md/lg tokens.

css
.toolbar .mrd-icon-button {
  --mrd-icon-button-size: 28px;
}

Accessibility

  • label is required by the types and becomes aria-label; the icon is aria-hidden.
  • Write the label as the action (“Delete invoice”), not the icon's shape (“Trash can”).
  • Pair with Tooltip so sighted mouse users can discover the label too.
KeyAction
TabMoves focus to the button.
EnterActivates the button.
SpaceActivates the button.

Guidelines

Do

Use icon buttons for well-known actions — close, settings, more — where the icon is unambiguous.

Avoid

Use an icon button for a primary or unfamiliar action. If people must guess, use a Button with a label.

  • Button — actions with a visible label.
  • Tooltip — shows the label on hover and focus.