Icon button
A square button with only an icon. The label is required and becomes its accessible name.
Example
<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>import { IconButton } from '@focsd-dev/react';
export function Example() { return <IconButton icon="trash" label="Delete file"></IconButton>;}<script setup>import '@focsd-dev/components/focsd-icon-button.js';</script>
<template> <focsd-icon-button icon="trash" label="Delete file"></focsd-icon-button></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-icon-button.js';
// template<focsd-icon-button icon="trash" label="Delete file"></focsd-icon-button><script> import '@focsd-dev/components/focsd-icon-button.js';</script>
<focsd-icon-button icon="trash" label="Delete file"></focsd-icon-button>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
icon | icon | string | — |
label | label | string | — |
icon-library | iconLibrary | string | — |
variant | variant | 'plain' | 'action' | 'quiet' | 'critical' | plain |
type | type | 'button' | 'submit' | 'reset' | button |
disabled | disabled | boolean | false |
name | name | string | — |
value | value | string | — |
expanded | expanded | boolean | — |
haspopup | haspopup | string | — |
description | description | string | — |
popovertarget | popoverTarget | string | — |
popovertargetaction | popoverTargetAction | 'toggle' | 'show' | 'hide' | toggle |
commandfor | commandFor | string | — |
command | command | string | — |
formaction | formAction | string | — |
formmethod | formMethod | string | — |
formenctype | formEnctype | string | — |
formnovalidate | formNoValidate | boolean | false |
formtarget | formTarget | string | — |
Slots
| Slot | Description |
|---|---|
(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).
| Part | Description |
|---|---|
icon | The named icon. |
control | The control element. |
Accessibility
popovertargetandcommandfor/commandwork as onfocsd-button.- Named by
labelthrougharia-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
| Key | Action |
|---|---|
| Enter / Space | Activates the button |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.