2024. 3. 4. 16:17ใ๐ Library
๊ฐ์
- ๋งํฌ: ui.shadcn.com
- ์ปดํฌ๋ํธ ๋ผ์ด๋ธ๋ฌ๋ก ๋คํฌ๋ชจ๋, ์บ๋ฆฐ๋, ์นด๋, ๋ฒํผ ๋ฑ ๋ค์ํ UI๋ค์ ์ ๊ณตํจ
์ค์น(Next.js ๊ธฐ์ค)
์๋ก์ด ํ๋ก์ ํธ ์์ฑ: CNA
npx create next-app@latest my-app --typescript --tailwind --eslint
CLI ์ ๋ ฅ
npx shadcn-ui@latest init
components.json ๊ตฌ์ฑ์ ์ํ ๋ช๊ฐ์ง ์ง๋ฌธ๋ค
Would you like to use TypeScript (recommended)? no / yes Which style would you like to use? โบ Default Which color would you like to use as base color? โบ Slate Where is your global CSS file? โบ โบ app/globals.css Do you want to use CSS variables for colors? โบ no / yes Are you using a custom tailwind prefix eg. tw-? (Leave blank if not) ... Where is your tailwind.config.js located? โบ tailwind.config.js Configure the import alias for components: โบ @/components Configure the import alias for utils: โบ @/lib/utils Are you using React Server Components? โบ no / yes
# ์ฌ์ฉ
* ํฐํธ ์ค์ (์์: Inter)
root layout์ ์ ์ฉ
import "@/styles/globals.css"
import { Inter as FontSans } from "next/font/google"
import { cn } from "../@/lib/utils"
const fontSans = FontSans({
subsets: ["latin"],
variable: "--font-sans",
})
export default function RootLayout({ children }: RootLayoutProps) {
return (
<body
className={cn(
"min-h-screen bg-background font-sans antialiased",
fontSans.variable
)}
>
...
)
}
tailwind.config.js์ ์ค์
const { fontFamily } = require("tailwindcss/defaultTheme")
/* @type {import('tailwindcss').Config} /
module.exports = {
darkMode: ["class"],
content: ["app/*/.{ts,tsx}", "components/*/.{ts,tsx}"],
theme: {
extend: {
fontFamily: {
sans: ["var(--font-sans)", ...fontFamily.sans],
},
},
},
}
* App structure
.
โโโ app
โ โโโ layout.tsx
โ โโโ page.tsx
โโโ components
โ โโโ ui
โ โ โโโ alert-dialog.tsx
โ โ โโโ button.tsx
โ โ โโโ dropdown-menu.tsx
โ โ โโโ ...
โ โโโ main-nav.tsx
โ โโโ page-header.tsx
โ โโโ ...
โโโ lib
โ โโโ utils.ts
โโโ styles
โ โโโ globals.css
โโโ next.config.js
โโโ package.json
โโโ postcss.config.js
โโโ tailwind.config.js
โโโ tsconfig.json
# ์ ์ฉ ์์
npx shadcn-ui@latest add button
import { Button } from "@/components/ui/button"
export default function Home() {
return (
)
}
```
reference: https://ui.shadcn.com/docs/installation/next
'๐ Library' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Library] Zustand (0) | 2024.03.19 |
---|---|
[Library] react-hook-form (0) | 2024.03.07 |
[Library] Zod (0) | 2024.03.07 |
[Library]lodash์ ๋ํ์ฌ (0) | 2023.04.27 |