How are custom fonts implemented? #3474
-
I am reading the docs about custom fonts and at one point it says that in my app.css file I need to put something like
I am curious, how does this import work? AFAIK this isn't valid css. Is this handled by a plugin? If so, which? Secondly, once I am done configuring my font, how can I use it in regular html elements or custom components? Just use the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
In short, the source of the font is an NPM package. You'll note the step listed installs your font of choice. In this example
Which should live in something like These directions come directly from Fontsource, which you can see written here: If you're curious to hear more about their implementation, I might recommend reaching out to their support communities on GitHub/Discord.
We recommend you assign the font family values to your theme properties like so. Substitute [data-theme='cerberus'] {
--heading-font-family: 'Open Sans', sans-serif;
--base-font-family: 'Open Sans', sans-serif;
--anchor-font-family: 'inherit';
} If you need to reference the theme-specified version of this font family list, you would use your API methods listed here: https://www.skeleton.dev/docs/get-started/core-api#typography For example if you set |
Beta Was this translation helpful? Give feedback.
-
@sledgehammer999 @Sarenor just FYI I've been working on a big docs update, so I've included the No need to file a new ticket or submit a separate PR. |
Beta Was this translation helpful? Give feedback.
Ok I see what they're doing here:
On FontSource they're expecting the import to occur in a JS/TS file, which Vite supports.
In our docs we're recommending folks import this in their CSS stylesheet. Which should be
@import
.I'd welcome a ticket or PR to help correct this.