Skip to content

Icon button

BetaActionsOpen in the workshop

A square button whose icon is universally read: close, more, edit, delete, search.

.xg-btn.xg-btn--icon + any variant and size. Always aria-label.

Example and markup

Live, from xg-ui.css and xg-ui.js. Switch the brand and mode on the example itself, or for the whole site in the header.

Icon button
Markup
<div class="xg-row">
<button class="xg-btn xg-btn--ghost xg-btn--icon" type="button" aria-label="Edit">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M4 20h4L19 9a2.8 2.8 0 0 0-4-4L4 16v4Z"/>
<path d="m13.5 6.5 4 4"/>
</svg>
</button>
<button class="xg-btn xg-btn--secondary xg-btn--icon" type="button" aria-label="Download report">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M12 4v11"/>
<path d="m7 10 5 5 5-5"/>
<path d="M4 20h16"/>
</svg>
</button>
<button class="xg-btn xg-btn--icon" type="button" aria-label="Add">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M12 5v14"/>
<path d="M5 12h14"/>
</svg>
</button>
<button class="xg-btn xg-btn--ghost xg-btn--icon xg-btn--sm" type="button" aria-label="More actions">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<circle cx="5" cy="12" r="1"/>
<circle cx="12" cy="12" r="1"/>
<circle cx="19" cy="12" r="1"/>
</svg>
</button>
</div>

States

Hover, focus and pressed are forced here with .is-hover, .is-focus and .is-active so they can be seen side by side; in a product they come from :hover, :focus-visible and :active.

Icon button: every state
StateGhostSecondaryPrimary
Default
Hover
Focus
Disabled

When to use it

Use it for

table row actions, toolbars, dialog close, topbar notifications.

Not for

actions whose icon needs explaining; use a Button with a label instead.

Rules

  • Only icons from the UI glyph set (24 px grid, 2 px stroke). No pictorial or brand icons.
  • Pair with a tooltip when the meaning could be ambiguous.
  • Ghost by default in dense places (tables, toolbars); secondary where it needs to stand on a busy surface.

Accessibility

  • aria-label is mandatory and names the action and its object: “More actions for Retargeting EU”.
  • Target size: 32 px minimum (small), 40 px default.

Every color pair this component uses is measured for both brands in light and dark on the Accessibility page.

Also in Actions: Button, Button group, Link.

Status Beta: usable; class names may still change in a minor release, with a note (see Releasing).