# Button

The action trigger, in four sizes, a tone and a variant.

## Sizes

Four sizes, `tiny` to `large`; the default fits most rows.

## Tones

`tone` says what a click does: the base for most actions, primary for the one the view is for, danger for what cannot be undone. The status tones match a message's severity.

## Variants

`variant` sets the weight: solid by default, outlined and text quieter, link inline with prose.

## Modifiers

`rounded`, `hoverable` and `full` adjust the shape, the hover and the width.

## Labels and icons

`children` also takes a string, for buttons built from data at runtime. An icon sits before the label; in a fixed-width button, a growing label pushes it to an end. A button with only an icon takes an `aria-label` for its name.

## States

`disabled` blocks the click; `inactive` only looks it and stays clickable; `aria-checked` makes it a toggle.

## Links

With `href` the button renders as a link, inside or out.

## Examples

```svelte
<script lang="ts">
  import Button from '@qualia-studios/design-ui/components/Button.svelte';
</script>
```

### Example 1: Four sizes

```svelte
<Button size="tiny">Tiny</Button>
<Button size="small">Small</Button>
<Button>Default</Button>
<Button size="large">Large</Button>
```

### Example 2: Action tones

```svelte
<Button>Base</Button>
<Button tone="primary">Primary</Button>
<Button tone="danger">Danger</Button>
```

### Example 3: Status tones

```svelte
<Button tone="warning">Warning</Button>
<Button tone="success">Success</Button>
<Button tone="info">Info</Button>
<Button tone="help">Help</Button>
```

### Example 4: Four variants

```svelte
<Button tone="primary">Solid</Button>
<Button tone="primary" variant="outlined">Outlined</Button>
<Button tone="primary" variant="text">Text</Button>
<Button variant="link">Link</Button>
```

### Example 5: Rounded and hoverable

```svelte
<Button tone="primary" rounded>Rounded</Button>
<Button tone="primary" hoverable>Hoverable</Button>
```

### Example 6: Full width

full fills its container.

```svelte
<Button tone="primary" full>Full width</Button>
```

### Example 7: A label from a string

```svelte
<Button tone="primary" children="Save" />
<Button variant="outlined" tone="danger" children="Delete" />
```

### Example 8: A leading icon

```svelte
<Button tone="primary">
  <div class="icon create"></div>
  <span>New project</span>
</Button>
<Button tone="danger" variant="outlined">
  <div class="icon trash"></div>
  <span>Delete</span>
</Button>
```

### Example 9: An icon at either end

In a fixed width, the growing label pushes the icon out.

```svelte
<Button variant="outlined" style="width: 12rem;">
  <div class="icon caret-left"></div>
  <span class="grow">Back</span>
</Button>
<Button variant="outlined" style="width: 12rem;">
  <span class="grow">Next</span>
  <div class="icon caret-right"></div>
</Button>
```

### Example 10: Icon-only buttons

Each is named by its aria-label.

```svelte
<Button tone="primary" aria-label="Settings">
  <div class="icon settings"></div>
</Button>
<Button variant="outlined" size="small" aria-label="Close">
  <div class="icon close"></div>
</Button>
```

### Example 11: Disabled and inactive

```svelte
<Button tone="primary">Enabled</Button>
<Button tone="primary" disabled>Disabled</Button>
<Button tone="primary" inactive>Inactive (still clickable)</Button>
```

### Example 12: A toggle, on and off

```svelte
<Button tone="primary" aria-checked="true">Toggle on</Button>
<Button tone="primary" aria-checked="false">Toggle off</Button>
```

### Example 13: Links, outside and in

```svelte
<Button href="https://qualiastudios.dev">External link</Button>
<Button href={resolve('/components')} tone="primary">Internal link</Button>
```

---

From the Qualia design guide: https://q-core-3b2732.gitlab.io/components/button. Every page as markdown: https://q-core-3b2732.gitlab.io/llms.txt
