In the starter kit, I have already configured two fonts: and . To use those fonts, you can use the font-sans and font-serif class in TailwindCSS.
Customize
You can find the following piece of code in src/app/layout.tsx and tailwind.config.ts file:
layout.tsx
import { Inter, Source_Serif_4 } from 'next/font/google';
// other import statements
// making an object of Inter font, and giving it variable '--font-sans'
const fontSans = Inter({ subsets: ['latin'], variable: '--font-sans' });
// making an object of Source Serif 4 font, and giving it variable '--font-serif'
const fontSerif = Source_Serif_4({
subsets: ['latin'],
style: ['italic', 'normal'],
variable: '--font-serif',
});
// some code here
<body
className={cn(
'font-sans antialiased', // making font-sans default
fontSans.variable, // with this, you can use font-sans anywhere
fontSerif.variable // with this, you can use font-serif anywhere
)}
>
// other code
import { Inter, Source_Serif_4, Space_Grotesk } from 'next/font/google';
// other import statements
// making an object of Inter font, and giving it variable '--font-sans'
const fontSans = Inter({ subsets: ['latin'], variable: '--font-sans' });
// making an object of Source Serif 4 font, and giving it variable '--font-serif'
const fontSerif = Source_Serif_4({
subsets: ['latin'],
style: ['italic', 'normal'],
variable: '--font-serif',
});
//making an object of Space Grotesk font, and giving it variable '--font-mono'
const fontMono = Space_Grotesk({
subsets: ['latin'],
variable: '--font-mono',
})
// some code here
<body
className={cn(
'font-sans antialiased', // making font-sans default
fontSans.variable, // with this, you can use font-sans anywhere
fontSerif.variable, // with this, you can use font-serif anywhere
fontMono.variable // with this, you can use font-mono anywhere
)}
>
// other code