# Installation

- **[Get started](/get-started/)**

Add Klarhimmel UI to a React 19 project that uses Tailwind CSS v4. Takes about two minutes.

## Steps

- **New Vite app? Add Tailwind**: Skip this if your project already runs Tailwind CSS v4. A new Vite app does not yet: install it and add its plugin.

  ```
  npm i tailwindcss @tailwindcss/vite
  
  // vite.config.ts
  import tailwindcss from '@tailwindcss/vite';
  plugins: [react(), tailwindcss()]
  ```
- **Map the @/ alias**: Every snippet imports from @/components/klarhimmel/. Vite does not map @/ yet: add it to both tsconfig files and to Vite (npm i -D @types/node). Next.js and most starters have it.

  ```
  // tsconfig.json and tsconfig.app.json, inside "compilerOptions"
  "paths": { "@/*": ["./src/*"] }
  
  // vite.config.ts
  import path from 'node:path';
  resolve: { alias: { '@': path.resolve(import.meta.dirname, './src') } }
  ```
- **Create components.json**: Tells the CLI where files go and where Klarhimmel items live. No shadcn init needed, and its style does not matter: files are copied as written. Already have one? Add only the registries entry.

  ```
  // components.json, in the project root
  {
    "style": "new-york",
    "tailwind": { "css": "src/index.css", "baseColor": "neutral", "cssVariables": true },
    "aliases": { "components": "@/components", "utils": "@/lib/utils" },
    "registries": { "@klarhimmel": "https://ui.klarhimmel.com/r/{name}.json" }
  }
  ```
- **Add a block**: Files land in components/klarhimmel/, with everything the block needs. They are yours now.

  ```
  npx shadcn add @klarhimmel/hero-split
  ```
- **Import the tokens**: In your main CSS file, after Tailwind. The tokens are scoped to .kh-root and never reset your own theme.

  ```
  @import 'tailwindcss';
  @import './components/klarhimmel/theme/theme.css';
  ```
- **Render it**: Wrap the page in Theme once. Each block sits on a BlockSurface and takes one props object.

  ```
  import { Theme } from '@/components/klarhimmel/theme/style';
  import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
  import Hero, { spec } from '@/components/klarhimmel/blocks/hero-split';
  
  <Theme theme="brand">
    <BlockSurface><Hero props={spec.defaults} /></BlockSurface>
  </Theme>
  ```
- **Check a page before you ship**: A real page keeps your text and never shows sample copy. Each installed block ships its spec: check your props against its schema in your build, so an over-limit or missing text fails there, not on the page.

  ```
  import { spec } from '@/components/klarhimmel/blocks/hero-split/spec';
  
  // props: what your page passes to <HeroSplit props={...} />
  const result = spec.schema.safeParse(props);
  if (!result.success) throw new Error(result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\n'));
  ```

## Host your own registry

The public registry is served at ui.klarhimmel.com. You can also build and host your own copy from the source.

- **Serve your own build**: Run npm run site:build in the repository. It writes every item to dist-site/r/ and llms.txt beside it. Serve dist-site with any static server and use that address, ending in /r/{name}.json, as the @klarhimmel registry above.
- **Or copy the source**: Every block and component is a plain file in the repository under src/. Copy the files and the theme item by hand; the registry only automates that.

[Previous](/get-started/)

[Next](/get-started/theming)

- **Copy for AI**
