NEXT.js ์์๋ 'next/font/google'์ ๊ฐ์ด google font ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ด์ฅํ๊ณ ์์ด ์ ๊ทผ์ฑ์ด ์ข์ต๋๋ค.
๋ฟ๋ง ์๋๋ผ 'next/font'๋ ๋ชจ๋ ๊ธ๊ผด ํ์ผ์ ์๋์ ์ผ๋ก ์์ฒด ํธ์คํ ์ด ๋ด์ฅ๋ผ ์๊ณ ,
์ด๋ฅผ ์ ์ฉํ๊ณ ์ ๋ ์ด์์(๋ทฐ)์ ์ฌํํธ(๊น๋นก์, ๊ธ๊ผด์ ์๊ฐ์ ๋ณํ ๋ฑ) ์์ด ํฐํธ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
Font ๋ฐ๊พธ๊ธฐ
1. import {...} from 'next/font/google';
2. layout.tsx ๋๋ Font.ts ์ปดํฌ๋ํธ์ ์ฌ์ฉํ Font ์์ฑ
3. tailwind.config.ts ์์ฑ
4. tailwind css ํ๊ธฐ๋ก ์ฌ์ฉํ๊ธฐ
์์ธ
1. import {...} from 'next/font/google';
# app/font.ts
import { Font๋ช
์นญ } from 'next/font/google';
2. layout.tsx ๋๋ Font.ts ์ปดํฌ๋ํธ์ ์ฌ์ฉํ Font ์์ฑ
# app/font.ts
import { ABeeZee } from 'next/font/google';
export const abeezee = ABeeZee(
{
subsets: ['latin'],
variable: '--font-abeezee',
weight: '400',
display: 'swap',
});
3. tailwind.config.ts ์์ฑ
# /tailwind.config.ts
import type {Config} from "tailwindcss";
const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
fontFamily: {
abeezee: ['var(--font-abeezee)'],
},
},
},
plugins: [],
};
export default config;
4. tailwind css ํ๊ธฐ๋ก ์ฌ์ฉํ๊ธฐ
(1) global.css
@tailwind base;
@tailwind components;
@tailwind utilities;
body {
@apply font-abeezee text-white
}
(2) page.tsx
# ์ ์ฉํ page
export default function Home() {
return (
<>
<div className="main-bg font-abeezee">
...
</div>
</>
);
}
๋๊ธ