Skip to the content

Button

Button renders a native <button> that triggers an action: submit a form, open a dialog, confirm a choice. Pick its weight with variant and its meaning with color; keep one contained primary action per view.
Actions@apollion-dsi/core/elements/button24.2 kB gzip

When to use

Use when
  • The user performs an action — save, submit, delete, open a dialog.
  • The action needs a visible text label.
Avoid when
  • The control navigates to another page — use Link.
  • The control is a single icon — use IconButton.
  • The content is a static label — use Label or Text.

Usage

loading

Variants and colors

variant sets the visual weight: contained (default, solid), outlined (border only), linked (text only) and ghost (nothing at rest, a wash on hover; meant for chrome clusters). color takes a semantic palette: primary (default), secondary, tertiary, success, warning, danger or neutral — a quiet palette with no brand hue, for chrome actions that must not compete with the page's primary action.

<Button variant="contained" text="Contained" />
<Button color="secondary" variant="outlined" text="Outlined" />
<Button variant="linked" text="Linked" />
<Button variant="ghost" text="Ghost" />
<Button color="neutral" variant="outlined" text="Neutral" />
<Button color="danger" text="Danger" />

Sizes

size takes extraSmall, small, medium (default) or large. fullWidth stretches the button to its container.

<Button size="extraSmall" text="extraSmall" />
<Button size="large" text="large" />

The size scale is a theme token: override theme.component.button.size.<size> (fontSize, fontWeight, py, px, borderRadius, optional textTransform) through createTheme({ component: { button: … } }).

Icons

icon takes any node, usually an Icon. iconPosition places it left (default) or right.

<Button color="danger" icon={<Icon icon={trash} />} text="Delete" />
<Button variant="linked" icon={<Icon icon={shareAlt} />} iconPosition="right" text="Share" />

Accessibility

  • Renders a native <button>: Enter and Space activate it, and disabled is forwarded.
  • The label is children or text (children wins). Give every button a visible, specific label.
  • isLoading swaps the content for a spinner but does not disable the button; set disabled to block repeat submits.
  • Under forced colors (Windows High Contrast), the focus outline is restored with the system Highlight color.

Properties

See also