この
この
ただ、
Noto Sans JP
Google Fonts で
No more tofu から
また、
Inter
英字フォントで
この
ちなみに
Newsreader
この
JetBrains Mono
普段から
そんな
特徴的なのは=/=
に=>
に
この
Noto Emoji
記事の
ただ、
20240519 追記
こちらの
Tailwind で 使う
Next.js とNext.js と
この機能を
また、
簡単に
まずは
import { Inter, JetBrains_Mono, Newsreader, Noto_Emoji, Noto_Sans_JP } from 'next/font/google';
export const notoSansJP = Noto_Sans_JP({ subsets: ['latin'], display: 'swap', weight: ['400', '500'],});
export const inter = Inter({ subsets: ['latin'], weight: ['400', '500'], display: 'swap', variable: '--font-inter' });
export const newsreader = Newsreader({ subsets: ['latin'], display: 'swap', weight: ['400'], style: 'italic', variable: '--font-newsreader',});
export const jetBrainsMono = JetBrains_Mono({ subsets: ['latin'], display: 'swap', weight: ['400'], style: 'normal', variable: '--font-jetbrains-mono',});
export const notoEmoji = Noto_Emoji({ subsets: ['emoji'], display: 'swap', weight: '600', style: 'normal', variable: '--font-noto-emoji',});
variable
を
次に<html>
要素に
import { inter, jetBrainsMono, newsreader, notoEmoji, notoSansJP } from '#/lib/nextjs/fonts';
const RootLayout = ({ children }: { children: React.ReactNode }) => ( <html className={`${notoSansJP.className} ${inter.variable} ${newsreader.variable} ${jetBrainsMono.variable} ${notoEmoji.variable}`} > ... </html>)
プライマリフォントであるclassName
をvariable
最後に
import type { Config } from 'tailwindcss';import defaultTheme from 'tailwindcss/defaultTheme';
export default { theme: { extend: { fontFamily: { sans: ['var(--font-inter)', ...defaultTheme.fontFamily.sans], serif: ['var(--font-newsreader)', ...defaultTheme.fontFamily.serif], mono: ['var(--font-jetbrains-mono)', ...defaultTheme.fontFamily.mono], emoji: ['var(--font-noto-emoji)', 'Apple Color Emoji'], }, }, },} satisfies Config;
もしカスタムフォントの
個別にclassName
を
<p className='font-mono'>Whereas disregard and contempt for human rights have resulted.</p>
フォントに