@dynamic-mockups/design-system
v0.2.5
Published
A professional, scalable design system built with React 18, TypeScript, Radix UI, and Storybook
Downloads
420
Readme
🎨 Dynamic Mockups Design System
A production-ready, scalable design system built with modern best practices.
📦 Tech Stack
- React 18.3.1 - Latest React with hooks
- TypeScript 5.9.3 - Full type safety
- Radix UI Themes 3.2.1 - Accessible primitives
- SCSS - Enhanced styling with nesting and variables
- Vite 6.0.7 - Lightning-fast build tool
- Storybook 10.1.4 - Component documentation
- Vitest - Testing framework
📁 Final Project Structure
design-system/
├── src/
│ ├── tokens/ # Design tokens (Type-safe)
│ │ ├── colors.ts # Brand & semantic colors (50-950 scales)
│ │ ├── spacing.ts # 8px grid system (0-96)
│ │ ├── typography.ts # Font families, sizes, weights
│ │ ├── radii.ts # Border radius values
│ │ ├── shadows.ts # Elevation shadows
│ │ └── index.ts # Token exports
│ │
│ ├── theme/ # Theme system
│ │ ├── theme.ts # Theme configuration
│ │ ├── ThemeProvider.tsx # React context provider
│ │ └── index.ts
│ │
│ ├── components/ # Component library
│ │ ├── Button/
│ │ │ ├── Button.tsx # Component logic
│ │ │ ├── Button.scss # SCSS styles
│ │ │ ├── Button.stories.tsx # Storybook stories
│ │ │ └── index.ts
│ │ │
│ │ ├── Input/ # Text input with labels, icons, errors
│ │ ├── Switch/ # Toggle switch
│ │ ├── Checkbox/ # Checkbox with labels
│ │ ├── Select/ # Dropdown select
│ │ └── index.ts # Component exports
│ │
│ └── index.ts # Main entry point
│
├── dist/ # Build output
│ ├── index.js # CommonJS bundle
│ ├── index.mjs # ESM bundle
│ ├── index.d.ts # TypeScript declarations
│ ├── design-system.css # Compiled CSS from SCSS
│ └── [component folders]/ # Individual declarations
│
├── stories/ # Storybook files
├── .storybook/ # Storybook config
├── tsconfig.json # TypeScript config
├── vite.config.ts # Vite build config
├── package.json # Package manifest
└── README.md # Usage documentation🎨 Components Built
1. Button - Full-featured button component
- Variants: solid, soft, outline, ghost, surface
- Colors: primary, secondary, accent, success, error, warning, info + Radix colors
- Sizes: 1-4
- Features: Loading states, left/right icons, full width, disabled states
- SCSS File:
Button.scsswith CSS variables for customization
2. Input - Professional text input
- Variants: surface, classic, soft
- Sizes: 1-3
- Colors: Custom focus colors (primary, secondary, accent, etc.)
- Features: Labels, helper text, error states, left/right icons, full width
- SCSS File:
Input.scsswith focus states and variants
3. Switch - Toggle switch
- Sizes: 1-3
- Colors: Custom colors beyond Radix defaults
- Features: Labels, helper text, left/right label positions
- SCSS File:
Switch.scss
4. Checkbox - Checkbox input
- Sizes: 1-3
- Colors: Custom colors
- Features: Labels, helper text, error states, indeterminate state
- SCSS File:
Checkbox.scss
5. Select - Dropdown select
- Variants: surface, classic, soft, ghost
- Sizes: 1-3
- Colors: Custom focus colors
- Features: Labels, helper text, error states, disabled options, full width
- SCSS File:
Select.scss
🎯 Design Tokens System
Colors
import { colors } from 'design-system';
// Brand colors with 50-950 scales
colors.brand.primary[500] // #0ea5e9
colors.brand.secondary[600] // #475569
colors.brand.accent[500] // #d946ef
// Semantic colors
colors.semantic.success.main // #059669
colors.semantic.error.main // #dc2626
colors.semantic.warning.main // #d97706
colors.semantic.info.main // #2563ebSpacing (8px grid)
import { spacing } from 'design-system';
spacing[4] // 1rem (16px)
spacing[8] // 2rem (32px)
spacing[16] // 4rem (64px)Typography
import { typography } from 'design-system';
typography.fontFamily.sans
typography.fontSize.base // 1rem (16px)
typography.fontWeight.bold // 700🚀 How to Use in Your Primary Project
Installation
# Install from npm
npm install @dynamic-mockups/design-system @radix-ui/themes react react-dom
# Or with yarn
yarn add @dynamic-mockups/design-system @radix-ui/themes react react-domSetup
1. Import CSS Files (REQUIRED)
// In your main App.tsx, main.tsx, or index.tsx
import '@radix-ui/themes/styles.css';
import '@dynamic-mockups/design-system/styles.css'; // ← IMPORTANT: Import design system CSS2. Wrap with ThemeProvider
import { ThemeProvider } from '@dynamic-mockups/design-system';
function App() {
return (
<ThemeProvider
appearance="light"
accentColor="blue"
radius="medium"
>
<YourApp />
</ThemeProvider>
);
}3. Use Components
import { Button, Input, Select, Switch, Checkbox } from '@dynamic-mockups/design-system';
function MyPage() {
return (
<form>
<Input
label="Email"
type="email"
placeholder="[email protected]"
required
/>
<Select
label="Country"
options={[
{ value: 'us', label: 'United States' },
{ value: 'uk', label: 'United Kingdom' },
]}
/>
<Switch label="Remember me" />
<Checkbox label="I agree to the terms" />
<Button color="primary" type="submit">
Submit
</Button>
</form>
);
}🎨 SCSS Customization
Method 1: Override CSS Variables
Create a custom-theme.scss in your project:
:root {
// Brand colors
--color-primary: #0ea5e9;
--color-primary-hover: #0284c7;
--color-primary-soft: #e0f2fe;
--color-secondary: #64748b;
--color-accent: #d946ef;
// Semantic colors
--color-success: #10b981;
--color-error: #ef4444;
--color-warning: #f59e0b;
--color-info: #3b82f6;
}Method 2: Use Design Tokens
@use 'design-system' as ds;
.my-component {
// Use tokens directly in your SCSS
color: var(--color-primary);
padding: var(--spacing-4);
border-radius: var(--radii-lg);
&:hover {
background-color: var(--color-primary-soft);
}
}Method 3: Import Component SCSS
If you want to customize component styles:
// Import and override
@use 'design-system/components/Button/Button.scss' with (
$button-primary-bg: #your-color
);📚 Available Scripts
# Development
yarn storybook # Run Storybook on port 6006
yarn dev # Run Vite dev server
# Building
yarn build # Build the library (TS + Vite)
yarn build-storybook # Build Storybook for deployment
# Quality
yarn typecheck # Run TypeScript type checking📦 Build Output
Package Exports
{
"main": "dist/index.js", // CommonJS
"module": "dist/index.mjs", // ESM
"types": "dist/index.d.ts", // TypeScript
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./styles.css": "./dist/design-system.css"
}
}Bundle Sizes
- ESM: ~186 KB (50 KB gzipped)
- CJS: ~127 KB (41 KB gzipped)
- CSS: ~11 KB (1.8 KB gzipped)
🎯 Key Features
✅ Type-Safe - Full TypeScript support with exported types ✅ Tree-Shakeable - Import only what you need ✅ Customizable - SCSS variables and CSS custom properties ✅ Accessible - Built on Radix UI primitives (WCAG compliant) ✅ Token-Based - Consistent design with design tokens ✅ Documented - Comprehensive Storybook documentation ✅ Production Ready - Tested, built, and ready to publish
📖 Next Steps
Run Storybook to see all components:
yarn storybookCustomize colors in
src/tokens/colors.tsAdd more components following the same pattern:
- Create component folder
- Add TypeScript component
- Add SCSS styles
- Create Storybook stories
- Export from
src/components/index.ts
Test in your primary project using
npm link
The system is scalable, maintainable, and follows industry best practices used by companies like Shopify, Atlassian, and GitHub.
Developed by https://dynamicmockups.com
