Building Your Own Design System
Tokenami makes it easy to create portable design systems that can be shared across projects or published for others to use.Why Build a Design System?
Creating a design system package offers several benefits:- Consistency across multiple projects
- Shared tokens for colors, spacing, typography
- Reusable components with type safety
- Version control for design decisions
- Portable - works with or without Tokenami
Package Structure
A typical design system package contains:Creating the Configuration
Start by creating a Tokenami config that defines your design system:Adding Global Styles
Include global styles in your configuration:Multiple Themes
Support light and dark modes using themodes configuration:
Property Aliases
Create convenient shorthand properties:Custom Selectors
Define reusable selector patterns:Package Configuration
Set up yourpackage.json:
Consuming the Design System
With Tokenami
If the consumer is using Tokenami, they should include your design system in their config:Without Tokenami
Projects not using Tokenami can still use your design system by including the CSS file:Publishing
To npm
-
Build your package:
-
Publish to npm:
To a Private Registry
For organization-internal design systems:Example: Extending the Official System
You can extend the official design system:Documentation
Create a comprehensive README documenting:- Installation instructions
- Available tokens and their values
- Usage examples
- Theme switching (if applicable)
- Property aliases
- Custom selectors
- Animation keyframes
Best Practices
Use Semantic Naming
Use Semantic Naming
Name tokens based on their purpose (
primary, danger) rather than their appearance (blue, red). This makes themes easier to maintain.Version Carefully
Version Carefully
Follow semantic versioning. Breaking changes to token names or values should be major version bumps.
Document Breaking Changes
Document Breaking Changes
Maintain a CHANGELOG.md documenting all breaking changes and migration paths.
Test Across Projects
Test Across Projects
Test your design system in multiple consuming projects before publishing.
Provide Escape Hatches
Provide Escape Hatches
Allow consumers to override your tokens when needed using the triple-dash syntax.
Next Steps
Global Styles
Configure global CSS styles
Breakpoints
Set up responsive breakpoints
Animation
Add keyframes and animations