Multiple Fonts
Overview
Customize
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 codeOther resources
Last updated