> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Button

A tappable button with five solid styles, three Liquid Glass styles, five sizes, and disabled and loading states.


## Installation

```bash
npx @blotch/dolan add button
```

```typescript
import { UiButton } from '../components/ui/button';
```

This also adds [Spinner](/dolan/spinner.md), which shows while the button is loading, [Icon](/dolan/icon.md), and [Glass](/dolan/glass.md), which draws the glass variants. Button imports `class-variance-authority` (see [Installation](/dolan/index.md#installation)).

## Usage

```typescript title="src/app/app.ts"
import { Component, signal } from '@angular/core';
import { UiButton } from '../components/ui/button';

@Component({
  selector: 'app-root',
  imports: [UiButton],
  template: `
    <ui-button [loading]="saving()" (pressed)="save()">
      {{ saving() ? 'Saving...' : 'Save changes' }}
    </ui-button>
  `,
})
export class App {
  protected readonly saving = signal(false);

  protected save(): void {
    this.saving.set(true);
  }
}
```

- `pressed` fires on tap. It doesn't fire while the button is disabled or loading.
- Put plain text inside. The button wraps it in a `<text>` in the variant's label color.
- Don't wrap the text in a `<view>`. Lynx text takes its color only from a `<text>` directly around it, so text inside your view draws in the default black, which barely shows on a dark button. For an icon, use [`<ui-icon>`](#icons). For a spinner, use [`loading`](#disabled-and-loading).
- The button shrinks slightly while a finger is down, on every platform.

### Variants

```angular-html
<ui-button variant="default">Default</ui-button>
<ui-button variant="destructive">Delete</ui-button>
<ui-button variant="outline">Outline</ui-button>
<ui-button variant="secondary">Secondary</ui-button>
<ui-button variant="ghost">Ghost</ui-button>
```

### Glass

Liquid Glass buttons, for controls that float over your content, like SwiftUI's glass button styles:

```angular-html
<ui-button variant="glass">Edit</ui-button>
<ui-button variant="glass-prominent">Done</ui-button>
<ui-button variant="glass-clear">Save</ui-button>
```

- **`glass`** is regular glass, SwiftUI's `.glass`. Use it for most floating buttons.
- **`glass-prominent`** is tinted with the theme's `glass-tint`, the primary color by default, like `.glassProminent`. Keep it for the screen's main action.
- **`glass-clear`** is clear glass, for buttons over photos and video. It sits on a dark dimming layer (`glass-dim`), so its white label stays legible over bright content.
- **The glass reacts to touch.** On iOS 26 it swells and brightens under the finger. Elsewhere the button shrinks, as the solid ones do.
- **Glass belongs on the layer above content.** Put glass buttons over a photo, a map or a scrolling list, not in a form.

What each platform draws:

| Platform                                          | `glass` and `glass-clear`                      | `glass-prominent`          |
| ------------------------------------------------- | ---------------------------------------------- | -------------------------- |
| iOS 26 and later                                  | Liquid Glass, drawn by iOS                     | Liquid Glass in the tint   |
| iOS 15 to 25                                      | The thin blur material, dark for `glass-clear` | A filled button            |
| Android                                           | A Material 3 filled tonal button               | A Material 3 filled button |
| Android, with [`provideGlass()`](/dolan/glass.md) | Glass without the refraction                   | Glass in the tint          |
| [Web preview](/guide/glossary.md#web-preview)     | Liquid Glass, drawn with WebGL                 | Liquid Glass in the tint   |

On Android the glass variants are Material buttons unless your app [opts into glass](/dolan/glass.md#what-each-platform-draws): fully rounded, flat, with Material's pressed state layer instead of a shrink.

### Sizes

```angular-html
<ui-button size="sm">Small</ui-button>
<ui-button size="default">Default</ui-button>
<ui-button size="lg">Large</ui-button>
<ui-button size="icon">+</ui-button>
<ui-button size="icon-circle" accessibility-label="Search">
  <ui-icon name="search" />
</ui-button>
```

- **The default is 48px tall**, a full touch target on iOS and Android, and as tall as a field such as [Input](/dolan/input.md) or [Select](/dolan/select.md), so a button beside one lines up.
- **`lg` is 56px**, for a screen's main action, such as Continue at the bottom of a form.
- **`sm` is 36px**, for a button inside a row or a card. Its touch target is still 48px: it reaches 6px past the button on every side.
- **`icon`** makes a 48px square button for a single character or icon.
- **`icon-circle`** makes a circle for one icon.
- **Glass buttons are capsules,** so a glass button in either icon size is a circle.

### Icons

Put a [`<ui-icon>`](/dolan/icon.md) in the button. It takes the label's color:

```angular-html
<ui-button variant="glass">
  <ui-icon name="share-2" />
  Share
</ui-button>

<ui-button variant="secondary">
  Next
  <ui-icon name="arrow-right" trailing />
</ui-button>

<ui-button variant="glass" size="icon-circle" accessibility-label="Add">
  <ui-icon name="plus" />
</ui-button>
```

- **The icon fits the button's size:** 20px beside a default button's label, 16px in a small button, and 24px in a large one or on its own. Set the icon's `size` to choose another.
- **An icon goes before the label,** wherever you write it.
- **Add `trailing` to put it after the label,** for an icon that points onward, such as Next or Open. A button can have one on each side.
- **In an icon size, the button shows the icon alone.** Give it an `accessibility-label`, which a screen reader says instead.
- **The icon can be your own SVG,** such as a sign-in provider's mark: `<ui-icon [svg]="githubMark" />` (see [Your own SVG](/dolan/icon.md#your-own-svg)).

### Disabled and loading

```angular-html
<ui-button disabled>Disabled</ui-button>

<ui-button [loading]="saving()">
  {{ saving() ? 'Saving...' : 'Save' }}
</ui-button>
```

Both dim the button to 50% and ignore taps. A glass button dims its label and keeps the glass, as iOS does.

`loading` also shows a spinner in the label's color. It goes before the label, in place of a leading icon, and the label stays, so change it to say what's happening. A trailing icon stays too. In an icon size, the spinner replaces the icon.

### Custom classes

```angular-html
<ui-button class="w-full">Continue</ui-button>
```

Your classes are merged onto the button's container and replace any default they conflict with.

### Button styles on your own view

`buttonVariants()` returns the container classes for a solid variant and a size. Use it to style a view that isn't a `<ui-button>`, and color its text yourself. Glass needs a [`<blur-view ui-glass>`](/dolan/glass.md), which classes can't draw.

```typescript title="src/app/settings-link.ts"
import { Component } from '@angular/core';
import { LYNX_ELEMENTS } from '@blotch/angular-lynx';
import { buttonVariants } from '../components/ui/button';

@Component({
  selector: 'app-settings-link',
  imports: [LYNX_ELEMENTS],
  template: `
    <view [class]="linkClass">
      <text class="text-sm font-medium text-foreground">Settings</text>
    </view>
  `,
})
export class SettingsLink {
  protected readonly linkClass = buttonVariants({
    variant: 'outline',
    size: 'sm',
  });
}
```

## API

### UiButton

| Input                 | Type                                                                                                                 | Default     | Description                                                                      |
| --------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------- |
| `variant`             | `'default' \| 'destructive' \| 'outline' \| 'secondary' \| 'ghost' \| 'glass' \| 'glass-prominent' \| 'glass-clear'` | `'default'` | Visual style.                                                                    |
| `size`                | `'default' \| 'sm' \| 'lg' \| 'icon' \| 'icon-circle'`                                                               | `'default'` | Height and padding: 48, 36 and 56px. `icon` is a square, `icon-circle` a circle. |
| `disabled`            | `boolean`                                                                                                            | `false`     | Dims the button and ignores taps.                                                |
| `loading`             | `boolean`                                                                                                            | `false`     | Shows a spinner before the label, dims the button, ignores taps.                 |
| `accessibility-label` | `string`                                                                                                             | —           | What a screen reader says. Needed for an icon-only button.                       |
| `class`               | `string`                                                                                                             | `''`        | Extra Tailwind classes for the container.                                        |

| Output    | Type   | Description                               |
| --------- | ------ | ----------------------------------------- |
| `pressed` | `void` | Emits on tap, unless disabled or loading. |

The file also exports `buttonVariants` and the `ButtonVariant`, `SolidButtonVariant`, `GlassButtonVariant` and `ButtonSize` types.

## Accessibility

- **A screen reader reads the label as a button.** With `accessibility-label`, the whole button is one element that says the label instead.
- **Reduce Motion:** the button dims while pressed instead of shrinking. Interactive glass in the web preview stops swelling. iOS calms its own glass.
- **Reduce Transparency and Increase Contrast:** the glass follows them as [Glass](/dolan/glass.md#accessibility) does. Clear glass that turns solid drops its dimming layer and its white label. Under Increase Contrast, Android's tonal buttons get an outline.

## Related

- [Button Group](/dolan/button-group.md): connected buttons for related actions, or a group on one glass background
- [Glass](/dolan/glass.md): the Liquid Glass the glass variants draw
- [Toggle](/dolan/toggle.md): a button that stays pressed
- [Spinner](/dolan/spinner.md): the loading indicator
- [Handling taps and events](/guide/elements/event-handling.md)
