sp-action-button
NPM
1.0.3
Storybook
View Storybook
Try it on
webcomponents.dev
1.0.3 (2024-12-09) #
Bug Fixes #
- action-button: action-button with href can be perceived by screen reader (
#4927 ) (2a0b3a5 )
1.0.1 (2024-11-11) #
Note: Version bump only for package @spectrum-web-components/action-button
1.0.0 (2024-10-31) #
BREAKING CHANGES #
- remove action-button variant property (
#4741 ) - remove deprecated 'static' references (
#4818 )
0.49.0 (2024-10-15) #
Features #
- add
static-color
to replacestatic
(#4808 ) (43cf086 )
0.48.1 (2024-10-01) #
Note: Version bump only for package @spectrum-web-components/action-button
0.48.0 (2024-09-17) #
Bug Fixes #
- picker: added a custom class to make
:focus-visible
styles consistent across all browsers (#4724 ) (d667d08 )
0.47.2 (2024-09-03) #
Note: Version bump only for package @spectrum-web-components/action-button
0.47.1 (2024-08-27) #
Note: Version bump only for package @spectrum-web-components/action-button
0.47.0 (2024-08-20) #
Note: Version bump only for package @spectrum-web-components/action-button
0.46.0 (2024-08-08) #
Note: Version bump only for package @spectrum-web-components/action-button
0.45.0 (2024-07-30) #
Note: Version bump only for package @spectrum-web-components/action-button
0.44.0 (2024-07-15) #
Note: Version bump only for package @spectrum-web-components/action-button
0.43.0 (2024-06-11) #
Note: Version bump only for package @spectrum-web-components/action-button
0.42.5 (2024-05-24) #
Note: Version bump only for package @spectrum-web-components/action-button
0.42.4 (2024-05-14) #
Note: Version bump only for package @spectrum-web-components/action-button
0.42.3 (2024-05-01) #
Note: Version bump only for package @spectrum-web-components/action-button
0.42.2 (2024-04-03) #
Note: Version bump only for package @spectrum-web-components/action-button
0.42.1 (2024-04-02) #
Note: Version bump only for package @spectrum-web-components/action-button
0.42.0 (2024-03-19) #
Bug Fixes #
- styles, theme: surface exports that omit Spectrum Vars proactively (
#4142 ) (5b524c1 )
Features #
- asset: use core tokens (
99e76f4 )
0.41.2 (2024-03-05) #
Note: Version bump only for package @spectrum-web-components/action-button
0.41.1 (2024-02-22) #
Note: Version bump only for package @spectrum-web-components/action-button
0.41.0 (2024-02-13) #
Features #
- icon: use core tokens (
a11ef6b )
0.40.5 (2024-02-05) #
Note: Version bump only for package @spectrum-web-components/action-button
0.40.4 (2024-01-29) #
Note: Version bump only for package @spectrum-web-components/action-button
0.40.3 (2024-01-11) #
Note: Version bump only for package @spectrum-web-components/action-button
0.40.2 (2023-12-18) #
Note: Version bump only for package @spectrum-web-components/action-button
0.40.1 (2023-12-05) #
Note: Version bump only for package @spectrum-web-components/action-button
0.40.0 (2023-11-16) #
Note: Version bump only for package @spectrum-web-components/action-button
0.39.4 (2023-11-02) #
Note: Version bump only for package @spectrum-web-components/action-button
0.39.3 (2023-10-18) #
Note: Version bump only for package @spectrum-web-components/action-button
0.39.2 (2023-10-13) #
Note: Version bump only for package @spectrum-web-components/action-button
0.39.1 (2023-10-06) #
Bug Fixes #
- action-button: allow change events to bubble and pierce shadowdom (
#3614 ) (3f76e04 )
0.39.0 (2023-09-25) #
Note: Version bump only for package @spectrum-web-components/action-button
0.38.0 (2023-09-05) #
Note: Version bump only for package @spectrum-web-components/action-button
0.37.0 (2023-08-18) #
Bug Fixes #
- handle longpress and over filter overlays (
483e52d )
0.36.0 (2023-08-18) #
Note: Version bump only for package @spectrum-web-components/action-button
0.35.0 (2023-07-31) #
Features #
- action-bar: use core tokens (
4e21edf )
0.34.0 (2023-07-11) #
Bug Fixes #
- action-button,action-menu,picker,split-button: expand and update application of aria-* attributes (
52c0156 ) - action-group: ensure Action Button clicks are attributed to the right element (
#3292 ) (ddccab7 )
0.33.2 (2023-06-14) #
Note: Version bump only for package @spectrum-web-components/action-button
0.33.0 (2023-06-08) #
Note: Version bump only for package @spectrum-web-components/action-button
0.32.0 (2023-06-01) #
Note: Version bump only for package @spectrum-web-components/action-button
0.31.0 (2023-05-17) #
Note: Version bump only for package @spectrum-web-components/action-button
0.30.0 (2023-05-03) #
Bug Fixes #
- action-button: add support for XS t-shirt size (
75440ce ) - action-button: all "selected" Action Buttons should be "aria-pressed=true" (
d85e235 ) - action-button: ensure disabled buttons are not interactable (
b81c3ba ) - action-button: expand Spectrum CSS processing (
ff1a424 ) - add t-shirt sizing to Thumbnail and support for "xxs"/"xs" sizes (
520a642 ) - correct specificity of webkit appearance work around (
f0d06bf ) - correctly delivery visuals and mouse interactions for litAnchor and extensions (
0ae889a ) - expand sized functionality to support no default and returning to default values (
acf3cfb ) - prevent default hoisting of custom pseudo elements (
7f66346 ) - prevent longpress when interacting with context menu (
f8b0732 ) - support a wider number of sizes (
ee44978 ) - update consumption of Spectrum CSS for latest version (
ed2305b ) - update export patterns (
b2da444 ) - update to latest spectrum-css packages (
a5ca19f ) - use icons without "size" values (
3fc7c91 ) - use the "browsers" listing in postcss-preset-env (
4eaf6a2 )
Features #
- action-button: add action button pattern (
03ac00a ) - action-group: manage "one" and "multiple" selections (
6fad59e ) - adopt DNA@7 base Spectrum CSS (
e08cafd ) - allow activation of longpress content (
55e71fd ) - apply sizedMixin for t-shirt sizing (
d7b63fb ) - icons-workflow: vend fully registered icon components (
941f3a4 ) - include all Dev Mode files in side effects (
f70817c ) - leverage latest Spectrum button API (
9caf2f6 ) - shared pkg versions, devmode define warning, registry-conflicts docs (
6e49565 ) - support Spectrum Token consumption and update Action Button to use them (
743ab16 ) - support static white and static black variants of Action Button (
7f1e25b ) - tabs: add sp-tab-panel element (
b17d276 ) - update lit-* dependencies, wip (
377f3c8 ) - use latest exports specification (
a7ecf4b ) - use SixedMixin to manage "size" property (
8819821 )
Performance Improvements #
- accept new Spectrum CSS featuring simpler DOM structure (
a0b042b )
0.10.16 (2023-04-24) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.15 (2023-04-05) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.14 (2023-03-22) #
Bug Fixes #
- prevent default hoisting of custom pseudo elements (
7f66346 )
Performance Improvements #
- accept new Spectrum CSS featuring simpler DOM structure (
a0b042b )
0.10.13 (2023-03-08) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.12 (2023-02-13) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.11 (2023-02-08) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.10 (2023-01-23) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.9 (2023-01-09) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.8 (2022-12-08) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.7 (2022-11-21) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.6 (2022-11-14) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.5 (2022-10-28) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.4 (2022-10-17) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.3 (2022-10-10) #
Bug Fixes #
- action-button: add support for XS t-shirt size (
75440ce )
0.10.2 (2022-09-14) #
Note: Version bump only for package @spectrum-web-components/action-button
0.10.1 (2022-08-24) #
Bug Fixes #
- prevent longpress when interacting with context menu (
f8b0732 )
0.10.0 (2022-08-09) #
Features #
- include all Dev Mode files in side effects (
f70817c )
0.9.1 (2022-08-04) #
Note: Version bump only for package @spectrum-web-components/action-button
0.9.0 (2022-07-18) #
Features #
- support Spectrum Token consumption and update Action Button to use them (
743ab16 )
0.8.7 (2022-06-29) #
Note: Version bump only for package @spectrum-web-components/action-button
0.8.6 (2022-06-07) #
Note: Version bump only for package @spectrum-web-components/action-button
0.8.5 (2022-05-27) #
Bug Fixes #
- update consumption of Spectrum CSS for latest version (
ed2305b )
0.8.4 (2022-05-12) #
Note: Version bump only for package @spectrum-web-components/action-button
0.8.3 (2022-04-21) #
Note: Version bump only for package @spectrum-web-components/action-button
0.8.2 (2022-03-30) #
Note: Version bump only for package @spectrum-web-components/action-button
0.8.1 (2022-03-08) #
Note: Version bump only for package @spectrum-web-components/action-button
0.8.0 (2022-03-04) #
Features #
- leverage latest Spectrum button API (
9caf2f6 ) - support static white and static black variants of Action Button (
7f1e25b )
0.7.4 (2022-02-22) #
Note: Version bump only for package @spectrum-web-components/action-button
0.7.3 (2022-01-26) #
Note: Version bump only for package @spectrum-web-components/action-button
0.7.2 (2022-01-07) #
Note: Version bump only for package @spectrum-web-components/action-button
0.7.1 (2021-12-13) #
Bug Fixes #
- add t-shirt sizing to Thumbnail and support for "xxs"/"xs" sizes (
520a642 ) - action-button: all "selected" Action Buttons should be "aria-pressed=true" (
d85e235 )
0.7.0 (2021-11-08) #
Features #
- update lit-* dependencies, wip (
377f3c8 )
0.6.1 (2021-11-08) #
Note: Version bump only for package @spectrum-web-components/action-button
0.6.0 (2021-11-02) #
Features #
- adopt DNA@7 base Spectrum CSS (
e08cafd )
0.5.9 (2021-10-12) #
Note: Version bump only for package @spectrum-web-components/action-button
0.5.8 (2021-09-20) #
Note: Version bump only for package @spectrum-web-components/action-button
0.5.7 (2021-09-13) #
Note: Version bump only for package @spectrum-web-components/action-button
0.5.6 (2021-08-24) #
Note: Version bump only for package @spectrum-web-components/action-button
0.5.5 (2021-08-03) #
Note: Version bump only for package @spectrum-web-components/action-button
0.5.4 (2021-07-22) #
Note: Version bump only for package @spectrum-web-components/action-button
0.5.3 (2021-07-01) #
Note: Version bump only for package @spectrum-web-components/action-button
0.5.2 (2021-06-16) #
Note: Version bump only for package @spectrum-web-components/action-button
0.5.1 (2021-06-07) #
Note: Version bump only for package @spectrum-web-components/action-button
0.5.0 (2021-05-24) #
Bug Fixes #
- action-button: ensure disabled buttons are not interactable (
b81c3ba )
Features #
- tabs: add sp-tab-panel element (
b17d276 )
0.4.7 (2021-05-12) #
Note: Version bump only for package @spectrum-web-components/action-button
0.4.6 (2021-04-15) #
Note: Version bump only for package @spectrum-web-components/action-button
0.4.5 (2021-04-09) #
Note: Version bump only for package @spectrum-web-components/action-button
0.4.4 (2021-03-29) #
Bug Fixes #
- action-button: expand Spectrum CSS processing (
ff1a424 )
0.4.3 (2021-03-22) #
Note: Version bump only for package @spectrum-web-components/action-button
0.4.2 (2021-03-22) #
Bug Fixes #
- correctly delivery visuals and mouse interactions for litAnchor and extensions (
0ae889a )
0.4.1 (2021-03-05) #
Note: Version bump only for package @spectrum-web-components/action-button
0.4.0 (2021-03-04) #
Bug Fixes #
- support a wider number of sizes (
ee44978 )
Features #
- use latest exports specification (
a7ecf4b )
0.3.0 (2021-02-11) #
Bug Fixes #
- expand sized functionality to support no default and returning to default values (
acf3cfb ) - update to latest spectrum-css packages (
a5ca19f )
Features #
- allow activation of longpress content (
55e71fd )
0.2.2 (2021-02-02) #
Note: Version bump only for package @spectrum-web-components/action-button
0.2.1 (2021-01-28) #
Note: Version bump only for package @spectrum-web-components/action-button
0.2.0 (2021-01-21) #
Bug Fixes #
- correct specificity of webkit appearance work around (
f0d06bf ) - update export patterns (
b2da444 ) - use icons without "size" values (
3fc7c91 ) - use the "browsers" listing in postcss-preset-env (
4eaf6a2 )
Features #
- apply sizedMixin for t-shirt sizing (
d7b63fb ) - use SixedMixin to manage "size" property (
8819821 ) - action-button: add action button pattern (
03ac00a ) - action-group: manage "one" and "multiple" selections (
6fad59e ) - icons-workflow: vend fully registered icon components (
941f3a4 )
0.1.0 (2021-01-13) #
Bug Fixes #
- update export patterns (
b2da444 ) - use icons without "size" values (
3fc7c91 )
Features #
- apply sizedMixin for t-shirt sizing (
d7b63fb ) - use SixedMixin to manage "size" property (
8819821 ) - action-button: add action button pattern (
03ac00a ) - action-group: manage "one" and "multiple" selections (
6fad59e ) - icons-workflow: vend fully registered icon components (
941f3a4 )
Attributes and Properties #
active
active
boolean
false
disabled
disabled
boolean
false
download
download
string | undefined
emphasized
emphasized
boolean
false
holdAffordance
hold-affordance
boolean
false
href
href
string | undefined
label
label
string | undefined
quiet
quiet
boolean
false
referrerpolicy
referrerpolicy
| 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url' | undefined
rel
rel
string | undefined
role
role
string
'button'
selected
selected
boolean
false
staticColor
static-color
'white' | 'black' | undefined
tabIndex
tabIndex
number
target
target
'_blank' | '_parent' | '_self' | '_top' | undefined
toggles
toggles
boolean
false
type
type
'button' | 'submit' | 'reset'
'button'
value
value
string
Slots #
default slot
icon
Events #
change
Event
Announces a change in the `selected` property of an action button
longpress
CustomEvent
Synthesizes a "longpress" interaction that signifies a `pointerdown` event that is >=300ms or a keyboard event where code is `Space` or code is `ArrowDown` while `altKey===true`.
Description #
An <sp-action-button>
represents an action a user can take.
Usage #
yarn add @spectrum-web-components/action-button
Import the side effectful registration of <sp-action-button>
via:
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:
import { ActionButton } from '@spectrum-web-components/action-button';
Sizes #
<sp-action-group size="xs"> <sp-action-button>Edit</sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group>
<sp-action-group size="s"> <sp-action-button>Edit</sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group>
<sp-action-group size="m"> <sp-action-button>Edit</sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group>
<sp-action-group size="l"> <sp-action-button>Edit</sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group>
<sp-action-group size="xl"> <sp-action-button>Edit</sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group>
Variants #
The <sp-action-button>
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 <sp-action-button>
. Content addressed to the icon
slot can also be provided and will be positioned just before the rest of the the supplied button content.
Standard #
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2em;" > <div> <sp-field-label for="standard">Default</sp-field-label> <sp-action-group id="standard"> <sp-action-button>Edit</sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-selected">Selected</sp-field-label> <sp-action-group id="standard-selected"> <sp-action-button selected>Edit</sp-action-button> <sp-action-button selected> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button selected> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button selected hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-disabled">Disabled</sp-field-label> <sp-action-group id="standard-disabled"> <sp-action-button disabled>Edit</sp-action-button> <sp-action-button disabled> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button disabled> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button disabled hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-disabled-selected"> Disabled + Selected </sp-field-label> <sp-action-group id="standard-disabled-selected"> <sp-action-button disabled selected>Edit</sp-action-button> <sp-action-button disabled selected> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button disabled selected> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button disabled selected hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> </div>
Quiet #
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2em;" > <div> <sp-field-label for="standard">Default</sp-field-label> <sp-action-group quiet id="standard"> <sp-action-button quiet>Edit</sp-action-button> <sp-action-button quiet> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button quiet> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button quiet hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-selected">Selected</sp-field-label> <sp-action-group quiet id="standard-selected"> <sp-action-button quiet selected>Edit</sp-action-button> <sp-action-button quiet selected> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button quiet selected> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button quiet selected hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-disabled">Disabled</sp-field-label> <sp-action-group quiet id="standard-disabled"> <sp-action-button quiet disabled>Edit</sp-action-button> <sp-action-button quiet disabled> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button quiet disabled> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button quiet disabled hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-disabled-selected"> Disabled + Selected </sp-field-label> <sp-action-group quiet id="standard-disabled-selected"> <sp-action-button quiet disabled selected>Edit</sp-action-button> <sp-action-button quiet disabled selected> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button quiet disabled selected> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button quiet disabled selected hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> </div>
Emphasized #
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2em;" > <div> <sp-field-label for="standard">Default</sp-field-label> <sp-action-group emphasized id="standard"> <sp-action-button emphasized>Edit</sp-action-button> <sp-action-button emphasized> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button emphasized> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button emphasized hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-selected">Selected</sp-field-label> <sp-action-group emphasized id="standard-selected"> <sp-action-button emphasized selected>Edit</sp-action-button> <sp-action-button emphasized selected> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button emphasized selected> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button emphasized selected hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-disabled">Disabled</sp-field-label> <sp-action-group emphasized id="standard-disabled"> <sp-action-button emphasized disabled>Edit</sp-action-button> <sp-action-button emphasized disabled> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button emphasized disabled> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button emphasized disabled hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-disabled-selected"> Disabled + Selected </sp-field-label> <sp-action-group emphasized id="standard-disabled-selected"> <sp-action-button emphasized disabled selected> Edit </sp-action-button> <sp-action-button emphasized disabled selected> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button emphasized disabled selected> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button emphasized disabled selected hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> </div>
Emphasized + Quiet #
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2em;" > <div> <sp-field-label for="standard">Default</sp-field-label> <sp-action-group emphasized quiet id="standard"> <sp-action-button emphasized quiet>Edit</sp-action-button> <sp-action-button emphasized quiet> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button emphasized quiet> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button emphasized quiet hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-selected">Selected</sp-field-label> <sp-action-group emphasized quiet id="standard-selected"> <sp-action-button emphasized quiet selected>Edit</sp-action-button> <sp-action-button emphasized quiet selected> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button emphasized quiet selected> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button emphasized quiet selected hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-disabled">Disabled</sp-field-label> <sp-action-group emphasized quiet id="standard-disabled"> <sp-action-button emphasized quiet disabled>Edit</sp-action-button> <sp-action-button emphasized quiet disabled> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button emphasized quiet disabled> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button emphasized quiet disabled hold-affordance> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> <div> <sp-field-label for="standard-disabled-selected"> Disabled + Selected </sp-field-label> <sp-action-group emphasized quiet id="standard-disabled-selected"> <sp-action-button emphasized quiet disabled selected> Edit </sp-action-button> <sp-action-button emphasized quiet disabled selected> <sp-icon-edit slot="icon"></sp-icon-edit> Edit </sp-action-button> <sp-action-button emphasized quiet disabled selected> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-action-button emphasized quiet disabled selected hold-affordance > <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> </sp-action-group> </div> </div>
Action button with hold affordance #
The use of the hold-affordance
attribute signifies that the <sp-action-button>
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.
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2em;" > <overlay-trigger placement="bottom-start"> <sp-action-button label="Edit" hold-affordance slot="trigger"> <sp-icon-edit slot="icon"></sp-icon-edit> </sp-action-button> <sp-popover slot="longpress-content" dialog tip> <p style="color: var(--spectrum-neutral-content-color-default);"> This content is triggered by the "longpress" interaction. </p> </sp-popover> </overlay-trigger> <overlay-trigger placement="top"> <sp-action-button hold-affordance quiet slot="trigger"> Show Longpress Content </sp-action-button> <sp-popover slot="longpress-content" dialog tip> <p style="color: var(--spectrum-neutral-content-color-default);"> This content is triggered by the "longpress" interaction. </p> </sp-popover> </overlay-trigger> <overlay-trigger placement="top-end"> <sp-action-button hold-affordance selected slot="trigger"> <sp-icon-edit slot="icon"></sp-icon-edit> Extended Content with Longpress </sp-action-button> <sp-popover slot="longpress-content" dialog tip> <p style="color: var(--spectrum-neutral-content-color-default);"> This content is triggered by the "longpress" interaction. </p> </sp-popover> </overlay-trigger> </div>
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.
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 2em;" > <div> <sp-field-label for="toggles-default">Standard</sp-field-label> <sp-action-button toggles id="toggles-default"> Toggle button </sp-action-button> </div> <div> <sp-field-label for="toggles-quiet">Quiet</sp-field-label> <sp-action-button toggles quiet id="toggles-quiet"> Toggle button </sp-action-button> </div> <div> <sp-field-label for="toggles-emphasized">Emphasized</sp-field-label> <sp-action-button toggles emphasized id="toggles-emphasized"> Toggle button </sp-action-button> </div> <div> <sp-field-label for="toggles-emphasized-quiet"> Emphasized + Quiet </sp-field-label> <sp-action-button toggles emphasized quiet id="toggles-emphasized-quiet" > Toggle button </sp-action-button> </div> </div>
Handling events #
Events handlers for clicks and other user actions can be registered on a <sp-action-button>
as on a standard HTML <button>
element.
<sp-button onclick="spAlert(this, '<sp-action-button> clicked!')"> Click me </sp-button>
In addition to handling events like a native <button>
HTML element, one can also use a <sp-action-button>
in place of the <a>
HTML element by using the href
and optional target
attribute.
<sp-action-button href="https://github.com/adobe/spectrum-web-components" target="_blank" > Click me </sp-action-button>