Installation
Get started with Mordecai Design System in your React application.
Install the package
Install @corew500/ui and its peer dependencies.
Or with your preferred package manager:
Import the styles
Import the CSS file in your app's entry point. This includes all design tokens, Tailwind utilities, and component styles.
// app/layout.tsx or _app.tsx import '@corew500/ui/styles.css'
- Design tokens (colors, spacing, typography, etc.)
- Tailwind CSS v4 base, components, and utilities
- Custom component utilities (button sizes, input heights, etc.)
- Light/dark theme support
Use components
Import and use components directly from the package.
import { Button, Card, CardContent, CardHeader } from '@corew500/ui'
export function MyComponent() {
return (
<Card>
<CardHeader>Welcome</CardHeader>
<CardContent>
<Button variant="primary">Get Started</Button>
</CardContent>
</Card>
)
}Framework Setup
For Next.js 13+ with the App Router, add the styles import to your root layout:
// app/layout.tsx
import '@corew500/ui/styles.css'
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}For Next.js with the Pages Router, add the styles import to _app.tsx:
// pages/_app.tsx
import '@corew500/ui/styles.css'
import type { AppProps } from 'next/app'
export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}Add the styles import to your main entry file:
// main.tsx or index.tsx
import '@corew500/ui/styles.css'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>
)Dark Mode
The design system supports dark mode out of the box. Add the dark class to your HTML element or use a theme provider like next-themes.
// With next-themes
import { ThemeProvider } from 'next-themes'
export default function RootLayout({ children }) {
return (
<html lang="en" suppressHydrationWarning>
<body>
<ThemeProvider attribute="class" defaultTheme="system">
{children}
</ThemeProvider>
</body>
</html>
)
}TypeScript Support
The package includes full TypeScript definitions. All components, props, and utilities are fully typed.
import type { ButtonProps } from '@corew500/ui'
// Component props are fully typed
const props: ButtonProps = {
variant: 'primary',
size: 'lg',
loading: false,
}CMS Integration (Optional)
For Payload CMS integration, install the CMS adapter package:
See the CMS Integration guide for detailed setup instructions.
Direct Token Access (Optional)
If you need programmatic access to design token values (e.g., for runtime calculations), import from the tokens package:
import { colors, spacing, breakpoints } from '@corew500/tokens'
// Access token values in JavaScript
console.log(spacing[4]) // "1rem"
console.log(breakpoints.md) // 768Note: The tokens package is automatically installed with @corew500/ui.
Troubleshooting
Make sure you've imported @corew500/ui/styles.css in your app's entry point. The import must be at the top level, not inside a component.
Ensure you're using TypeScript 5.0 or later. The package uses modern TypeScript features for better type inference.
See the Tailwind Setup guide for configuring Tailwind CSS v4 alongside the design system.