There is a particular process for adding custom fonts to an iOS project. I assume there is such a process for an Android project. What is the process for adding custom fonts to a react-native-web project? Is it as easy as simply adding an @font-face declaration with the appropriate url relative to the React Native project root? If so, does this hold for production builds and not just dev builds?
Thanks for your feedback!
You can add a standard @font-face definition to the head of your HTML shell page
Nice, thanks! I tried it locally and it seemed to work, but I just wanted to make sure. Also this is nice documentation for newcomers to react-native-web (like myself).
Hello!
My project use custom fonts, ex. OpenSans (regular, light, bold).
This is part of my current stylesheet
const MyStyles = StyleSheet.create({
textInput: {
fontFamily: 'opensans_light',
}
}
I'd like to use custom font both in web project and in react (not react-native) storybook.
So where and how I need specify fonts?
Thank you!
Just add a wrapper with some inline styles if you don't have a CSS file. Example here https://github.com/oblador/react-native-vector-icons#web-with-webpack
I will be very appreciate who could provide any minimal project using custom (google) fonts :)
@necolas would you accept a PR to add an expo-like API to load custom fonts? https://docs.expo.io/versions/latest/sdk/font.html
No, that belongs in a tool like Expo. Thanks for asking :)
"Expo for Web" is an idea that's been kicking around. And making a combination of CRA and CRNA.
@alexandergunnarson Can you please provide some details on how you added the font-face css? thanks in advance.
I have choose react native web in my project without expo, I am facing problem of Date Time picker and responsiveness of site not working, please suggest which datetime picker used for our project and how make responsive template....
I haven't been able to find it anywhere in the docs and the issues, so I'll just leave it here. My case was Expo with Bare Workflow, so Expo has web support built-in, and I couldn't figure out where I can add a stylesheet to html, so this how I did it:
index.web.js.web.js extension.index.css file with @font-face declarations// in index.web.js
import './index.css'
After this font files should be loaded in web app.
Most helpful comment
"Expo for Web" is an idea that's been kicking around. And making a combination of CRA and CRNA.