Button
A tappable button with five solid styles, three Liquid Glass styles, five sizes, and disabled and loading states.
Installation
This also adds Spinner, which shows while the button is loading, Icon, and Glass, which draws the glass variants. Button imports class-variance-authority (see Installation).
Usage
pressedfires 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>. For a spinner, useloading. - The button shrinks slightly while a finger is down, on every platform.
Variants
Glass
Liquid Glass buttons, for controls that float over your content, like SwiftUI's glass button styles:
glassis regular glass, SwiftUI's.glass. Use it for most floating buttons.glass-prominentis tinted with the theme'sglass-tint, the primary color by default, like.glassProminent. Keep it for the screen's main action.glass-clearis 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:
On Android the glass variants are Material buttons unless your app opts into glass: fully rounded, flat, with Material's pressed state layer instead of a shrink.
Sizes
- The default is 48px tall, a full touch target on iOS and Android, and as tall as a field such as Input or Select, so a button beside one lines up.
lgis 56px, for a screen's main action, such as Continue at the bottom of a form.smis 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.iconmakes a 48px square button for a single character or icon.icon-circlemakes 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> in the button. It takes the label's color:
- 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
sizeto choose another. - An icon goes before the label, wherever you write it.
- Add
trailingto 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).
Disabled and loading
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
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>, which classes can't draw.
API
UiButton
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 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: connected buttons for related actions, or a group on one glass background
- Glass: the Liquid Glass the glass variants draw
- Toggle: a button that stays pressed
- Spinner: the loading indicator
- Handling taps and events
