jbmui

FileCabinet

  • UI Bits
  • adjustable

SVG cabinet enclosure around a controlled filing drawer whose folders slide out and lift.

pruebasdiseñoanálisis
Folders3 folders

Install

npx shadcn@latest add @jbm/file-cabinet

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

Also installs @jbm/tokens, @jbm/cajon, @jbm/scene-geometry.

Docs

Usage

Open cabinet with one folder
import { FileCabinet } from "@/jbm/ui/file-cabinet"<svg viewBox="0 -260 500 650">  <FileCabinet x={80} folders={[{ name: "datos" }]} open={1} /></svg>
Lift the front folder
import { FileCabinet } from "@/jbm/ui/file-cabinet"<svg viewBox="0 -260 500 700">  <FileCabinet x={85} y={-20} w={330} h={350} open={0.8}    folders={[{ name: "análisis", accent: true, pulled: 0.6 }, { name: "diseño" }]} /></svg>

API

Stage px
Declared at the documented defaults
Landscape
300 by 360
Vertical
300 by 360
Basis

Default w 300 by h 360 in the parent SVG's units, placed at x, y. The drawer stays inside the enclosure at every opening, but lifted folders rise above the top by up to about their height plus 24 (roughly 190 units at the default width), so the parent viewBox needs headroom: the gallery uses "0 -260 500 700".

FileCabinetcomponent

An SVG <g> for use inside your own <svg>: a fixed card enclosure with a chamfered top, and a Cajon drawer inset 10px at the sides and 32px from the top. open and per-folder pulled are controlled 0–1; the enclosure never moves or resizes.

PropTypeDefaultDescription
xnumbernoneLeft edge of the enclosure in the parent SVG's units.
ynumbernoneTop edge of the enclosure.
wnumbernoneEnclosure width; the drawer is w − 20.
hnumbernoneEnclosure height; the drawer is h − 44.
foldersreadonly DrawerFolder[]requiredFolders in the drawer, index 0 nearest the front. Each is a Cajon DrawerFolder: name (tab label, drawn whole; long names compress), optional accent fill, pulled 0–1 lift, light k, flap open, name reveal, and sublabel. Count never changes the drawer size; the folders pack within the same 48-unit rise.
opennumbernoneDrawer opening from 0 (closed) to 1 (open). Clamped.
depthSpacingnumbernoneRise between folders. Defaults to the packed 48 / max(5, n − 1), so the drawer stays under the enclosure top; pass a larger value to fan the tabs (they then rise above the cabinet).
tabLayout"stair" | "stagger3"noneTab placement; defaults to "stagger3" (left, center, right) in a cabinet so packed tabs stay readable. "stair" puts every tab at the left edge.
labelSizenumbernoneTab name size in SVG units (default 13).

Also accepts Partial<Box>.

FileCabinetBodycomponent

The enclosure alone, so composites (such as Escritorio) can draw foreground furniture between it and the moving drawer.

PropTypeDefaultDescription
xnumberrequiredLeft edge in the parent SVG's units.
ynumberrequiredTop edge.
wnumberrequiredWidth.
hnumberrequiredHeight.

fileCabinetLayoutfunction

Computes the enclosure box and the drawer props FileCabinet renders, for composites that draw the parts separately.

ParamTypeDefaultDescription
xnumber0Left edge of the enclosure.
ynumber0Top edge of the enclosure.
wnumber300Enclosure width.
hnumber360Enclosure height.
foldersreadonly DrawerFolder[]requiredDrawer folders, passed through to the drawer.
opennumbernoneDrawer opening 0–1, passed through to the drawer.
depthSpacingnumbernoneRise, in parent SVG units, from one folder to the next one back. Defaults to tab height plus a band of back panel (the tab and band stay visible up to six folders; more folders pack into the same rise, so the stack never grows past six folders' height).
tabLayout"stair" | "stagger3"nonestair: every tab at its folder's left edge, so the tabs climb as folders narrow toward the back. stagger3: tabs cycle left, center, right.
labelSizenumbernoneTab name size in parent SVG units; the tab height and sublabel size follow it.

Returns { body: Box, drawer: CajonProps }: the enclosure box and the inset drawer props (x + 10, y + 32, w − 20, h − 44).

QA checks

  • Drag Open through 0, 0.5, and 1: the enclosure never moves or resizes and only the drawer travels toward the viewer.
  • Try folder counts 0, 1, 3, 6, and 12: the drawer size is unchanged and extra folders pack toward the back.
  • Drag Lift front folder to 1: the folder body is complete behind the drawer front, keeps its size, and stays within the viewBox headroom.
  • Check the preview at narrow widths; the SVG scales with its viewBox.