Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
paths: - "apps/erp/app/components/" - "apps/mes/app/components/" - "packages/react/**"
UI Conventions
Use Existing Components First
Before writing any UI, grep packages/react/src/ and apps/erp/app/components/.
Prefer a built-in component (and its variants) over hand-rolled markup, and prefer
built-in variants over ad-hoc bg-* / text-* classes.
- Primitives come from
@carbon/react— the shared library barrel-exported atpackages/react/src/index.tsx. Components live flat inpackages/react/src/(e.g.packages/react/src/Button.tsx), NOT under acomponents/subdir. - Form fields come from
~/components/Formin the ERP app (apps/erp/app/components/Form/index.ts), which re-exports@carbon/formfields plus Carbon domain selectors (Customer, Employee, Item, Location, ...). - App-level shared components live in
apps/erp/app/components/(barrelindex.ts) andapps/mes/app/components/— reach for these before writing new cross-feature UI.
import { Button, Card, HStack, VStack, IconButton, cn } from "@carbon/react";
import { Input, Select, Submit, Number, Boolean } from "~/components/Form";
cn (from @carbon/react, defined in packages/react/src/utils/cn.ts) is the
standard class merge helper — twMerge(clsx(...)). Use it to compose classes.
Button
Button (packages/react/src/Button.tsx) is the canonical button. Pick a built-in
variant rather than styling a bare element.
- variant:
primary(default) ·secondary·solid·active·destructive·ghost·outline·link - size:
sm·md(default) ·lg - props:
isDisabled,isLoading,isIcon,isRound,leftIcon,rightIcon,asChild,shortcut,hideShortcutKey,shortcutGuard
Keyboard shortcuts
shortcut binds a hotkey that ref-clicks the button and renders a keycap badge
(ShortcutKey); it is inert while disabled/loading and while a dialog the
button isn't inside is open. shortcutGuard AND-composes an extra guard.
Every combo is a named constant — shared ones in
packages/react/src/shortcuts.ts (SHORTCUTS), app ones in
apps/erp/app/shortcuts.ts / apps/mes/app/shortcuts.ts. Never write a combo
string literal at a call site. Many-bindings-to-many-actions use
useShortcutKeyMap(entries) (dev-warns on duplicate combos); two-key sequences
(g then a letter) use useShortcutSequence. The ? overlay
(ShortcutHelpOverlay) lists shortcuts; each app's ShortcutHelp.tsx declares
its entries from the central files. Submit (@carbon/form) defaults to the
SHORTCUTS.save binding (⌘/Ctrl+Enter) with a focus-aware guard; pass
shortcut={false} to opt out of the binding or hideShortcutKey to keep it
silent. The legacy useKeyboardShortcuts / usePrettifyShortcut hooks are
deleted.
All matching goes through react-hotkeys-hook (useShortcutKeys and
useShortcutKeyMap both delegate to useHotkeys) — never hand-roll a
document keydown listener; the library already handles typing-in-input
suppression and physical-key (event.code) matching. useShortcutSequence
is the one hand-rolled exception (the library has no sequence support).
Menu item keys. DropdownMenuItem / ContextMenuItem / MenuItem take
shortcut={MENU_ITEM_SHORTCUTS.<verb>} (packages/react/src/shortcuts.ts:
Edit E, Rename R, Pin P, Duplicate/Copy C, Download D, View/Open O,
Delete Backspace — the Backspace or Delete key).
The item shows a keycap and runs when its key is pressed — only while its menu
is open, because the handler (utils/menuShortcut.ts) sits on the menu
content's onKeyDown, not on the document. Unowned letters fall through to
Radix typeahead; keys typed into a field inside the menu are ignored. Give a
Delete item the key only when choosing it opens a confirmation first; an item
that deletes immediately gets none. An item with a keycap never wraps
(whitespace-nowrap), so give its menu a min-w-*, not a fixed w-*. Never
give two items in one menu the same key.
Interaction design rules (apply per screen, don't bind mechanically):
- Enter is the shortcut when there is one obvious action: a single input (native form submit already handles it), a choice screen, "select and continue". ⌘/Ctrl+Enter is for real forms — multiple fields, selects, editors — where Enter has other meanings and submission should be deliberate.
- Badge visibility is a design decision. Don't advertise a shortcut on a
trivial screen (login email, OTP screens, single-input dialogs): the binding
can stay, the badge goes (
hideShortcutKey). Multi-field forms keep the ⌘↵ badge. - Choice screens are radio groups: one tab stop, arrow keys move AND
select, Enter confirms and continues (Radix radios don't activate on Enter,
which leaves it free for the continue button's
shortcut). UseChoiceCardGroup(cards,autoFocusprop) orRadioGroupButton(button-styled options); give the screen initial focus on the selected option.
<Button variant="primary" leftIcon={<LuPlus />}>Save</Button>
<Button variant="secondary" onClick={onClose}>Cancel</Button>
For icon-only buttons use IconButton (packages/react/src/IconButton.tsx) — it
requires an aria-label and takes an icon prop, sizing the icon to match the
button size.
<IconButton aria-label="Collapse" variant="ghost" icon={<LuChevronUp />} />
Form Buttons
Submit (from ~/components/Form) is the submit action; pair it with a plain
Button for cancel.
<HStack>
<Submit isDisabled={isDisabled}>Save</Submit>
<Button variant="solid" onClick={onClose}>Cancel</Button>
</HStack>
Layout Patterns
Stacks
VStack and HStack (packages/react/src/{VStack,HStack}.tsx) take a numeric
spacing prop (maps to Tailwind space-y-* / space-x-*), default 2.
VStack supports spacing 0,1,2,3,4,8; HStack 0,1,2,3,4,6,8. VStack is
w-full items-start; HStack is items-center.
<VStack spacing={4}>
<Input name="name" label="Name" />
<Input name="description" label="Description" />
</VStack>
Grid Layout
<div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4">
<Input name="field1" />
<Input name="field2" />
<Input name="field3" />
</div>
Card
Card and its subcomponents (CardHeader, CardTitle, CardDescription,
CardContent, CardFooter, plus CardAttributes/CardAttribute* for label/value
grids) come from @carbon/react. Card supports isCollapsible. It already
applies rounded-2xl + layered shadow on the outer shell and rounded-2xl on
CardContent, so don't re-add borders/radius — compose with the subcomponents.
Popovers inside Drawers / Dialogs
Combobox, CreatableCombobox, CreatableMultiSelect, MultiSelect, and
ChoiceSelect (all packages/react/src/) render their options in a
PopoverContent portaled to document.body. Drawer (Drawer.tsx) is a Radix
Dialog using react-remove-scroll to lock background scroll. Because the popover
is portaled outside the dialog subtree, the scroll-lock's document-level wheel
listener swallows wheel/touch events over the dropdown, so its internal
overflow-auto list cannot scroll (symptom: only the first ~6 options show and it
won't scroll).
Required pattern — stop propagation on the PopoverContent so events never reach
the scroll-lock listener, and give the scroll container a visible scrollbar:
<PopoverContent
onWheel={(e) => e.stopPropagation()}
onTouchMove={(e) => e.stopPropagation()}
>
<div className="overflow-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent">
...
</div>
</PopoverContent>
Any new popover-based dropdown with an internal scroll area used inside a drawer/dialog must follow this.
Polish Principles
Apply these when building or reviewing UI. The verified examples below are live in the codebase.
1. Concentric Border Radius
Outer radius = inner radius + padding. (E.g. Card shell is rounded-2xl.)
// Bad: same radius on parent and child
<div className="rounded-xl p-2"><button className="rounded-xl">...</button></div>
// Good: outer is larger
<div className="rounded-2xl p-2"><button className="rounded-lg">...</button></div>
2. Shadows Over Borders
Prefer layered box-shadow for depth over solid borders. Button and Card use
shadow-button-base / inset highlight shadows rather than hard borders.
3. Tabular Numbers
For dynamic numbers, prevent layout shift with tabular-nums (used in
packages/react/src/{Count,Progress,BarProgress}.tsx).
<span className="tabular-nums">{count}</span>
4. Scale on Press
Tactile button feedback. Button itself applies active:scale-[0.98] active:duration-75; reuse Button/IconButton rather than reimplementing. When
hand-rolling a pressable element, match 0.98 (a deeper press reads as the layout moving; never below 0.95).
<button className="active:scale-[0.98] transition-transform">
5. Minimum Hit Area
Interactive elements need a comfortable hit area (~40×40px). Extend with a pseudo-element if the visual is smaller.
6. Animations
- Use CSS transitions for interactive states (interruptible); keyframes for staged sequences.
- Prefer scoping transitions to specific properties (e.g.
transition-transform, ortransition-[background-color,color,transform]asButtondoes) overtransition-all. - Stagger enter animations (~100ms); keep exit animations subtle.
// Preferred
className="transition-transform"
// Avoid (broad, can animate unintended properties)
className="transition-all"
7. AnimatePresence
Motion uses motion (imported as from "motion/react"; framer-motion is no longer a dependency), e.g.
apps/erp/app/components/DirectionAwareTabs.tsx. Skip animation on page load with
initial={false}:
<AnimatePresence initial={false}>
...
</AnimatePresence>
8. Font Smoothing
Use the Tailwind antialiased class for smoothing (applied on apps/erp/app/root.tsx
body and a few top-level pages).
9. Text Wrapping
Tailwind v4 utilities (NOT text-wrap-*):
// Headings — used in Heading.tsx, Modal.tsx, Drawer.tsx
<h1 className="text-balance">...</h1>
// Body text — used in Card.tsx (CardTitle)
<p className="text-pretty">...</p>
Common Mistakes
| Mistake | Fix |
|---|---|
Hand-rolling UI instead of grepping @carbon/react first |
Use the existing component + its variants |
Ad-hoc bg-* / text-* instead of a variant |
Pick the built-in variant (e.g. Button variant="secondary") |
| Same border radius on parent/child | outerRadius = innerRadius + padding |
| Numbers cause layout shift | tabular-nums |
Broad transition-all |
Scope to specific properties where practical |
| Animation on page load | initial={false} on AnimatePresence |
text-wrap-balance / text-wrap-pretty |
text-balance / text-pretty (Tailwind v4) |
| Tiny hit areas | Extend to ~40×40px |
| Hard borders | Use layered shadows |
| Dropdown inside a Drawer won't scroll (shows ~6 items) | stopPropagation on PopoverContent onWheel/onTouchMove |
Review Checklist
- Used an existing
@carbon/react/~/components/Formcomponent over custom markup - Used a
variantinstead of ad-hocbg-*/text-*classes - Concentric border radius on nested elements
- Icons optically centered (use
IconButtonfor icon-only) - Shadows instead of borders where appropriate
- Dynamic numbers use
tabular-nums - Pressable elements scale on press (reuse
Buttonwhere possible) - Transitions scoped to specific properties, not blanket
transition-all - Enter animations staggered; exit animations subtle (
initial={false}on load) - Interactive elements have a ~40×40px hit area