Button
An action, or a link that looks like one.
Variants
<div class="flex flex-wrap items-center gap-2">
{ui button, title: 'Primary' /}
{ui button, title: 'Secondary', class: 'bg-well' /}
{ui button, title: 'Outline', class: 'button-outline' /}
{ui button, title: 'Ghost', class: 'button-ghost' /}
{ui button, title: 'Destructive', class: 'bg-destructive' /}
{ui button, title: 'Success', class: 'bg-success' /}
{ui button, title: 'Link', class: 'button-link', href: '#' /}
</div>
Use one primary button per area for the main action, and bg-well, button-outline or button-ghost for the rest. bg-destructive is for actions that delete or can't be undone. button-link looks like a link. Colours are utilities and looks are classes, so pass them as class. current: true marks the button as the current one with aria-current, like the open section in a nav.
Sizes
<div class="flex flex-wrap items-center gap-2">
{ui button, title: 'Small', class: 'text-xs' /}
{ui button, title: 'Default' /}
{ui button, title: 'Large', class: 'text-base' /}
{ui button,
icon: 'plus',
class: 'button-icon',
attrs: ['aria-label' => 'Add'],
/}
</div>
button-icon makes a square button for an icon alone. Give it an aria-label, since it has no text.
Size by breakpoint
{ui button, title: 'Grows at lg', class: 'lg:text-base' /}
Size is the text size: text-xs, text-sm (the default), text-base and up, with any responsive prefix. The box, padding and icon scale together.
With an icon
<div class="flex flex-wrap items-center gap-2">
{ui button, title: 'New page', icon: 'plus' /}
{ui button, title: 'Download', icon: 'download', class: 'button-outline' /}
</div>
With content
<div class="flex flex-wrap items-center gap-2">
{ui button, class: 'button-outline'}
Inbox
{ui badge, title: '3', class: 'bg-well' /}
{/ui}
{ui button}
Saving
{ui spinner /}
{/ui}
</div>
title is the plain-text form. For anything more, such as a badge or a spinner, put the content inside a paired {ui button} tag instead.
Disabled
<div class="flex flex-wrap items-center gap-2">
{ui button, title: 'Button', disabled: true /}
{ui button, title: 'Link', href: '#', disabled: true /}
</div>
A disabled link has no disabled attribute to set, so it gets aria-disabled and leaves the tab order instead.