Installation
CK-UI has its own command-line tool, the CK-UI CLI (ck-ui-cli on npm). Run it in your project to set CK-UI up once, then add the components you need. Each component is copied into your project as source code, so you can read it and change it.
Requirements
| Project | Tailwind CSS | Status |
|---|---|---|
| Next.js (App Router), TypeScript | v4 | Supported |
| Next.js (App Router), TypeScript | v3.4.1 or later | Supported |
| React + Vite, TypeScript | v4 | Supported |
| React + Vite, TypeScript | v3 | Not supported: upgrade to v4 with npx @tailwindcss/upgrade |
- Node.js 18.17 or later and React 18 or later.
- A
tsconfig.json: the components are TypeScript (.tsx) files. - Tailwind CSS set up in the project, with a stylesheet that loads it.
- npm and pnpm are supported. Yarn and Bun are detected (from the
packageManagerfield or the lockfile) and used, but are not part of the tested setups yet.
Quick Start
Run these commands in your project's folder. The CLI detects the framework, the Tailwind CSS version and the package manager.
Set up CK-UI
npx ck-ui-cli@latest initRun this once per project. It changes only what CK-UI needs:
- Adds CK-UI's design tokens, utilities and dark mode to the stylesheet that loads Tailwind CSS (for example
src/app/globals.css), inside a block marked/* ck-ui:start … */…/* ck-ui:end */. The rest of the file stays as it is. - Writes the
cn()helper tosrc/components/ck-ui/lib/utils.ts. - Installs
clsx,tailwind-mergeandtw-animate-css(Tailwind CSS v4), orclsx,tailwind-merge,tailwindcss-animateand@tailwindcss/forms(v3). Packages you already have are not reinstalled or upgraded. - With Tailwind CSS v3, adds
ck-ui.tailwind-preset.jsand adds it to the presets in yourtailwind.config. - Records the setup in
ck-ui.json.
CK-UI's CSS variables are prefixed (--ck-primary, …), so yours keep their values. If your stylesheet already defines theme colours CK-UI uses (for example from another design system), init stops and names them; --allow-theme-overrides lets CK-UI's colours win for those names. Running init again changes nothing, unless CK-UI's setup has changed since (see Update Components).
Add a component
npx ck-ui-cli@latest add buttonThis copies Button.tsx into src/components/ck-ui (components/ck-ui in a project without a src folder), together with every CK-UI component it uses, points its imports at that folder and installs the npm packages it needs. Each component's page shows its command in its Installation section.
Components are namespaces:
import * as Button from "@/components/ck-ui/Button";
export function Save() {
return <Button.Root>Save</Button.Root>;
}The import path follows your project's alias (@/* here); the CLI prints it after adding a component.
Add several components
npx ck-ui-cli@latest add button input modalComponents they share are added once. dialog is another name for modal.
See the available components
npx ck-ui-cli@latest listLists the 54 components you can add. --json prints them for scripts, and --all also shows the files installed only as dependencies of other components.
Check your setup
npx ck-ui-cli@latest doctorChecks Node.js, the framework, Tailwind CSS, your stylesheet, the Tailwind CSS v3 preset, the packages and the installed components, and prints a fix for each problem. It never changes anything, and exits with code 1 when something needs fixing.
Project Files
| File | What it is |
|---|---|
src/components/ck-ui/ | The components you add (components/ck-ui/ without a src folder). Choose another folder with init --dir <folder>. |
src/components/ck-ui/lib/utils.ts | The cn() helper the components use (clsx + tailwind-merge). |
| Your stylesheet | CK-UI's block, between /* ck-ui:start … */ and /* ck-ui:end */. |
ck-ui.json | Where things are, and a checksum of every file the CLI wrote. add and doctor read it, so keep it with your project. |
ck-ui.tailwind-preset.js | Tailwind CSS v3 only: CK-UI's theme, used through presets in your tailwind.config. |
Update Components
Components are copied into your project, so they stay as they are until you update them. To get the current version of the components you use, run add again with their names. To get CK-UI's current design tokens (its colours, for example), run init again.
npx ck-ui-cli@latest add badge buttonnpx ck-ui-cli@latest initaddupdates each file it wrote that you have not edited since, adds any component the new versions use, and installs their packages. A component you name that is not in the project yet is added too.initupdates CK-UI's block in your stylesheet (and, with Tailwind CSS v3, its preset) when CK-UI's setup has changed.- Files you edited are kept, as described below. Add
--dry-runto see what would change first. - The changelog says which components and tokens changed in each release.
Your Changes Are Kept
- A file you have not changed since the CLI wrote it is updated in place.
- A file you edited, or any file the CLI did not write, is never replaced unless you pass
--overwrite(or answer "y" in an interactive terminal). The previous version is kept as<file>.ck-ui-backup. - Running
addagain with nothing new changes nothing. - In your stylesheet,
initonly replaces its own block. If you edited that block, it is kept as well (in an interactive terminal,initasks first). - Add
--dry-runtoinitoraddto see what would change without changing anything.
Options
| Command | Options |
|---|---|
init | --css <file> your stylesheet, --dir <folder> the components folder, --dry-run, --no-install, --allow-theme-overrides |
add | --dry-run, --overwrite, --no-install |
list | --all, --json |
| Every command | --cwd <dir> runs it for another project folder, --help shows its usage |
Dark Mode
CK-UI's components follow a dark class on <html> (or any ancestor), as set by next-themes with attribute="class". They use their own ck-dark: variant, so the dark: classes in your project keep their meaning.
Known Limitations
- React + Vite needs Tailwind CSS v4, and Tailwind CSS before 3.4.1 is not supported. Projects without TypeScript are not supported.
- Next.js support is tested with the App Router.
- Yarn and Bun are detected and used, but are not part of the tested setups yet.
- In React + Vite projects, components that render links (Button, Link Button and Navs Vertical with
href) use a plain<a>instead of Next.js'<Link>. For client-side routing, render your router's link throughasChild. - With Tailwind CSS v4, utilities that v4 renamed are installed under their v4 names with the same look. Two v4 defaults still apply: buttons show the default cursor, and palette colours chosen by props (for example
Badge color="green") use v4's palette. To restore the pointer cursor, add@layer base { button:not(:disabled), [role="button"]:not(:disabled) { cursor: pointer; } }to your stylesheet. - The CLI installs the free components. Premium blocks and templates are not available through it.
Troubleshooting
- "Could not find the stylesheet that loads Tailwind CSS"
- Name it:
npx ck-ui-cli@latest init --css src/styles/app.css. - "… already defines theme colours CK-UI would override"
- Another design system is probably set up in that stylesheet. Run
initwith--allow-theme-overridesto let CK-UI's colours win for the names it lists. - "Tailwind CSS is not installed" or "… is too old"
- Set up Tailwind CSS v4 (or v3.4.1 or later with Next.js) first, then run
initagain. - Components look restyled in a React + Vite project
- Vite's starter
src/index.cssstylesbuttonandaoutside a cascade layer, which with Tailwind CSS v4 overrides every utility class. Remove those starter rules (Tailwind's reset replaces them);initanddoctorpoint them out. The CLI never deletes your styles itself. - "edited — kept"
- You changed that file since the CLI wrote it, so it was left as it is. Run the command again with
--overwriteto replace it; a.ck-ui-backupcopy is kept. - Anything else
- Run
npx ck-ui-cli@latest doctor: it checks the whole setup and prints a fix for each problem. The CLI downloads components fromhttps://www.ck-ui.com/r, so it needs access to that address.
Security
- The registry is fetched over HTTPS only, and redirects are refused.
- Every response is validated: component and file names must match strict patterns, each file must match its SHA-256 checksum, and dependencies must be plain npm packages with a version range.
- Files are only written inside your project.
- Packages are installed without a shell, and npm and pnpm run with
--ignore-scripts. Nothing downloaded is executed, and the CLI itself has no runtime dependencies.
Manual Installation
Prefer to set a project up by hand? Follow the Next.js guide (Tailwind CSS v3), then copy components from their pages: open Manual installation in a component's Installation section.
The same files are also in the CK-UI repository on GitHub (opens in a new tab): every free component in one folder per setup (Next.js or React + Vite with Tailwind CSS v4, Next.js with Tailwind CSS v3), with the design tokens and example apps.