Button

Variants

Without data-variant a button is outline. Use one primary button per page.

Sizes

Icon-only buttons use data-size="icon" or icon-sm and need an aria-label.

Icon and disabled

Put the icon before the text. Disabled links use aria-disabled="true"

Delete icon button

A red trash icon in an outline frame, or ghost (data-variant="ghost danger") for table rows.

Delete at the end of a row of fields

The button does not shrink in a narrow row (flex-shrink: 0), so it always keeps its size at the end of the row.

Button group

.btn-group joins buttons into one set. Add role="group" and an aria-label.

Pressed toggle buttons

aria-pressed="true" gives a button a grey background to show it is on. Put data-pressed="single" on the group to allow one button at a time, or multiple to let each button toggle on its own (needs JS).

Button group with a menu

The last button in the group opens a dropdown with popovertarget. The popover can sit inside the group without affecting the buttons' rounded corners.

Attributes

Attribute / element Values Description
.btn button, a A button. Use on <button type="button"> or a link.
data-variant (none = outline, default), primary, secondary, ghost, danger, ghost danger Button style. Takes several values separated by spaces, e.g. ghost danger is a red ghost button.
data-size (none = 36px, default), sm (28px), lg (40px), xl (48px), icon, icon-sm icon / icon-sm are 36px / 28px square buttons for a single icon.
aria-label text Required on icon-only buttons.
.icon i, Lucide icon name Icon inside a button. Always add aria-hidden="true".
aria-pressed true, false Toggle button. true shows a grey background.
disabled boolean Disables the button.
aria-disabled true Disables an a.btn link.
.btn-group div Joined group of buttons. Children are .btn. Add role="group" and an aria-label.
data-pressed single, multiple Put on .btn-group (or any element) so JS toggles aria-pressed on the buttons inside: one at a time, or each on its own.
.dropdown popover, id The group's menu. It can sit inside .btn-group and opens from a group button with popovertarget. It does not count as a button for the rounded corners.

API

No functions. Buttons in a [data-pressed] group work through event delegation, so buttons added later work too.

Event Detail Description
tsunami:pressedchange { button, pressed } Fires from the element with data-pressed (bubbles) after a button click. button is the clicked button, pressed is its new state.