Reputation: 37484
export const SomeText = styled(Text)`
font-family: "Arial", sans-serif;
`
export const SomeText = styled(Text)`
font-family: Arial, sans-serif;
`
export const SomeText = styled(Text)`
font-family: "Arial, sans-serif";
`
All of the above error.
Example error: Error: Failed to parse declaration "fontFamily: "Arial", sans-serif"
Which is the correct way to apply font-family in React Native via Styled Components?
Upvotes: 2
Views: 4243
Reputation: 953
The system fonts are different for mobile platforms than for the browser. You can find a list here: https://github.com/react-native-training/react-native-fonts
If you want your code to fall back on available system fonts you can use something like this:
${Platform.select({ ios: css`font-family: Helvetica`, android: css`font-family: Roboto` })};
(Reference here: https://github.com/styled-components/styled-components/issues/1058)
Upvotes: 5