Quick start

Installation and the process: https://ui.shadcn.com/docs/installation/next

  1. Initialize an empty nextjs project.

  2. Initialize shadcn

    npx shadcn@latest init
    
  3. It will install some dependencies, lets talk about this one.

    Class-Variance-Authority

    https://cva.style/docs

  4. It will create a file libs/utils.ts

    import { clsx, type ClassValue } from "clsx"
    import { twMerge } from "tailwind-merge"
    
    export function cn(...inputs: ClassValue[]) {
      return twMerge(clsx(inputs))
    }
    
  5. It will create a components.json file

  6. It will create overwrite global.css file

  7. Now lets add a component, its as simple as installing a package from CLI

    npx shadcn@latest add button
    
  8. Just import the component where you want and use it https://ui.shadcn.com/docs/installation/next

    import { Button } from "@/components/ui/button"
    
    export default function Home() {
      return (
        <div>
          <Button>Click me</Button>
        </div>
      )
    }
    //you can use varients, size to tweak the component