Capítulo 18 de 108
Full manual setup without the CLI: install deps, configure aliases, add the theme CSS, write the cn helper, and hand-author components.json. Useful for frameworks the CLI doesn't support or for full control.
shadcn class-variance-authority clsx tailwind-merge lucide-react tw-animate-css.cn helper: clsx + tailwind-merge wrapper, the utility every component uses to merge className props.tsconfig.json paths (@/*) or package.json#imports (#components/* etc., needs moduleResolution: "bundler" + resolvePackageJsonImports: true).components.json is hand-authored here, not generated by init.npm install shadcn class-variance-authority clsx tailwind-merge lucide-react tw-animate-css
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "base-nova",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "",
"css": "src/styles/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"iconLibrary": "lucide"
}
components.json mínimo e completo escrito à mão, sem depender de init.@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";
@custom-variant dark (&:is(.dark *));
dark custom variant.@import "shadcn/tailwind.css": loses shared utilities like data-open:/data-closed: custom variants and accordion animations that CLI-installed components rely on.components.json and tsconfig/package.json#imports: components install to the wrong path or fail to resolve.shadcn init automates: deps, aliases, theme CSS, cn helper, components.json.package.json#imports requires mirroring the same #... alias roots in components.json's aliases block.npx shadcn add <component>, manual install only replaces init, not add.init is what this chapter replicates by hand.