Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[joy-ui] What is the correct way to specify a custom font-face in the theme? #38977

Closed
1 task done
atrauzzi opened this issue Sep 14, 2023 · 3 comments
Closed
1 task done
Assignees
Labels
customization: theme Centered around the theming features package: joy-ui Specific to @mui/joy support: docs-feedback Feedback from documentation page support: question Community support but can be turned into an improvement

Comments

@atrauzzi
Copy link
Contributor

atrauzzi commented Sep 14, 2023

Duplicates

  • I have searched the existing issues

Related page

https://mui.com/joy-ui/customization/theme-typography/#changing-the-default-font

Kind of issue

Missing information

Issue description

I was looking for the right place to put a font-face declaration and it appears that it isn't mentioned in the docs.

Context 🔦

Joy UI

@atrauzzi atrauzzi added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: docs-feedback Feedback from documentation page labels Sep 14, 2023
@danilo-leal danilo-leal changed the title [docs] What is the correct way to specify a custom font-face in joy? [joy-ui] What is the correct way to specify a custom font-face in the theme? Sep 14, 2023
@danilo-leal danilo-leal added support: question Community support but can be turned into an improvement package: joy-ui Specific to @mui/joy customization: theme Centered around the theming features labels Sep 14, 2023
@siriwatknp
Copy link
Member

Thanks for asking, this is more of CSS related question. It depends on the framework that you use, but the recommended way is to use CSS file which could look like this:

// global.css or anyname.css
@font-face {
  font-family: "Trickster";
  src:
    local("Trickster"),
    url("trickster-COLRv1.otf") format("opentype") tech(color-COLRv1),
    url("trickster-outline.otf") format("opentype"),
    url("trickster-outline.woff") format("woff");
}

Then, to apply the font to Joy UI, set it in the theme:

extendTheme({
  fontFamily: {
    display: 'Trickster',
    body: 'Trickster',
  }
})

Learn more about theming from here.

@siriwatknp siriwatknp removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 25, 2023
@atrauzzi
Copy link
Contributor Author

@siriwatknp -- My question was more around managing the @font-face declaration using the theme, rather than having to keep some CSS file separate somewhere.

@danilo-leal
Copy link
Contributor

@atrauzzi hey! I think Jun mentions this is more of a CSS question because you wouldn't use the theme to manage it. You'd need to declare any font-face-related stuff in the place where you import the font and then refer to it on the theme, as he pointed out. Is there anything specific you could share that you were trying to do? Maybe with an example, we can be more helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: theme Centered around the theming features package: joy-ui Specific to @mui/joy support: docs-feedback Feedback from documentation page support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

3 participants