Button

One button in three sizes and four looks. It squeezes a little when pressed.

Default
Small
Large
With icon
Disabled

Installation

Terminal
npx shadcn@latest add https://fabrickit.org/r/button.json

This copies the component into components/fabricui. It's your code from then on. First time? Add the theme once: see Installation.

Code

components/fabricui/button.tsx
import * as React from "react";
import "./button.css";

export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
  /** primary: the one main action · ghost: secondary · soft: small inline actions · danger: destructive */
  variant?: "primary" | "ghost" | "soft" | "danger";
  /** sm 28px (inside rows) · md 34px (inside panels) · lg 38px (on the page) */
  size?: "sm" | "md" | "lg";
};

/**
 * Button. Squeezes a little when pressed; shows Fabric Kit's focus ring for
 * the keyboard. Put an icon (an <svg>) before or after the label.
 */
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(
  { variant = "primary", size = "md", className, type = "button", ...props },
components/fabricui/button.css
/*
 * Button — sizes sm (28px), md (34px, the default), lg (38px); looks primary,
 * ghost, soft, danger. Corners follow Fabric Kit's roundness rule (40% of the
 * height), so every size is the same shape. Squeezes a little when pressed;
 * a ring shows for keyboard focus.
 */
.fui-btn {
  all: unset;
  box-sizing: border-box;
  flex: none;
  --h: 34px;
  height: var(--h);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;

Usage

Usage
import { Button } from "@/components/fabricui/button";

export function Actions() {
return (
  <div className="flex gap-2">
    <Button>Save changes</Button>
    <Button variant="ghost">Cancel</Button>
  </div>
);
}

Props

PropTypeDefault
variant

primary for the one main action, ghost for secondary, soft for small inline actions, danger for destructive ones.

"primary" | "ghost" | "soft" | "danger""primary"
size

sm (28px) inside rows, md (34px) inside panels, lg (38px) on the page.

"sm" | "md" | "lg""md"
...props

Anything a <button> takes: onClick, disabled, type, aria-*.

ButtonHTMLAttributes—