Skip to content
IndexRequest a UIAboutContact

Icon Button

A square icon-only button with an accessible name, tooltip and toggle state.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Create three icon buttons (Like, Bookmark, Share), each 44x44px with a 24px inline SVG. Each has an aria-label and a tooltip shown on hover and keyboard focus (small dark label above the button, 140ms fade). Like and Bookmark are toggles using aria-pressed: when on, the icon fills with the accent colour and plays a 280ms pop animation (scale 1, 1.25, 1) with cubic-bezier(0.3,1.6,0.5,1). Hover shows a circular surface behind the icon. Pressing scales the icon to 0.9. Share is a plain action button that changes its tooltip to "Copied" for 1.2 seconds. Focus-visible shows a 2px ring. Remove the pop animation under prefers-reduced-motion.

About this pattern

Definition

A button that shows only an icon. The icon sits inside a generous hit area, has an accessible name supplied by aria-label, and optionally acts as a toggle (like, bookmark, mute) reported through aria-pressed.

Purpose & UX principles

  • Saves space for familiar, repeated actions such as like, share or close.
  • The icon alone is not a label: provide aria-label and a tooltip for sighted users who are unsure.
  • Use filled icon plus colour change for the on state so that state is not communicated by colour alone.

Interaction states

  • Default, hover (circular surface appears), pressed (scale 0.9), focus-visible ring.
  • Toggled on: filled icon, accent colour, aria-pressed="true".
  • Toggling plays a small pop on the icon.

Motion specification

  • Hover surface: 140ms fade.
  • Pop on toggle: scale 1 → 1.25 → 1 in 280ms with spring-like easing.
  • Reduced motion: no pop, only the colour change.

Responsive behaviour

  • Visual size 24px, hit area at least 44×44px.
  • Tooltips appear on hover and focus only; on touch devices rely on the accessible name and clear iconography.

Code

HTML
<div class="row">
  <button class="ib" aria-label="Like" aria-pressed="false" data-tip="Like"><svg viewBox="0 0 24 24"><path d="M12 21s-8-5.2-8-11a4.5 4.5 0 018-2.8A4.5 4.5 0 0120 10c0 5.8-8 11-8 11z"/></svg></button>
  <button class="ib" aria-label="Bookmark" aria-pressed="false" data-tip="Bookmark"><svg viewBox="0 0 24 24"><path d="M6 3h12v18l-6-4-6 4z"/></svg></button>
  <button class="ib" id="share" aria-label="Share" data-tip="Share"><svg viewBox="0 0 24 24"><path d="M12 3l5 5-1.4 1.4L13 6.8V16h-2V6.8L8.4 9.4 7 8zM5 14h2v5h10v-5h2v7H5z"/></svg></button>
</div>

Related patterns

Primary & Secondary Button

↗
Primary & Secondary ButtonButtons & Actions

Floating Action Button

↗
Floating Action ButtonButtons & Actions

Press Feedback

↗
Press FeedbackButtons & Actions