1. Next.js ์คํ์ผ๋ง ๋ฐฉ๋ฒ
Next.js์์๋ ๋ํ์ ์ผ๋ก 3๊ฐ์ง ๋ฐฉ์์ผ๋ก ์คํ์ผ์ ์ ์ฉํ ์ ์์ต๋๋ค.
์ ์ญ ์คํ์ผ (
globals.css
/ SCSS ๊ฐ๋ฅ)โ ๋ชจ๋ ํ์ด์ง์ ๊ณตํต ์ ์ฉ
CSS Module / SCSS Module (
.module.scss
)โ ์ปดํฌ๋ํธ ๋จ์๋ก ์คํ์ผ ์บก์ํ
CSS-in-JS (styled-components, emotion ๋ฑ)
โ ์ด๋ฒ ๊ณผ์ ์์๋ ๋ค๋ฃจ์ง ์์ (์ฌํ ๊ณผ์ ์์ ๊ฐ๋ฅ)
๐ ์ฐ๋ฆฌ๋ ์ ์ญ SCSS + ๋ชจ๋ SCSS๋ฅผ ์กฐํฉํด์ ์ฌ์ฉํฉ๋๋ค.
2. ๊ธ๋ก๋ฒ ์คํ์ผ (์ ์ญ SCSS)
(1) styles/globals.scss
์์ฑ
/* ๊ธ๋ก๋ฒ ์คํ์ผ */
body {
margin: 0;
padding: 0;
background: #fafafa;
color: #222;
font-family: "Noto Sans KR", sans-serif;
line-height: 1.6;
}
a {
color: #0070f3;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
(2) app/layout.tsx
์์
import { Noto_Sans_KR } from "next/font/google";
import Link from "next/link";
import '@/styles/globals.scss'; // ๊ธ๋ก๋ฒ SCSS ์ ์ฉ
// .. ์ดํ ์๋ต
3. ๋ ์ด์์์ฉ SCSS ๋ชจ๋
(1) styles/layout.module.scss
.header {
background: white;
border-bottom: 1px solid #ddd;
padding: 1rem;
nav {
display: flex;
gap: 1rem;
}
}
.container {
max-width: 960px;
margin: 2rem auto;
padding: 0 1rem;
}
.footer {
text-align: center;
padding: 2rem 0;
font-size: 0.9rem;
color: #777;
border-top: 1px solid #ddd;
}
(2) app/layout.tsx
์ ์ฐ๊ฒฐ
import { Noto_Sans_KR } from "next/font/google";
import Link from "next/link";
import '@/styles/globals.scss';
import styles from "@/styles/layout.module.scss";
const notoSansKR = Noto_Sans_KR({
subsets: ["latin"],
weight: ["400", "500", "700"],
});
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="ko">
<body className={notoSansKR.className}>
<header className={styles.header}>
<nav>
<Link href="/">ํ</Link>
<Link href="/about">์๊ฐ</Link>
<Link href="/posts">Posts</Link>
</nav>
</header>
<main className={styles.container}>{children}</main>
<footer className={styles.footer}>ยฉ 2025 My Next.js App</footer>
</body>
</html>
);
}
4. ํ์ด์ง ์คํ์ผ๋ง ๊ฐ์
(1) styles/home.module.scss
๊ฐ์
.title {
font-size: 2.5rem;
color: #0070f3;
text-align: center;
margin-top: 2rem;
}
.description {
color: #555;
text-align: center;
font-size: 1.2rem;
margin-bottom: 2rem;
}
(2) app/page.tsx
์ ์ฉ
import styles from "@/styles/home.module.scss";
export default function Home() {
return (
<main>
<h1 className={styles.title}>Hello Next.js ๐</h1>
<p className={styles.description}>
SCSS์ ๊ธ๋ก๋ฒ ๋ ์ด์์์ ์ ์ฉํ Next.js ๊ธฐ๋ณธ ํ์ด์ง์
๋๋ค.
</p>
</main>
);
}
5. ์ค๋์ ์ ๋ฆฌ
- ๊ธ๋ก๋ฒ SCSS(
globals.scss
) ์ ์ฉ โ ํฐํธ/๊ธฐ๋ณธ ์คํ์ผ ๊ด๋ฆฌ - ๋ ์ด์์ SCSS ๋ชจ๋(
layout.module.scss
) ์ ์ฉ โ Header/Footer/Container ์คํ์ผ ๊ด๋ฆฌ - ํ์ด์ง SCSS ๋ชจ๋(
home.module.scss
)๋ก ๊ฐ๋ณ ์คํ์ผ ์ ์ฉ - ๊ณตํต ๋ ์ด์์(ํค๋/ํธํฐ) ๊ตฌ์กฐ ์์ฑ
๐ฌ ๋๊ธ
โป ๋ก๊ทธ์ธ ํ ๋๊ธ์ ์์ฑํ ์ ์์ต๋๋ค.