Icon

A wrapper for sized SVG icons.

When to use

Use the icon wrapper to align and size an SVG beside text or inside a control. Use Icon button when the symbol is the only visible content of an action.

Default

Set aria-hidden="true" on decorative icon wrappers. The Showcase Astro wrapper supplies this attribute by default; the published package supplies the CSS classes.

HTML
<i class="icon icon-sm" aria-hidden="true">
	<svg viewBox="0 0 640 640" focusable="false">
		<path
			d="M128 160h384M128 320h384M128 480h384"
			fill="none"
			stroke="currentColor"
			stroke-width="64"
			stroke-linecap="round"></path>
	</svg>
</i>

Sizes and semantics

Use .icon-sm, .icon-md, .icon-lg or .icon-xl to match the surrounding text and control size. Changing the icon size does not change a button’s accessible name or target size.

Display utilities also apply to the wrapper: .icon.d-none hides it, and .icon.d-none.d-md-inline-flex reveals it from md upward. With selective imports, include both components/icon and scss/display; either import order works.

Accessibility and behavior

  • Hide decorative wrappers with aria-hidden="true". Keep the visible text or control label responsible for the meaning.
  • For an informative standalone icon, expose a suitable role and accessible name on one element and hide redundant SVG content. In the Astro wrapper, set decorative={false} when supplying those semantics.
  • Icons are not focusable actions by themselves. Place actions in native buttons or links and preserve their visible focus styles.

CSS variables

This component has no component-specific CSS custom properties. Its four sizes are defined by the .icon-sm, .icon-md, .icon-lg and .icon-xl classes.