Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

Components / Core

Button

Button, or a link that looks like one when you pass href.

import { Button } from "@stylhero/ui";

Example

Code
import { Button, Stack } from "@stylhero/ui";

function ButtonExample() {
  return (
    <Stack direction="row" gap={2} wrap align="center">
      <Button>Save</Button>
      <Button variant="secondary">Cancel</Button>
      <Button variant="ghost">Skip</Button>
      <Button variant="danger">Delete</Button>
      <Button loading>Saving</Button>
      <Button href="#props" variant="secondary" size="sm">Read the props</Button>
    </Stack>
  );
}

Props

PropTypeDefaultDescription
fullWidth boolean -
href string - Renders a link styled as a button, through your router's link (see LinkProvider). http(s):// links open in a new tab. Links can't be disabled or loading: render a Button without href for that.
loading boolean - Shows a spinner and disables the button while keeping its width.
size "sm" | "md" | "lg" "md"
variant "primary" | "secondary" | "ghost" | "danger" "primary"

Also takes every <button> attribute (id, style, data-*, aria-*, event handlers…), passed to that element. Takes a ref.

Keyboard

KeyDoes
Enter / SpaceActivates it (a native <button>); with href, Enter follows the link

Accessibility

  • loading sets aria-busy and disables the button, keeping its width.
  • With href it's a real link, so screen readers announce it as a link.

Generated from src/components/Button.tsx. Something wrong or missing? Open an issue.