Skip to content

Commit

Permalink
Update tailwind fonts snippet (withastro#6883)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOtterlord authored Feb 14, 2024
1 parent 2b7f593 commit 2b305f3
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/content/docs/en/guides/fonts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,25 @@ If you are using the [Tailwind integration](/en/guides/integrations-guide/tailwi
To register your font in Tailwind:

1. Follow either of the guides above, but skip the final step of adding `font-family` to your CSS.
1. Add the typeface name to `tailwind.config.cjs`.
1. Add the typeface name to `tailwind.config.mjs`.

This example adds `InterVariable` and `Inter` to the sans-serif font stack, with default fallback fonts from Tailwind CSS.

```js title="tailwind.config.cjs" ins={1,7-9}
const defaultTheme = require("tailwindcss/defaultTheme");

module.exports = {
// ...
theme: {
extend: {
fontFamily: {
sans: ["InterVariable", "Inter", ...defaultTheme.fontFamily.sans],
},
},
},
// ...
};
```js title="tailwind.config.mjs" ins={1,8-10}
import defaultTheme from 'tailwindcss/defaultTheme'

/** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
theme: {
extend: {
fontFamily: {
sans: ['Inter', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [],
}
```

Now, all sans-serif text (the default with Tailwind) in your project will use your chosen font and the `font-sans` class will also apply the Inter font.
Expand Down

0 comments on commit 2b305f3

Please sign in to comment.