Tangible Design System · @tangible/ui 0.2.56 · Interactive version · Markdown

IconButton

import { IconButton } from '@tangible/ui';

Interactive docs and examples: IconButton in Storybook.

IconButton props

Prop Type Default Description
icon IconSource Icon to display: a registry path or an icon component. Required — this is the button's visual content.
label string Accessible label. Required — icon-only buttons must have a label for screen readers since there's no visible text.
badge? number A count on the button's corner: unread notifications, items in a cart. Above badgeMax it shows "99+". 0, a negative or a non-number shows nothing, so badge={items.length} needs no guard. The count is part of the button's name, not only its look: "Notifications, 5 new" (labels.badgeCount). The full count is spoken even when the badge is capped. Anything that replaces the name replaces the count with it: an aria-label or aria-labelledby (a dev warning fires), and loadingLabel, which is the whole busy name. A change of count is NOT announced: the name changes silently on a button the user isn't on. If people need to know about an arrival right away, tell them with your own status message (a Toast). The badge overhangs the button's end edge (a "99+" by about 10px at sm) and paints above later siblings, so leave a gap after a badged button. Its colour doesn't follow theme: it is --tui-icon-button-badge-bg (primary by default) on every button. Set --tui-icon-button-badge-ring to the surface the button sits on (a header) so its cut-out blends in.
badgeDot? boolean false Show the badge as a dot instead of a number: "there's something new" without a count, or a quieter look for one. With a badge count as well, the dot still speaks the count in the name.
badgeMax? number 99 The largest count the badge shows; above it, the badge reads "99+". At xs, consider 9: a wide count overhangs a small button a long way. Whole numbers of 1 or more.
className? string Additional CSS class names.
disabled? boolean Disabled state.
href? string Only in some variants; the others reject it.
labels? IconButtonLabels Override default strings for i18n, and opt in to loading announcements (loadingStart / loadingEnd, empty by default). The button's name is label; the busy name is loadingLabel.
loading? boolean Loading state: shows a spinner and blocks activation while keeping the button focusable (aria-disabled, not native disabled), so a keyboard user who triggered it keeps their place. Only onClick is guarded: put the action there, not in onKeyDown/onPointerDown. By default the start and end of loading aren't announced: the busy name ("Save, loading") is set on the focused button, which screen readers rarely re-read, and it reverts silently. Opt in with labels={{ loadingStart: 'Saving…', loadingEnd: 'Saved' }} to speak each transition through a pre-mounted polite live region (portaled, so it never becomes a DOM sibling of the button). If the button unmounts when the action completes, the end can't be spoken from here: confirm through your own status message (a Toast). With loadingStart, don't set aria-busy on an ancestor of the button: NVDA and Chromium hold live-region output under a busy ancestor. Test with a screen reader: some also re-read the busy name ("Save, loading"), which can double up with loadingStart. While loading, the button stays focusable, so it mutes its colors rather than dimming the whole element: the focus ring keeps full contrast.
loadingLabel? string `${name}, loading` (English), where `name` includes any badge Accessible label override during loading state. For i18n support. It is the whole busy name: include the badge count yourself if it matters.
pressed? boolean Pressed state for toggle buttons. When true, applies aria-pressed="true" and active styling.
shape? "circle" | "square" 'square' Button shape. Use 'circle' for avatar-adjacent actions, FABs, or anywhere a round affordance is expected.
showTooltip? boolean false Show the label as a tooltip on hover. Since icon-only buttons have no visible text, enabling this helps sighted users discover what the button does. Recommended for most standalone icon buttons. Can be omitted in toolbars where a shared Tooltip provider handles it, or where adjacent visible text already communicates the action.
size? "lg" | "md" | "sm" | "xs" 'sm' Size of the button. 'xs': 24px — below WCAG 2.5.8 minimum target size (24×24 CSS px). Use only in dense, mouse-first UIs (toolbars, table rows) where touch is not expected. Consider pairing with adequate spacing or a larger touch target via padding/margin. 'sm': 32px (default); 'md': 40px; 'lg': 48px
theme? "danger" | "info" | "primary" | "secondary" | "success" | "warning" 'secondary' Semantic color theme. Note: Defaults to 'secondary' (unlike Button which defaults to 'primary') because IconButtons are typically used for toolbar/utility actions.
tooltipSide? "bottom" | "left" | "right" | "top" 'top' Tooltip placement side.
variant? "ghost" | "outline" | "solid" 'ghost' Visual style variant. 'solid': Filled background; 'outline': Border only, transparent background; 'ghost': No border or background, icon only — has no at-rest visual affordance. Best suited for toolbar groups, icon bars, or other contexts where surrounding UI makes the interactive nature obvious.

Also accepts the standard attributes of AnchorHTMLAttributes and ButtonHTMLAttributes (data-*, aria-*, event handlers), passed to the element it renders.

Other exports

Examples

Other stories: Playground, Variants, Themes, Sizes, Common Use Cases, States, Pressed State (Toggles), As Link, Circle Shape, With Tooltip (interactive page).

Component API tokens

Read via fallback, never declared. Set one on an ancestor to restyle every instance under it.