Font Display
Font display is a CSS property that controls how fonts appear on your website. By default, Fontsource uses the swap
value for the font-display
property. This means that while a custom font is loading, the browser displays a fallback font. Once the custom font is ready, the browser swaps it in place of the fallback font.
Note: You can learn more about the
font-display
property in the MDN Web Docs.
To customise the font-display
property for a specific font, you can use the Advanced tab on each Install page to generate custom @font-face
rules with your preferred value.
Example
To set the font-display
property to optional
for Open Sans, you can create the following @font-face
rule:
⬤⬤
css
Note: This method is only compatible with Vite-based frameworks or similar setups that support CSS bundling with
url()
rewrites.
You can then include this rule in your global CSS file and apply it to your components using the following CSS:
⬤⬤
css