# Button

Renders a real `<button type="button">` by default. Use `render` when the action navigates rather than does something in place, so it renders as an `<a>` instead.

## Examples

### Variants

Four visual weights, from the primary action to a destructive one.

### With icons

iconStart/iconEnd, or an icon alone with aria-label for an icon-only button. Icons sit in a slot concentric with the corner, drawn at --kernel-icon-size; an icon-only button is square, or a circle at Round.

### Disabled

Native disabled state — no aria-disabled workaround needed.

### Rendered as a link

render swaps in a real <a> for actions that navigate instead of acting in place.

## Playground

Toggle every adjustable prop and watch the button — and the code — update live. Use the **Unstyled** switch to preview the same DOM without Kernel visuals (same idea as omitting `styles.css` on [Platforms](/platforms/)).

## Props

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `variant` | `"primary" \| "secondary" \| "ghost" \| "danger"` | `"secondary"` | Visual role of the button. Defaults to `secondary`. |
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | Defaults to `md`. |
| `loading` | `boolean` | `false` | Shows a spinner and marks the button `aria-disabled` and `aria-busy` without changing its layout width. |
| `iconStart` | `ReactNode` | — | Icon placed before the label: any `svg`, `img` or icon component. It's drawn at `--kernel-icon-size` in a slot concentric with the button's corner. With no label (or a lone icon as `children`) the button is icon-only: square, or a circle at Round. Pass icon components here rather than as children: a lone `svg` / `img` child is also treated as icon-only, but a component child is always treated as the label. |
| `iconEnd` | `ReactNode` | — | Icon placed after the label. Same sizing as `iconStart`. |
| `className` | `ClassNameValue<ButtonState>` | — | A class string, or a function of the component's state that returns one. |
| `render` | `RenderProp<ButtonState>` | — | Render as a different element, e.g. an anchor styled as a button. The default is a real `<button type="button">`. |
| `data-slot` | `string` | `"button"` | Overrides the default `data-slot="button"` composition hook. A component that renders a Button as one of its own named parts sets this so its slot name is the one consumers can select (`Dialog` 's close control is `dialog-close`, not `button`) — matching what the same component's Custom Element already emits. Declared explicitly because it can't just ride in with the rest of the props: the default below is applied after the spread, so it would otherwise win. |

### Web Components

| Tag | Attributes | Events |
| --- | --- | --- |
| `<kernel-button>` | `aria-label`, `aria-labelledby`, `aria-describedby`, `variant`, `size`, `disabled`, `loading`, `type` | — |

## Accessibility

- Space and Enter activate it, focus and disabled state are native.
- When rendered via `render` as something other than a button (an `<a>`, say), `disabled` becomes `aria-disabled` plus a blocked click handler, since non-form elements have no native disabled behaviour.
- `loading` sets `aria-busy` without changing the button's width.
