Skip to content
Focsd homeFocsd homeFocsd
Forms

Icon button

A square button with only an icon. The label is required and becomes its accessible name.

  • Tag: focsd-icon-button
  • Pattern: Button with accessible label
  • Category: Actions

Example

HTML
<focsd-icon-button icon="trash" label="Delete file"></focsd-icon-button>
<focsd-icon-button icon="copy" label="Copy link" variant="quiet"></focsd-icon-button>
<focsd-icon-button
icon="edit"
label="Rename project"
variant="action"></focsd-icon-button>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-icon-button.js';
</script>
<focsd-icon-button icon="trash" label="Delete file"></focsd-icon-button>

API

Attributes

AttributePropertyTypeDefault
iconiconstring—
labellabelstring—
icon-libraryiconLibrarystring—
variantvariant'plain' | 'action' | 'quiet' | 'critical'plain
typetype'button' | 'submit' | 'reset'button
disableddisabledbooleanfalse
namenamestring—
valuevaluestring—
expandedexpandedboolean—
haspopuphaspopupstring—
descriptiondescriptionstring—
popovertargetpopoverTargetstring—
popovertargetactionpopoverTargetAction'toggle' | 'show' | 'hide'toggle
commandforcommandForstring—
commandcommandstring—
formactionformActionstring—
formmethodformMethodstring—
formenctypeformEnctypestring—
formnovalidateformNoValidatebooleanfalse
formtargetformTargetstring—

Slots

SlotDescription
(default)Your own icon, replacing the named one.

CSS parts

Style the inside of the component with ::part(), for example focsd-icon-button::part(icon).

PartDescription
iconThe named icon.
controlThe control element.

Accessibility

  • popovertarget and commandfor/command work as on focsd-button.
  • Named by label through aria-label; the icon is decorative (aria-hidden).
  • Square at the control height (36px by default), above the 24px target minimum.
  • Pair with a tooltip if sighted users may not recognize the icon.

Keyboard

KeyAction
Enter / SpaceActivates the button