Piece
Picks the button, input, or card illustration by kind and sizes it from one width.
Install
npx shadcn@latest add @jbm/pieceNeeds the @jbm entry in components.json; see Install once.
Also installs @jbm/paper, @jbm/ui-button, @jbm/ui-input, @jbm/ui-card.
Usage
import { Piece } from "@/jbm/ui/piece"<Piece kind="button" w={220} />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:
wis 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.
| Prop | Type | Default | Description |
|---|---|---|---|
kind | PieceKind | required | Which piece to draw: button, input, or card. |
w | number | required | Width in stage pixels; height is derived from it per kind. |
tone | PaperTone | none | Button tone only (ink by default, accent, or paper); ignored by input and card. |
cursorOn | boolean | none | Input only: shows or hides the text cursor (UiInput default: shown); ignored by button and card. |
style | React.CSSProperties | none | Inline 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.