Button

A button, or anything drawn as one, with its words and icons as children, solid by default.

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

const Example = () => <Button>Button</Button>;

export default Example;

Usage

import { Button } from "@produkto/ui/Button";
<Button>Button</Button>

Examples

Appearances

appearance paints the button on the kit's one scale: solid, the default, then soft, outline and transparent for quieter actions.

import { Button, type ButtonAppearance } from "@produkto/ui/Button";

const appearances: { appearance: ButtonAppearance; label: string }[] = [
  { appearance: "solid", label: "Solid" },
  { appearance: "soft", label: "Soft" },
  { appearance: "outline", label: "Outline" },
  { appearance: "transparent", label: "Transparent" },
];

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    {appearances.map((item) => (
      <Button appearance={item.appearance} key={item.appearance}>
        {item.label}
      </Button>
    ))}
  </div>
);

export default Example;

Tones

tone sets the colour, neutral by default, accent, destructive, success, warning or info, and works with every appearance: a solid accent button is a form's main action, a solid destructive one deletes, a soft one warns. Where the host asks for solidLikeFields, a neutral solid button takes a field's look and accent stays filled.

import { Button, type ButtonTone } from "@produkto/ui/Button";

const tones: { tone: ButtonTone; label: string }[] = [
  { tone: "neutral", label: "Neutral" },
  { tone: "accent", label: "Accent" },
  { tone: "destructive", label: "Destructive" },
  { tone: "success", label: "Success" },
  { tone: "warning", label: "Warning" },
  { tone: "info", label: "Info" },
];

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    {tones.map(({ tone, label }) => (
      <Button key={tone} tone={tone}>
        {label}
      </Button>
    ))}
  </div>
);

export default Example;

Sizes

size sets the height from xs to lg, and a button holding only an icon is square at each of them.

import { ArrowUpRight01Icon } from "@hugeicons/core-free-icons";
import { Button, type ButtonSize } from "@produkto/ui/Button";
import { Icon } from "@produkto/ui/Icon";

const sizes: { size: ButtonSize; label: string }[] = [
  { size: "xs", label: "Extra small" },
  { size: "sm", label: "Small" },
  { size: "base", label: "Base" },
  { size: "lg", label: "Large" },
];

const Example = () => (
  <div className="flex flex-col gap-4">
    <div className="flex flex-wrap items-center gap-2">
      {sizes.map((item) => (
        <Button key={item.size} size={item.size}>
          {item.label}
        </Button>
      ))}
    </div>
    <div className="flex flex-wrap items-center gap-2">
      {sizes.map((item) => (
        <Button aria-label="Button" key={item.size} size={item.size}>
          <Icon icon={ArrowUpRight01Icon} />
        </Button>
      ))}
    </div>
  </div>
);

export default Example;

Border radius

borderRadius sets the corners on the kit's one scale: none, xs 4px, sm 6px, base 8px, lg 12px, xl 16px, or full to round it, which makes a button holding only an icon a circle; base is the default at every size.

import { Add01Icon } from "@hugeicons/core-free-icons";
import { Button, type ButtonBorderRadius } from "@produkto/ui/Button";
import { Icon } from "@produkto/ui/Icon";

const radii: ButtonBorderRadius[] = [
  "none",
  "xs",
  "sm",
  "base",
  "lg",
  "xl",
  "full",
];

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    {radii.map((borderRadius) => (
      <Button key={borderRadius} borderRadius={borderRadius}>
        {borderRadius}
      </Button>
    ))}
    <Button aria-label="Button" borderRadius="full">
      <Icon icon={Add01Icon} />
    </Button>
  </div>
);

export default Example;

With icon

An icon goes in as a child, and data-icon="inline-start" or "inline-end" trims the padding on its side.

import { ArrowRight01Icon, Download01Icon } from "@hugeicons/core-free-icons";
import { Button } from "@produkto/ui/Button";
import { Icon } from "@produkto/ui/Icon";

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    <Button>
      <Icon icon={Download01Icon} data-icon="inline-start" />
      Button
    </Button>
    <Button>
      Button
      <Icon icon={ArrowRight01Icon} data-icon="inline-end" />
    </Button>
  </div>
);

export default Example;

Icon only

An icon alone makes the button square at every size, and aria-label names it for a screen reader.

import {
  Copy01Icon,
  Delete01Icon,
  Edit03Icon,
  Share08Icon,
} from "@hugeicons/core-free-icons";
import { Button } from "@produkto/ui/Button";
import { Icon, type IconSvgElement } from "@produkto/ui/Icon";

const icons: IconSvgElement[] = [
  Edit03Icon,
  Copy01Icon,
  Share08Icon,
  Delete01Icon,
];

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    {icons.map((icon, at) => (
      <Button aria-label="Button" key={at}>
        <Icon icon={icon} />
      </Button>
    ))}
  </div>
);

export default Example;

Loading

loading spins in place of the button's icon, or before its words when it has none, and holds off clicks until it is done; off is the default.

import { Add01Icon } from "@hugeicons/core-free-icons";
import { Button } from "@produkto/ui/Button";
import { Icon } from "@produkto/ui/Icon";

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    <Button>Button</Button>
    <Button loading>Button</Button>
    <Button loading>
      <Icon icon={Add01Icon} />
      Button
    </Button>
    <Button loading aria-label="Button">
      <Icon icon={Add01Icon} />
    </Button>
  </div>
);

export default Example;

Wrap

A button keeps its words on one line by default; wrap lets long ones run onto more lines, the button growing with them, as a list of long choices does.

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

const words = "Content goes here. Content goes here. Content goes here.";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col items-start gap-2">
    <Button>{words}</Button>
    <Button wrap>{words}</Button>
  </div>
);

export default Example;

Block

block stretches the button across its row, as a form's last button or a menu's footer does, so a page never writes the width itself; by default it is as wide as its words.

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

const Example = () => (
  <div className="flex w-full max-w-xs flex-col items-start gap-2">
    <Button>Button</Button>
    <Button block>Button</Button>
  </div>
);

export default Example;

Muted

muted writes the words in the muted grey, darkening on hover, on focus and while its menu is open, for quiet controls such as a breadcrumb or a social icon.

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

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    <Button>Button</Button>
    <Button muted>Button</Button>
  </div>
);

export default Example;

Align

align sets the words and icons at the button's start, centre or end when it is wider than them, as a block button is: start for the rows of a list such as a sidebar's or a list of suggestions.

import { Add01Icon } from "@hugeicons/core-free-icons";
import { Button } from "@produkto/ui/Button";
import { Icon } from "@produkto/ui/Icon";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-2">
    <Button align="start" block>
      <Icon icon={Add01Icon} />
      Button
    </Button>
    <Button block>
      <Icon icon={Add01Icon} />
      Button
    </Button>
    <Button align="end" block>
      <Icon icon={Add01Icon} />
      Button
    </Button>
  </div>
);

export default Example;

Href

href makes the button a link to that address, opened through Next's link and drawn as a button; target and rel open another site in a new tab.

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

const Example = () => <Button href="#">Button</Button>;

export default Example;

Disabled

disabled dims the button and holds off clicks, beside one as it is by default.

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

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    <Button>Button</Button>
    <Button disabled>Button</Button>
  </div>
);

export default Example;

API Reference

Button

ButtonProps · components/Button/Button.types.ts
PropTypeDefault
hrefstring-
targetHTMLAttributeAnchorTarget-
relstring-
prefetchboolean-
appearanceButtonAppearance"solid" | "soft" | "outline" | "transparent""solid"
toneButtonTone"neutral" | "accent" | "destructive" | "success" | "warning" | "info""neutral"
sizeButtonSize"xs" | "sm" | "base" | "lg""base"
wrapbooleanfalse
blockbooleanfalse
mutedbooleanfalse
alignButtonAlign"start" | "center" | "end""center"
borderRadiusButtonBorderRadius"none" | "xs" | "sm" | "base" | "lg" | "xl" | "full""base"
loadingbooleanfalse
onClickMouseEventHandler<HTMLElement>-
type"button" | "submit" | "reset""button"

It also takes the props of <button>.