Use the design system
Most existing projects already decided what a button looks like, what the spacing
scale is, and which colors are allowed. When you drop in a freshly hand-rolled
component with its own hardcoded colors and padding, it looks slightly off, it
duplicates work, and it drifts from the rest of the app. The system is there so
the UI stays consistent. Use it before you build anything new.
The rule: in an existing codebase, find the UI system first and build with it.
Hand-rolling is the last resort, not the default.
Look before you build
Before writing a new component, scan the project for what already exists:
- A components folder:
components/, src/ui/, components/ui/, a shared
package. Is there already a Button, Modal, Input, Card?
- A component library in
package.json: shadcn/ui, MUI, Chakra, Mantine, Radix,
Ant, Headless UI, DaisyUI, Bootstrap. Use its components and its API.
- Design tokens and theme: CSS custom properties (
--color-primary, spacing
vars), a theme.ts, a Tailwind config with custom colors and scales.
- Utility conventions: Tailwind classes, CSS modules, styled-components. Match how
the rest of the code styles things.
- Existing patterns: open a couple of nearby components and copy their structure,
prop shapes, and naming.
Build with it, not around it
- Reuse the existing component instead of making a new one that does the same job.
- Pull colors, spacing, radius, and typography from the tokens or theme. Do not
hardcode a hex value when there is a token for it.
- Follow the library's API and the project's conventions, so your code reads like
the code already there (see also: write code that matches its surroundings).
- Compose from primitives the system gives you rather than reaching for a new
dependency.
When nothing fits
Sometimes the system genuinely lacks what you need. Then build it, but build it to
belong:
- Use the project's tokens and primitives, not a fresh set of hardcoded values.
- Match the file location, naming, and prop conventions of the existing
components.
- If it is reusable, add it to the system so the next person finds it, rather than
burying a one-off in a page.
- Do not pull in a whole new UI library to get one component when the project
already standardized on another. If you think a new dependency is warranted, ask
(
dont-be-afraid-to-ask).
Before you deliver
Before you ship new UI, ask: does the project already have this component, token,
or pattern? If yes, you should be using it. Check that your colors and spacing
come from the system, your component matches the library and conventions in use,
and you have not quietly duplicated something that already exists.
For greenfield projects with no system yet, see no-ai-design-cliches for making
intentional choices, and prefer-icons for iconography.
1---2name: use-the-design-system3description: If the project already has a UI system, use it before building anything new. Use this WHENEVER you add or change UI in an existing codebase: a button, modal, form, card, page, or any component. Look first for the project's component library, design tokens, theme, and utility setup (a components or ui folder, shadcn/ui, MUI, Chakra, Mantine, Radix, a Tailwind config, CSS variables), and build with those. Reinventing a button from scratch when the project has one creates inconsistency and duplicate work. Only hand-roll a component when nothing in the system fits, and then match the system's conventions so it belongs.4---56# Use the design system78Most existing projects already decided what a button looks like, what the spacing9scale is, and which colors are allowed. When you drop in a freshly hand-rolled10component with its own hardcoded colors and padding, it looks slightly off, it11duplicates work, and it drifts from the rest of the app. The system is there so12the UI stays consistent. Use it before you build anything new.1314The rule: in an existing codebase, find the UI system first and build with it.15Hand-rolling is the last resort, not the default.1617## Look before you build1819Before writing a new component, scan the project for what already exists:2021- A components folder: `components/`, `src/ui/`, `components/ui/`, a shared22 package. Is there already a `Button`, `Modal`, `Input`, `Card`?23- A component library in `package.json`: shadcn/ui, MUI, Chakra, Mantine, Radix,24 Ant, Headless UI, DaisyUI, Bootstrap. Use its components and its API.25- Design tokens and theme: CSS custom properties (`--color-primary`, spacing26 vars), a `theme.ts`, a Tailwind config with custom colors and scales.27- Utility conventions: Tailwind classes, CSS modules, styled-components. Match how28 the rest of the code styles things.29- Existing patterns: open a couple of nearby components and copy their structure,30 prop shapes, and naming.3132## Build with it, not around it3334- Reuse the existing component instead of making a new one that does the same job.35- Pull colors, spacing, radius, and typography from the tokens or theme. Do not36 hardcode a hex value when there is a token for it.37- Follow the library's API and the project's conventions, so your code reads like38 the code already there (see also: write code that matches its surroundings).39- Compose from primitives the system gives you rather than reaching for a new40 dependency.4142## When nothing fits4344Sometimes the system genuinely lacks what you need. Then build it, but build it to45belong:4647- Use the project's tokens and primitives, not a fresh set of hardcoded values.48- Match the file location, naming, and prop conventions of the existing49 components.50- If it is reusable, add it to the system so the next person finds it, rather than51 burying a one-off in a page.52- Do not pull in a whole new UI library to get one component when the project53 already standardized on another. If you think a new dependency is warranted, ask54 (`dont-be-afraid-to-ask`).5556## Before you deliver5758Before you ship new UI, ask: does the project already have this component, token,59or pattern? If yes, you should be using it. Check that your colors and spacing60come from the system, your component matches the library and conventions in use,61and you have not quietly duplicated something that already exists.6263For greenfield projects with no system yet, see `no-ai-design-cliches` for making64intentional choices, and `prefer-icons` for iconography.