Installation
Get started with Matrix UI by installing the necessary packages and setting up your project.
Prerequisites
- Node.js 18.17 or later
- Next.js 15.0 or later
- React 19.0 or later
- TypeScript 5.0 or later (recommended)
Installation Methods
Method 1: Using the CLI (Recommended)
The easiest way to get started is using the Matrix UI CLI:
npx @matrix-ui/cli initThis will:
- Install required dependencies
- Set up your tailwind.config.ts
- Create a components folder structure
- Configure your TypeScript paths
Method 2: Manual Installation
1. Install core packages
npm install @matrix-ui/components @matrix-ui/themes @matrix-ui/utils2. Install peer dependencies
npm install @radix-ui/react-* class-variance-authority clsx tailwind-merge3. Configure Tailwind CSS
Update your tailwind.config.ts:
import type { Config } from 'tailwindcss'
const config: Config = {
darkMode: ['class'],
content: [
'./src/**/*.{js,ts,jsx,tsx,mdx}',
'./node_modules/@matrix-ui/components/**/*.{js,ts,jsx,tsx}',
],
theme: {
extend: {
colors: {
background: 'hsl(var(--background))',
foreground: 'hsl(var(--foreground))',
primary: {
DEFAULT: 'hsl(var(--primary))',
foreground: 'hsl(var(--primary-foreground))',
},
secondary: {
DEFAULT: 'hsl(var(--secondary))',
foreground: 'hsl(var(--secondary-foreground))',
},
// ... more color definitions
},
borderRadius: {
lg: 'var(--radius)',
md: 'calc(var(--radius) - 2px)',
sm: 'calc(var(--radius) - 4px)',
},
},
},
plugins: [],
}
export default config4. Add CSS variables
Add to your global CSS file:
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;
--radius: 0.5rem;
}
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
}
}Adding Components
Once installed, you can add components using the CLI:
# Add specific components
npx @matrix-ui/cli add button card
# Add all components
npx @matrix-ui/cli add --allTypeScript Configuration
For the best development experience, update your tsconfig.json:
{
"compilerOptions": {
"paths": {
"@/components/*": ["./src/components/*"],
"@/lib/*": ["./src/lib/*"],
"@matrix-ui/*": ["./node_modules/@matrix-ui/*"]
}
}
}Next Steps
After installation, check out the Quick Start guide to build your first component.