ButtonOptions
Defined in: components/button.ts:52
Options for button.
Properties
Section titled “Properties”content?
Section titled “content?”
optionalcontent?:Slot
Defined in: components/button.ts:54
Button content: a string for plain text, or a function for custom markup.
optionalicon?:Slot
Defined in: components/button.ts:56
Leading icon/adornment, drawn before the label.
click?
Section titled “click?”
optionalclick?: (event) =>unknown
Defined in: components/button.ts:68
Click handler.
Return a promise and the button goes busy until it settles: a spinner
rides after the label, and clicks (and keypresses) bounce off, so a slow
save can’t be started twice. Nothing to wire up — click: () => save() on
an async save is the whole thing, and a handler awaiting a
confirm counts: the button waits for the answer with everything
else. For a wait that isn’t a promise, put the button in the same state
yourself with attrs: ".s-busy".
Parameters
Section titled “Parameters”Event
Returns
Section titled “Returns”unknown
disabled?
Section titled “disabled?”
optionaldisabled?:boolean
Defined in: components/button.ts:70
Disables the button.
optionaltype?:"button"|"submit"|"reset"
Defined in: components/button.ts:72
Native button behaviour. Defaults to "button".
optionalhref?:string
Defined in: components/button.ts:74
Render as a link (<a role=button>) pointing here instead of a <button>.
ariaLabel?
Section titled “ariaLabel?”
optionalariaLabel?:string
Defined in: components/button.ts:79
Accessible label, when the button has only an icon. A string tooltip is
taken as the label of such a button when this is left out.
optionalkey?:string
Defined in: components/button.ts:89
A keyboard shortcut that presses this button: "mod+s", "f2" — see
bindKey for the spelling and which keystrokes are yours to take.
It works from anywhere while the button is drawn, shows in a tooltip,
reaches screen readers as aria-keyshortcuts, and does exactly what a
click does: a type: "submit" submits its form, an href navigates. The
? overview (showKeyHelp) lists it under the button’s text (or
its ariaLabel).
tooltip?
Section titled “tooltip?”
optionaltooltip?:false|Slot
Defined in: components/button.ts:100
A tooltip, shown on hover and keyboard focus. A string renders as rich
text, a function draws its own markup. There is none unless you ask for
one. A key is appended to it, behind a ·; pass false to suppress
even that. On an icon-only button, a string tooltip doubles as the
ariaLabel when that is left out.
Works on a disabled button too, which is where a tooltip earns its keep: it is the only room there is to say why.
attrs?
Section titled “attrs?”
optionalattrs?:string
Defined in: components/button.ts:111
Aberdeen attr/style string applied to the button. A button is a surface, so
pass surface modifier classes here to restyle it, e.g. ".danger",
".danger .outlined", or ".neutral" for a neutral button. Defaults to a
filled .primary surface.
Size is set here too, with .small or .large (medium is the default and
needs no class), e.g. ".danger .small". A .small/.large parent (such
as a buttonGroup) also sizes its buttons, so you can set it once.