An `<sp-action-button>` represents an action a user can take.
npm install @spectrum-web-components/action-buttonAn represents an action a user can take.



``bash`
yarn add @spectrum-web-components/action-button
Import the side effectful registration of via:
`ts`
import '@spectrum-web-components/action-button/sp-action-button.js';
When looking to leverage the ActionButton base class as a type and/or for extension purposes, do so via:
`ts`
import { ActionButton } from '@spectrum-web-components/action-button';
`html`
#### Content
elements can be provided a visible label,
a label and an icon, or just an icon.
An icon is provided by placing an icon element in the icon slot.
If the button is icon-only, a non-visible labellabel
can be provided via the attribute on an
or on an element child to appropriately
fulfill the accessibility contract of the button.
`html demo`
`html demo`
Icon + Label
`html demo`
slot="icon"
viewBox="0 0 36 36"
focusable="false"
aria-hidden="true"
role="img"
>
>
SVG Icon + Label
`html demo`
#### Sizes
`html demo`
Edit
`html demo`
Edit
`html demo`
Edit
`html demo`
Edit
`html demo`
Edit
#### Variants
The can be customized with either or both of the emphasized and quiet attributes. These will pair with either or both of the state attributes (selected and disabled) to decide the final visual delivery of the . Content addressed to the icon slot can also be provided and will be positioned just before the rest of the the supplied button content.
`html demo
style="display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2em;"
>
Edit
Quiet
`html demo
style="display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2em;"
>
Default
Edit
Edit
Selected
Edit
Edit
Disabled
Edit
Edit
Disabled + Selected
Edit
Edit
label="Edit"
quiet
disabled
selected
hold-affordance
>
Emphasized
`html demo
style="display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2em;"
>
Default
Edit
Edit
Selected
Edit
Edit
Disabled
Edit
Edit
Disabled + Selected
Edit
Edit
label="Edit"
emphasized
disabled
selected
hold-affordance
>
Emphasized + quiet
`html demo
style="display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2em;"
>
Default
Edit
Edit
Selected
Edit
Edit
label="Edit"
emphasized
quiet
selected
hold-affordance
>
Disabled
Edit
Edit
label="Edit"
emphasized
quiet
disabled
hold-affordance
>
Disabled + Selected
Edit
Edit
label="Edit"
emphasized
quiet
disabled
selected
hold-affordance
>
$3
#### Action button with hold affordance
The use of the
hold-affordance attribute signifies that the in question will be delivered with a visual affordance outlining that special interaction with the button will dispatch a longpress event. Via a pointer input, this even will be dispatched when 300ms has passed after a pointerdown event without the presence of a pointerup or pointercancel event. Via the keyboard, an event with a code of Space or or ArrowDown while altKey === true will dispatch the event.`html demo
style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2em;"
>
This content is triggered by the "longpress" interaction.
Show Longpress Content
This content is triggered by the "longpress" interaction.
Extended Content with Longpress
This content is triggered by the "longpress" interaction.
#### Toggles
With the application of the
toggles attribute, the button will self manage its selected property on click. When this value is updated, a cancellable change event will be dispatched to inform the parent application.
Default
`html demo
Toggle button
Toggle button
`
Quiet
`html demo
Toggle button
Toggle button
`
Emphasized
`html demo
Toggle button
Toggle button
`
Emphasized + Quiet
`html demo
Toggle button
toggles
emphasized
quiet
selected
id="toggles-emphasized-quiet"
>
Toggle button
`
#### Handling events
Events handlers for clicks and other user actions can be registered on a
as on a standard HTML