Unverified Commit 98eaa5c1 authored by Joseph's avatar Joseph Committed by GitHub

docs: font per-call preload scope and the declarations font-family override (#99167)

Derived from the conversation over at:
https://github.com/vercel/next.js/discussions/99025

I think `preload` needs that additional caveat.

Document the declaration of a font-family. Note that the pattern
discussed on that thread is not something we should document, at least I
don't think so, I am just expanding the docs on this area.
parent bae2c569
...@@ -185,6 +185,8 @@ Examples: ...@@ -185,6 +185,8 @@ Examples:
A boolean value that specifies whether the font should be [preloaded](/docs/app/api-reference/components/font#preloading) or not. The default is `true`. A boolean value that specifies whether the font should be [preloaded](/docs/app/api-reference/components/font#preloading) or not. The default is `true`.
Every font file a call loads shares this setting, because they become a single group of `@font-face` rules with one `font-family`.
Used in `next/font/google` and `next/font/local` Used in `next/font/google` and `next/font/local`
- Optional - Optional
...@@ -235,6 +237,17 @@ Examples: ...@@ -235,6 +237,17 @@ Examples:
An array of font face [descriptor](https://developer.mozilla.org/docs/Web/CSS/@font-face#descriptors) key-value pairs that define the generated `@font-face` further. An array of font face [descriptor](https://developer.mozilla.org/docs/Web/CSS/@font-face#descriptors) key-value pairs that define the generated `@font-face` further.
Setting `font-family` replaces the name Next.js generates. Keep the value the same as the exported constant, so `className` and the CSS variable reference the same family.
```ts filename="app/fonts.ts"
import localFont from 'next/font/local'
export const myFont = localFont({
src: './my-font.woff2',
declarations: [{ prop: 'font-family', value: 'myFont' }],
})
```
Used in `next/font/local` Used in `next/font/local`
- Optional - Optional
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment