Icon-Only Button Template
Save space and provide intuitive controls with this set of clean, icon-only buttons.
These buttons are essential for user interfaces that require compact actions, such as settings toggles, item deletions, or editing functions.
About Icon-Only Buttons
Icon-only buttons are a staple of modern UI design, used when an action's meaning can be conveyed effectively by a symbol alone. They help to de-clutter interfaces and are especially useful in toolbars or next to items in a list. Because they lack visible text, making them accessible is a top priority. This template shows how to create them accessibly for all users.
Features
- Accessibility is Key: Each
buttonincludes a descriptivearia-labelattribute. This provides the "accessible name" of the button, so a screen reader will announce "Settings" or "Delete" even though no text is visible. - Embedded SVG Icons: Uses lightweight, inline SVGs that are easy to style with CSS and require no external files.
- Subtle, Clean Style: A minimalist design with a soft background color change on hover, suitable for any interface.
- Flexible and Reusable: The CSS is designed so you can easily create new icon buttons by simply adding a new SVG.
Code Breakdown
The buttons are styled to be circular and use Flexbox to perfectly center the icon within. The most important part of the HTML from an accessibility perspective is the aria-label on each button. Without it, the buttons would be confusing or completely unusable for screen reader users. The SVG icons inside are given aria-hidden="true" because their purpose is purely decorative; the accessible name is already provided by the parent button's aria-label.
Code
Here is the complete code for the accessible icon-only buttons.