Using custom fonts
Last updated: 2.0.0 (16/01/2024)
Last updated
Was this helpful?
Last updated: 2.0.0 (16/01/2024)
Last updated
Was this helpful?
You may pretty quickly bump up against the fact that Valence will default to using your system's fonts.
This guide assumes you have followed your chosen Discipline library's Getting Started guide.
To start, download and save whichever font/s you want to use in your project. In this example we're going to use , which is available for free on Google Fonts. Relevant files from this font have been saved to the src/assets/fonts/
folder in our project directory.
Then, we're going to define and import the fonts into a global.css
file, which we will then import. We're going to create the file in src/assets/css/
, then paste the standard CSS font imports like so:
Then, head back into the root app file (usually App.tsx
or App.jsx
) and import the global.css
file:
Finally, we can update the ValenceProvider
to use our new font/s:
That's all there is to it! Valence will default to using this font when it needs a monospace or heading font, however you can supply different fonts to them by updating the fontFamily
prop of the ValenceProvider
with references to those fonts.