# Button: variants, sizes and states

> iVOLT button: primary, secondary, ghost and danger variants, sizes, icon-only, disabled and loading states, and button groups. CSS only.

Source: https://ivolt.intervolutions.com/components/button · iVOLT 1.1.2 · English

Use a `<button>` for actions and an `<a>` for navigation; both take the same classes. No JavaScript is involved.

**CSS:** included in `ivolt.css`; standalone `css/components/button.css` (needs `core.css`).

Couldn't load the demo. [Open alone](https://ivolt.intervolutions.com/stage/button/variants.html?id=fx-button-variants)

```html
<div class="iv-cluster">
  <button class="iv-button iv-button--primary" type="button">Primary</button>
  <button class="iv-button iv-button--secondary" type="button">Secondary</button>
  <button class="iv-button iv-button--ghost" type="button">Ghost</button>
  <button class="iv-button iv-button--danger" type="button">Danger</button>
  <button class="iv-button" type="button">Neutral</button>
  <a class="iv-button iv-button--secondary" href="#docs">Link as button</a>
</div>
```

## Variants

Without a variant the button is neutral. `--primary` is for the main action of a view, `--secondary` outlines, `--ghost` is text-only, `--danger` marks destructive actions.

## Sizes and icon-only

Default height is 2.5rem; `--sm` is 2rem and `--lg` 3rem. Icon-only buttons need `aria-label` and keep a square target of at least 24×24 px.

Couldn't load the demo. [Open alone](https://ivolt.intervolutions.com/stage/button/sizes.html?id=fx-button-sizes)

```html
<div class="iv-cluster">
  <button class="iv-button iv-button--primary iv-button--sm" type="button">Small</button>
  <button class="iv-button iv-button--primary" type="button">Default</button>
  <button class="iv-button iv-button--primary iv-button--lg" type="button">Large</button>
  <button class="iv-button iv-button--secondary iv-button--icon" type="button" aria-label="Search">
    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg>
  </button>
</div>
```

## States

Use the native `disabled` attribute on buttons and `aria-disabled="true"` on links. `aria-busy="true"` shows a spinner, blocks pointer events and keeps the label. Hover styles only apply on devices with hover; the focus ring uses `--iv-color-focus` on `:focus-visible`.

Couldn't load the demo. [Open alone](https://ivolt.intervolutions.com/stage/button/states.html?id=fx-button-states)

```html
<div class="iv-cluster">
  <button class="iv-button iv-button--primary" type="button" disabled>Disabled</button>
  <a class="iv-button iv-button--secondary" href="#docs" aria-disabled="true">Disabled link</a>
  <button class="iv-button iv-button--primary" type="button" aria-busy="true">Saving…</button>
</div>
```

## Groups

Couldn't load the demo. [Open alone](https://ivolt.intervolutions.com/stage/button/group.html?id=fx-button-group)

```html
<div class="iv-button-group" role="group" aria-label="View mode">
  <button class="iv-button iv-button--secondary" type="button" aria-pressed="true">List</button>
  <button class="iv-button iv-button--secondary" type="button" aria-pressed="false">Grid</button>
  <button class="iv-button iv-button--secondary" type="button" aria-pressed="false">Map</button>
</div>
```

## Customising

```css
.iv-button { --iv-button-radius: var(--iv-radius-full); }
.iv-button--primary { --iv-button-bg: var(--iv-color-accent); --iv-button-fg: var(--iv-color-on-accent); }
```

Local properties: `--iv-button-bg`, `--iv-button-fg`, `--iv-button-border`, `--iv-button-radius`.

## Common mistakes

- A `<div>` with the button class: not focusable, no keyboard activation.
- Icon-only button without `aria-label`.
- Several `--primary` buttons in one view; keep one main action.
