I connect the font in head (index.html)
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display&display=swap"
rel="stylesheet"/>
file tailwind.config.js
module.exports = {
content: ["./src/**/*.{html,js}"],
theme: {
extend: {
fontFamily: {
playfair: ['"Playfair Display"', 'cursive'],
}
}
}
};
and how I use <h1 class="font-playfair">Enjoy Your Favorite Coffee</h1>
I checked the font is attached correctly, because if you attach it in the css file everything works
Based on your question and comment about using CND, I assume you might have been mixed two possible setup options in an incorrect way.
CDN setup
This is the simplest option, it doesn't require dealing with any command, installing node packages, etc. All you need is to add
scripttag to referencetailwindcsslibrary from the CDN and, if needed, add any configurations or customization in that same HTML file. See more details in the documentation.Note that in this case,
tailwinddoes not have access to other files, it can work only with what included into the HTML code. So configs and everything else should be included explicitly.This is an example using that font:
CLI setup
In that case you should use Command-Line Interface (CLI) to build your retulting CSS file based on configuration in
tailwind.config.jsand you input CSS files.Minimum setup to add that font would be:
tailwindcssnode package (runnpm i tailwindcss);tailwind.config.jswith your configuration:srcfolder andindex.htmlin that folder:npx tailwindcss -o ./src/output.cssso it will createoutput.cssin thesrcfolder.Whenever you change configuration, or add more CSS, you'll have to rebuild
output.cssto reflect changes. You can also run build command adding--watchargument, so it will monitor your files changes and automatically rebuild theoutput.css.See more details in the documentation.