# Button
> Displays a button, with variants, sizes, an optional icon and a loading state.
Source: https://native.shellui.dev/docs/components/form/button
## Installation
```bash
shellui-native add button
```
**Platforms:** MAUI · Avalonia. Also installs `icon`, `button-variants`.
## Usage
### Variants
**MAUI**
```xml
```
**Avalonia**
```xml
```
[Live preview](https://native.shellui.dev/preview/index.html?c=button-variants)
### Sizes
**MAUI**
```xml
```
**Avalonia**
```xml
```
[Live preview](https://native.shellui.dev/preview/index.html?c=button-sizes)
### With an icon
`Icon` takes any name from the icon set; `IconPosition` puts it before or after the text.
**MAUI**
```xml
```
**Avalonia**
```xml
```
[Live preview](https://native.shellui.dev/preview/index.html?c=button-icon)
### Loading and disabled
While `IsLoading` is true the button shows a spinner and ignores clicks.
**MAUI**
```xml
```
**Avalonia**
```xml
```
[Live preview](https://native.shellui.dev/preview/index.html?c=button-loading)
## Events
Handle `Clicked`. It fires for a click, a tap, and Enter or Space while the button has keyboard focus.
```csharp
SaveButton.Clicked += async (_, _) =>
{
SaveButton.IsLoading = true;
await SaveAsync();
SaveButton.IsLoading = false;
};
```
## MAUI and Avalonia
The same on both. For a full-width button, set `HorizontalOptions="Fill"` on MAUI and `HorizontalAlignment="Stretch"` on Avalonia.
## API
| Property | Type | Default | Description |
|---|---|---|---|
| `Variant` | `ButtonVariant` | `Default` | Visual style. One of `Default`, `Destructive`, `Outline`, `Secondary`, `Ghost`, `Link`. |
| `Size` | `ButtonSize` | `Default` | Size preset. One of `Default`, `Sm`, `Lg`, `Icon`. |
| `IsLoading` | `bool` | `false` | Shows a spinner and ignores clicks. |
| `Text` | `string` | — | Label text. |
| `Icon` | `IconName` | `None` | Lucide icon from `IconName`; `None` for no icon. |
| `IconPosition` | `IconPosition` | `Left` | Side of the text the icon sits on. One of `Left`, `Right`. |
| Event | Arguments | Description |
|---|---|---|
| `Clicked` | — | Clicked or tapped (or Enter / Space with keyboard focus). |
| Method | Description |
|---|---|
| `Press()` | Clicks in code, as a pointer click or Enter/Space would. Avalonia only. |