Skip to content

<sessions-button>

A button, or a link styled as one when to is set.

Preact & React<Button>GroupActionsDrawn asButton

Preview

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
to
A 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 to
type
submit submits the sessions-form the button is in, and shows the button loading until the form’s submit handler settles.buttonsubmitProp type
emphasis
Visual prominence.subduednormalstrongProp emphasis
tone
A semantic colour.normaldestructiveProp tone
size
Control size.normalsmallProp size
disabledboolean
Non-interactive.Prop disabled
loadingboolean
Shows a spinner and blocks interaction.Prop loading
aria-label
An accessible name when the label is not descriptive.Prop ariaLabel

Events

clickdetail: undefined
The button was pressed.Prop onClick
Example
import {Button} from '@sessions/apps/preact';

<Button emphasis="strong" onClick={() => model.save()}>
  Save playlist
</Button>

In the same group