Documentation
Quick Start
Designers is a toolkit for managing and using design tokens in React projects. It helps you keep your UI consistent, type-safe, and easy to theme. This quick start will guide you through setup, usage, and customization.
Prerequisites
- Node.js 16 or newer
- A React project (Next.js, Vite, CRA, etc.)
Overview
- Install the
designers
package - Initialize your project for instant configuration
- Use design tokens in your codebase
- Customize tokens and integrate with Tailwind CSS (optional)
1. Install Designers
Add the package to your project using your preferred package manager. This gives you access to all core tokens and utilities:
npm install designers
# or
yarn add designers
# or
pnpm add designers
2. Initialize Your Project
Run the CLI to generate a designers.config.json
and example files. This step is optional but recommended for best experience:
npx designers init
designers.config.json
file and example usage in your project root. You can edit this file to customize your tokens.3. Use Design Tokens in Your Components
Import ds
and use tokens for consistent, type-safe styling. Here’s a real-world example:
import { ds } from 'designers';
export function ExampleButton() {
return (
<button
style={{
background: ds.colors.blue[600],
color: ds.colors.white,
padding: ds.spacing[3],
borderRadius: ds.radius.md,
boxShadow: ds.shadows.sm,
border: 'none',
fontWeight: 600,
cursor: 'pointer',
}}
>
Click Me
</button>
);
}
4. Customizing Tokens
Edit designers.config.json
to add or override colors, spacing, radii, and more. After editing, restart your dev server to apply changes.
// designers.config.json
{
"colors": {
"brand": {
"primary": "#1e40af",
"secondary": "#f59e42"
}
},
"spacing": {
"xs": "0.25rem",
"sm": "0.5rem"
}
}
ds.colors.brand.primary
and ds.spacing.xs
in your components.5. Using with Tailwind CSS
Designers can generate Tailwind-compatible tokens. See the theming docs for setup instructions. Example integration:
// tailwind.config.js
const { designersTailwind } = require('designers/tailwind');
module.exports = {
theme: {
extend: designersTailwind(),
},
};
Troubleshooting & Resources
- If you see TypeScript errors, ensure your
designers
package and config are up to date. - For more examples, see the Examples page.
- For Tailwind CSS integration, see theming docs.
- Need help? Open an issue on GitHub.