Icon Button

A square button that renders a single icon with no visible label.

Import

import { IconButton } from '@matix/components/icon-button';

Usage

Variants

Icon buttons come in four visual variants.

Sizes

Disabled

Notification Count

Pass count to draw a small count in the top-end corner. A count of 0 draws nothing, and a count over 99 shows as 99+. The count is hidden from assistive tech, so put it in aria-label too.

Pass a link element to render. The button keeps the link role, so screen readers announce a link. See Button.

<IconButton aria-label="Home" render={<Link href="/" />}>
  <House size="1em" aria-hidden="true" />
</IconButton>

Custom Styles

Use the sx prop to override styles. Your styles always win over internal styles.

import * as stylex from '@stylexjs/stylex';
import { Heart } from 'lucide-react';

const custom = stylex.create({
  round: { borderRadius: '9999px' },
});

<IconButton sx={custom.round} aria-label="Like">
  <Heart size="1em" />
</IconButton>;

API Reference

PropTypeDefaultDescription
aria-labelstring—Required. Describes the icon's action for assistive tech
variant'solid' | 'outline' | 'ghost' | 'soft''ghost'Visual style
size'xs' | 'sm' | 'md' | 'lg''md'Size preset — button is square, icon scales via 1em
countnumber—Notification count in the corner. 0 hides it; over 99 shows 99+
renderReactElement—Element to render in place of the <button>, e.g. a link
disabledboolean—Disables the button
sxStyleXStyles—StyleX style override

All other props are forwarded to the underlying <button> element.

Accessibility

  • Renders a native <button> element by default.
  • With a link in render, it renders that link with no role, so assistive tech announces a link, not a button.
  • aria-label is required — icon buttons carry no visible text, so screen readers rely on it to announce the action. TypeScript enforces this at compile time.
  • Disabled state applies aria-disabled and prevents all pointer and keyboard interaction.
  • Focus ring is visible only on keyboard navigation (:focus-visible) — never on mouse click.
  • The xs size is 22 px high, under the 24 px target size of WCAG 2.5.8. It passes when each target has 24 px of room: put at least 2 px between adjacent xs icon buttons, and use sm or larger for dense touch layouts.
  • Inherits all Base UI Button accessibility behaviors, including ARIA role and keyboard handling.

Keyboard

KeyAction
EnterActivates the button
SpaceActivates the button