Button
Trigger an action.
Use buttons for actions such as confirming a choice, opening a screen, or submitting a form.
Button
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>Links
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.
<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.
| Prop | Type | Default |
|---|---|---|
color | "primary" | "secondary" | "destructive" | "dungeons" | "legends" | "gold" | "realms" | "primary" |
loading | boolean | false |
variant | "default" | "hero" | "default" |
CSS variables
| Variable | Purpose |
|---|---|
--ore-button-unit | Base size unit |
--ore-button-background-default | Default face background |
--ore-button-background-hover | Hovered face background |
--ore-button-background-pressed | Pressed face background |
--ore-button-highlight-default | Default top highlight |
--ore-button-highlight-hover | Hovered top highlight |
--ore-button-highlight-pressed | Pressed top highlight |
--ore-button-border | Border color |
--ore-button-shadow | Bottom shadow color |
--ore-button-foreground | Text and icon color |
--ore-button-font-family | Label font family |
--ore-button-font-size | Label font size |
--ore-button-text-shadow | Label 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".