Shadw ui is an Huge collection of copy and paste components for quickly building app, webs UI using tailwind css and shadcn ui for the faster building of UI. It‘s free, open-source, and ready to drop into your projects.
Components are styled using Tailwind CSS. You need to install Tailwind CSS in your project.
Follow the Tailwind CSS installation instructions to get started.After Create the next.js project, add a shadcn to your project run the following command in your terminal
npminstall tailwindcss-animate class-variance-authority clsx tailwind-merge lucide-react
Configure the path aliases in your tsconfig.json file.
1{
2 "compilerOptions": {
3 "baseUrl": ".",
4 "paths": {
5 "@/*": ["./*"]
6 }
7 }
8}
Here's what my tailwind.config.js file looks like:
1/** @type {import('tailwindcss').Config} */
2module.exports = {
3 darkMode: ["class"],
4 content: ["app/**/*.{ts,tsx}", "components/**/*.{ts,tsx}"],
5 theme: {
6 extend: {
7 colors: {
8 border: "hsl(var(--border))",
9 input: "hsl(var(--input))",
10 ring: "hsl(var(--ring))",
11 background: "hsl(var(--background))",
12 foreground: "hsl(var(--foreground))",
13 primary: {
14 DEFAULT: "hsl(var(--primary))",
15 foreground: "hsl(var(--primary-foreground))",
16 },
17 secondary: {
18 DEFAULT: "hsl(var(--secondary))",
19 foreground: "hsl(var(--secondary-foreground))",
20 },
21 destructive: {
22 DEFAULT: "hsl(var(--destructive))",
23 foreground: "hsl(var(--destructive-foreground))",
24 },
25 muted: {
26 DEFAULT: "hsl(var(--muted))",
27 foreground: "hsl(var(--muted-foreground))",
28 },
29 accent: {
30 DEFAULT: "hsl(var(--accent))",
31 foreground: "hsl(var(--accent-foreground))",
32 },
33 popover: {
34 DEFAULT: "hsl(var(--popover))",
35 foreground: "hsl(var(--popover-foreground))",
36 },
37 card: {
38 DEFAULT: "hsl(var(--card))",
39 foreground: "hsl(var(--card-foreground))",
40 },
41 },
42 borderRadius: {
43 lg: `var(--radius)`,
44 md: `calc(var(--radius) - 2px)`,
45 sm: "calc(var(--radius) - 4px)",
46 },
47 },
48 },
49 plugins: [require("tailwindcss-animate")],
50}
Add the following to your styles/globals.css file. You can learn more about using CSS variables for theming in the
1@tailwind base;
2@tailwind components;
3@tailwind utilities;
4
5@layer base {
6 :root {
7 --background: 0 0% 100%;
8 --foreground: 222.2 47.4% 11.2%;
9 --muted: 210 40% 96.1%;
10 --muted-foreground: 215.4 16.3% 46.9%;
11 --popover: 0 0% 100%;
12 --popover-foreground: 222.2 47.4% 11.2%;
13 --border: 214.3 31.8% 91.4%;
14 --input: 214.3 31.8% 91.4%;
15 --card: 0 0% 100%;
16 --card-foreground: 222.2 47.4% 11.2%;
17 --primary: 222.2 47.4% 11.2%;
18 --primary-foreground: 210 40% 98%;
19 --secondary: 210 40% 96.1%;
20 --secondary-foreground: 222.2 47.4% 11.2%;
21 --accent: 210 40% 96.1%;
22 --accent-foreground: 222.2 47.4% 11.2%;
23 --destructive: 0 100% 50%;
24 --destructive-foreground: 210 40% 98%;
25 --ring: 215 20.2% 65.1%;
26 --radius: 0.5rem;
27 }
28
29 .dark {
30 --background: 224 71% 4%;
31 --foreground: 213 31% 91%;
32 --muted: 223 47% 11%;
33 --muted-foreground: 215.4 16.3% 56.9%;
34 --accent: 216 34% 17%;
35 --accent-foreground: 210 40% 98%;
36 --popover: 224 71% 4%;
37 --popover-foreground: 215 20.2% 65.1%;
38 --border: 216 34% 17%;
39 --input: 216 34% 17%;
40 --card: 224 71% 4%;
41 --card-foreground: 213 31% 91%;
42 --primary: 210 40% 98%;
43 --primary-foreground: 222.2 47.4% 1.2%;
44 --secondary: 222.2 47.4% 11.2%;
45 --secondary-foreground: 210 40% 98%;
46 --destructive: 0 63% 31%;
47 --destructive-foreground: 210 40% 98%;
48 --ring: 216 34% 17%;
49 }
50}
51
52@layer base {
53 * {
54 @apply border-border;
55 }
56 body {
57 @apply font-sans antialiased bg-background text-foreground;
58 }
59}
1import { clsx, type ClassValue } from "clsx"
2import { twMerge } from "tailwind-merge"
3
4export function cn(...inputs: ClassValue[]) {
5 return twMerge(clsx(inputs))
6}
Create a components.json file in the root of your project.
1{
2 "$schema": "https://ui.shadcn.com/schema.json",
3 "style": "new-york",
4 "rsc": false,
5 "tsx": true,
6 "tailwind": {
7 "config": "tailwind.config.js",
8 "css": "src/index.css",
9 "baseColor": "zinc",
10 "cssVariables": true,
11 "prefix": ""
12 },
13 "aliases": {
14 "components": "@/components",
15 "utils": "@/lib/utils",
16 "ui": "@/components/ui",
17 "lib": "@/lib",
18 "hooks": "@/hooks"
19 },
20 "iconLibrary": "lucide"
21}