Button
A tappable button with five styles, four sizes, and disabled and loading states.
Installation
This also adds Spinner, which shows while the button is loading. Button imports class-variance-authority (see Installation).
Usage
src/app/app.ts
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>element for you. - The button shrinks slightly while a finger is down, on every platform.
Variants
Sizes
icon makes a square button for a single character.
Disabled and loading
Both dim the button to 50% and ignore taps. loading also replaces the label with a spinner.
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 variant and size. Use it to style a view that isn't a <ui-button>, and color its text yourself.
src/app/settings-link.ts
API
UiButton
The file also exports buttonVariants and the ButtonVariant and ButtonSize types.
Related
- Button Group: connected buttons for related actions
- Toggle: a button that stays pressed
- Spinner: the loading indicator
- Handling taps and events
