Bedform UIButtons

Button

Trigger an action.

Use buttons for actions such as confirming a choice, opening a screen, or submitting a form.

Button

*
*
string
*
boolean
*
boolean
*
*

Usage

import { Button } from "@bedform/ui/button";

export function App() {
  return <Button type="button">Create new world</Button>;
}

Variants

<Button variant="default">Default</Button>
<Button variant="hero">Hero</Button>

Colors

<Button color="primary">Primary</Button>
<Button color="secondary">Secondary</Button>
<Button color="destructive">Delete</Button>
<Button color="dungeons">Dungeons</Button>
<Button color="legends">Legends</Button>
<Button color="gold">Gold</Button>
<Button color="realms">Realms</Button>

Disabled

<Button disabled>Unavailable</Button>

Loading

Set loading while an action is in progress. The button is then disabled and sets aria-busy="true".

<Button loading>Saving</Button>

Prefix and suffix

Use the public ore-button-prefix and ore-button-suffix classes to place presentational elements around the label.

import arrowLeftUrl from "@bedform/ui/icons/arrow-left";
import arrowRightUrl from "@bedform/ui/icons/arrow-right";

<Button type="button">
  <img className="ore-button-prefix" src={arrowLeftUrl} alt="" />
  Back
</Button>

<Button type="button">
  Continue
  <img className="ore-button-suffix" src={arrowRightUrl} alt="" />
</Button>

Button always renders a button. For navigation, give a native anchor the ore-button class. It keeps browser behaviors such as opening in a new tab, copying the link, and downloading a resource.

Open OreUI on GitHub
<a
  className="ore-button"
  href="https://example.com"
  target="_blank"
  rel="noreferrer"
>
  Open website
</a>

Use a link button for navigation and a regular button for actions. Anchors do not support disabled; omit href or remove the link when navigation is unavailable.

Forms

A native button defaults to type="submit" inside a form, so set type="button" on buttons that only run an action. name and value are included only when that button submits the form. Use form to associate a button outside the form with a form ID.

<form id="settings">
  <Button type="submit" name="action" value="save">
    Save
  </Button>
  <Button type="reset" color="secondary">
    Reset
  </Button>
</form>

<Button type="submit" form="settings" name="action" value="save-and-close">
  Save and close
</Button>

API

Button renders a native button and accepts every button attribute, such as disabled, form, name, type and value. It forwards its ref to the button.

PropTypeDefault
color"primary" | "secondary" | "destructive" | "dungeons" | "legends" | "gold" | "realms""primary"
loadingbooleanfalse
variant"default" | "hero""default"

CSS variables

VariablePurpose
--ore-button-unitBase size unit
--ore-button-background-defaultDefault face background
--ore-button-background-hoverHovered face background
--ore-button-background-pressedPressed face background
--ore-button-highlight-defaultDefault top highlight
--ore-button-highlight-hoverHovered top highlight
--ore-button-highlight-pressedPressed top highlight
--ore-button-borderBorder color
--ore-button-shadowBottom shadow color
--ore-button-foregroundText and icon color
--ore-button-font-familyLabel font family
--ore-button-font-sizeLabel font size
--ore-button-text-shadowLabel text shadow

Accessibility

Native buttons provide form participation, validation, focus, Enter, and Space behavior without a controller. Native anchors provide standard link semantics and navigation. Loading buttons remain disabled and expose aria-busy="true".

On this page