jbmui

Piece

  • UI Bits

Picks the button, input, or card illustration by kind and sizes it from one width.

Install

npx shadcn@latest add @jbm/piece

Needs the @jbm entry in components.json; see Install once.

Also installs @jbm/paper, @jbm/ui-button, @jbm/ui-input, @jbm/ui-card.

Usage

One button
import { Piece } from "@/jbm/ui/piece"<Piece kind="button" w={220} />
A row of every kind
import { Piece, type PieceKind } from "@/jbm/ui/piece"const kinds: PieceKind[] = ["button", "input", "card"]<div style={{ display: "flex", gap: 30, alignItems: "center" }}>  {kinds.map((kind) => <Piece key={kind} kind={kind} w={180} tone="accent" cursorOn={false} />)}</div>

API

Stage px
Declared at the documented defaults
Landscape
220 by 70
Vertical
220 by 70
Basis

No defaults: w is required. At w = 220 a button or input is 220 × 70 (round(0.32 × w)); a card is 220 × 172 (round(0.78 × w)).

Piececomponent

Renders UiButton, UiInput, or UiCard for kind at width w; height follows each piece's proportion (button and input 0.32 × w, card 0.78 × w). Lets a list of { kind } entries render interface pieces without branching.

PropTypeDefaultDescription
kindPieceKindrequiredWhich piece to draw: button, input, or card.
wnumberrequiredWidth in stage pixels; height is derived from it per kind.
tonePaperTonenoneButton tone only (ink by default, accent, or paper); ignored by input and card.
cursorOnbooleannoneInput only: shows or hides the text cursor (UiInput default: shown); ignored by button and card.
styleReact.CSSPropertiesnoneInline styles forwarded to the chosen piece.

PieceKindtype

The piece names: "button" | "input" | "card".

QA checks

  • Render all three kinds at the same w and check their heights (0.32, 0.32, 0.78 × w) and baseline alignment in a row.
  • Pass tone and cursorOn to each kind: tone changes only the button and cursorOn only the input.