Icon Button
Alignment target:@astryxdesign/core v0.7.1 · IconButton
Usage #
IconButton displays one icon. The icon must clearly identify the action. Set label to provide an accessible name:
Vue
<script setup lang="ts">
import { Icon } from '@astryx-vue/core/Icon'
import { IconButton } from '@astryx-vue/core/IconButton'
</script>
<template>
<IconButton label="Search">
<Icon name="carbon:search" />
</IconButton>
</template>Icon fills the square the button already sizes. Leave size unset. A CSS icon class still works in the slot when your build generates it; UnoCSS is not required.
Use a text-bearing Button when the action is not immediately clear.
Best practices #
| Guidance | Practices |
|---|---|
| Do | Make the aria-label specific: a trash icon labeled "Delete conversation" is clearer than just "Delete" for screen readers. |
| Do | Add a tooltip: even a gear icon can mean Settings, Preferences, or Configure. |
| Do | Use ghost in toolbars and dense areas to reduce visual clutter. |
| Don't | Use IconButton if the action isn't obvious from the icon alone; use Button with text. |
| Don't | Skip the tooltip; label only reaches screen readers, sighted users need the hover hint. |
Examples #
Icon Button — Action bar
Row of ghost icon buttons for a compact action toolbar.
Icon Button — Floating
A floating action button. The most common floating-button shape is icon-only. Raised here with elevation="high".
Icon Button — Loading state
Icon buttons that show a loading spinner on click for async feedback.
Icon Button — With tooltips
Icon buttons with tooltips that explain each action on hover.