<sessions-button>
A button, or a link styled as one when to is set.
Preact & React
<Button>GroupActionsDrawn asButtonPreview
Drawn by the same renderers Sessions uses for your extension, from the DOM example beside it, without its event handlers.
When to use it
The primary way an extension acts. Listen for click; while an async handler runs, set loading yourself to show progress. With to it becomes a link and click is not fired.
In Preact and React, import the component of the same name from @sessions/apps/preact or @sessions/apps/react. Attributes become camelCase props, a boolean attribute is a boolean prop, and an event is an on prop that receives the event’s detail.
Attributes
Attribute
toA URL to open instead of firing
click: an https:, http:, mailto: or tel: URL, or a Sessions path. Absolute URLs open in a new tab. Any other scheme renders the button disabled.Prop totypesubmit submits the sessions-form the button is in, and shows the button loading until the form’s submit handler settles.buttonsubmitProp typeemphasisVisual prominence.
subduednormalstrongProp emphasistoneA semantic colour.
normaldestructiveProp tonesizeControl size.
normalsmallProp sizedisabledbooleanNon-interactive.Prop
disabledloadingbooleanShows a spinner and blocks interaction.Prop
loadingaria-labelAn accessible name when the label is not descriptive.Prop
ariaLabelEvents
clickdetail: undefinedThe button was pressed.Prop
onClickExample
import {Button} from '@sessions/apps/preact';
<Button emphasis="strong" onClick={() => model.save()}>
Save playlist
</Button>In the same group
<sessions-banner>A callout with a heading and a body.<sessions-badge>A small status label.<sessions-image>An image with an accessible description.<sessions-embed>A Spotify, Apple Music or YouTube player in a sandboxed frame.<sessions-disclosure-group>Stacks sessions-disclosure rows with dividers between them.<sessions-disclosure>A row that expands to reveal its children.