728x90
반응형
SMALL
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>
</>
);
}
728x90
반응형
LIST
'DEV > NextJS' 카테고리의 다른 글
[NEXT.js] 5. Link 컴포넌트 사용 이슈 ( new- link ) (0) | 2024.06.19 |
---|---|
[NEXT.js 14] 5. Layout(feat. { children }: { children: ReactNode }) props (1) | 2024.06.18 |
[NEXT.js 14] 3. CSS 사용 2가지 방법 (css module 생생 / global.css : tailwind css) (0) | 2024.06.14 |
[NEXT.js 14] 2. loading.js & Suspense & streamed Response (세분화 로딩상태 관리) (0) | 2024.06.14 |
[NEXT.js 14] 1. Image 태그 관련 <Image> (0) | 2024.06.11 |
댓글