- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Dropdown Menu
- Empty
- Field
- Hover Card
- Icon
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Label
- Menubar
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner (Toast)
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
Installation
Install behavior. Copy styles. Start building.
spartan/ui uses a two-layer architecture: you install @spartan-ng/brain from npm for accessible primitives, then copy helm styles into your codebase for customization.
Prerequisites
spartan/ui requires Tailwind CSS. If you haven't set it up yet, follow the official Angular installation guide before continuing.
Quick Start
Install the CLI plugin:
pnpm add -D @spartan-ng/cli
Run the spartan/cli init command:
ng g @spartan-ng/cli:init
npx nx g @spartan-ng/cli:init
Use the CLI to add components to your project. This installs the brain dependency (npm) and copies helm code (styles) into your codebase:
ng g @spartan-ng/cli:ui
npx nx g @spartan-ng/cli:ui
The CLI will prompt you to select which components to add. Each component includes:
- Brain primitive (installed to node_modules)
- Helm styles (copied to your project)
- All necessary dependencies
Manual Setup
1. Install Dependencies
Install the brain (accessible primitives):
pnpm add @spartan-ng/brain
Install Angular CDK (required for overlays and accessibility):
pnpm add @angular/cdk
2. Configure Tailwind CSS
spartan/ui requires Tailwind CSS v4.
2.1 Configure CSS Layers
Add these layers to your styles.css to ensure ng-icons styles load correctly:
@layer theme, base, components, utilities;
@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/preflight.css" layer(base);
@import "tailwindcss/utilities.css";2.2 Import spartan/ui preset
Add the spartan preset to your CSS file:
@import "@spartan-ng/brain/hlm-tailwind-preset.css";spartan/ui preset
Our preset already includes tw-animate-css and @angular/cdk/overlay-prebuilt.css
2.3 Add Theme Variables
You have two options for adding spartan's CSS variables:
Option A: Use the Theme Generator (Recommended)
Generate theme configuration automatically with our CLI:
ng g @spartan-ng/cli:ui-theme
npx nx g @spartan-ng/cli:ui-theme
Option B: Manual Setup
Copy these CSS variables to your styles.css :
:root {
color-scheme: light;
--font-sans: 'Geist Sans', sans-serif;
--radius: 0.625rem;
--background: oklch(1 0 0);
--foreground: oklch(0.145 0 0);
--card: oklch(1 0 0);
--card-foreground: oklch(0.145 0 0);
--popover: oklch(1 0 0);
--popover-foreground: oklch(0.145 0 0);
--primary: oklch(0.205 0 0);
--primary-foreground: oklch(0.985 0 0);
--secondary: oklch(0.97 0 0);
--secondary-foreground: oklch(0.205 0 0);
--muted: oklch(0.97 0 0);
--muted-foreground: oklch(0.556 0 0);
--accent: oklch(0.97 0 0);
--accent-foreground: oklch(0.205 0 0);
--destructive: oklch(0.577 0.245 27.325);
--border: oklch(0.922 0 0);
--input: oklch(0.922 0 0);
--ring: oklch(0.708 0 0);
--sidebar: oklch(0.985 0 0);
--sidebar-foreground: oklch(0.145 0 0);
--sidebar-primary: oklch(0.205 0 0);
--sidebar-primary-foreground: oklch(0.985 0 0);
--sidebar-accent: oklch(0.97 0 0);
--sidebar-accent-foreground: oklch(0.205 0 0);
--sidebar-border: oklch(0.922 0 0);
--sidebar-ring: oklch(0.708 0 0);
}
.dark {
color-scheme: dark;
--background: oklch(0.145 0 0);
--foreground: oklch(0.985 0 0);
--card: oklch(0.205 0 0);
--card-foreground: oklch(0.985 0 0);
--popover: oklch(0.205 0 0);
--popover-foreground: oklch(0.985 0 0);
--primary: oklch(0.922 0 0);
--primary-foreground: oklch(0.205 0 0);
--secondary: oklch(0.269 0 0);
--secondary-foreground: oklch(0.985 0 0);
--muted: oklch(0.269 0 0);
--muted-foreground: oklch(0.708 0 0);
--accent: oklch(0.269 0 0);
--accent-foreground: oklch(0.985 0 0);
--destructive: oklch(0.704 0.191 22.216);
--border: oklch(1 0 0 / 10%);
--input: oklch(1 0 0 / 15%);
--ring: oklch(0.556 0 0);
--sidebar: oklch(0.205 0 0);
--sidebar-foreground: oklch(0.985 0 0);
--sidebar-primary: oklch(0.985 0 0);
--sidebar-primary-foreground: oklch(0.205 0 0);
--sidebar-accent: oklch(0.269 0 0);
--sidebar-accent-foreground: oklch(0.985 0 0);
--sidebar-border: oklch(1 0 0 / 10%);
--sidebar-ring: oklch(0.556 0 0);
}Learn how to customize these variables in the theming documentation .
3. Add Components
Use the CLI to add components to your project. This installs the brain dependency (npm) and copies helm code (styles) into your codebase:
ng g @spartan-ng/cli:ui
npx nx g @spartan-ng/cli:ui
The CLI will prompt you to select which components to add. Each component includes:
- Brain primitive (installed to node_modules)
- Helm styles (copied to your project)
- All necessary dependencies
Editor Setup (Optional)
IntelliSense
Enable Tailwind autocompletion in hlm , cva and classes functions:
- Install the Tailwind CSS IntelliSense extension
- Add this to your
settings.json:
{
"tailwindCSS.classFunctions": ["hlm", "cva", "classes"]
}Class Sorting
Automatically sort Tailwind classes with Prettier:
- Install prettier-plugin-tailwindcss
- Add this to your
.prettierrc:
{
"tailwindFunctions": ["hlm", "cva", "classes"]
}On This Page