Custom Fonts
The design system includes DancingScript and OpenSans fonts. Here's how to use them effectively.
Included Fonts
| Font | Weights | Usage |
|---|---|---|
| DancingScript | Regular, Medium, Bold | Display text, branding |
| OpenSans | Regular, Medium, Bold | UI text, body content |
Font Loading
Fonts are automatically loaded by MultinaireDesignProvider. The provider shows nothing until fonts are loaded:
<MultinaireDesignProvider theme={theme}>
{/* App renders only after fonts load */}
</MultinaireDesignProvider>
Using Fonts
With MultinaireText
// DancingScript is used for 'display' type
<MultinaireText type="display" weight="bold">
Brand Name
</MultinaireText>
// OpenSans is used for all other types
<MultinaireText type="body">
Regular content
</MultinaireText>
Direct Style Access
const { fonts } = useMultinaireTheme();
<Text style={fonts.display.bold}>
{/* Uses DancingScript-bold */}
</Text>
<Text style={fonts.body.regular}>
{/* Uses OpenSans-regular */}
</Text>
Font Configuration
Configure fonts in your theme.json:
{
"texts": {
"display": {
"regular": { "fontFamily": "DancingScript", "fontSize": 24 },
"medium": { "fontFamily": "DancingScript", "fontSize": 24 },
"bold": { "fontFamily": "DancingScript", "fontSize": 24 }
},
"heading": {
"regular": { "fontFamily": "OpenSans", "fontSize": 20 },
"medium": { "fontFamily": "OpenSans", "fontSize": 20 },
"bold": { "fontFamily": "OpenSans", "fontSize": 20 }
}
}
}
Adding Custom Fonts
To add your own fonts:
- Currently not supported - The design system only supports DancingScript and OpenSans
- Fork the library if you need custom fonts
- Or use inline styles for occasional custom font usage:
import { useFonts } from 'expo-font';
function App() {
const [fontsLoaded] = useFonts({
'MyCustomFont': require('./assets/fonts/MyCustomFont.ttf'),
});
return (
<Text style={{ fontFamily: 'MyCustomFont' }}>
Custom font text
</Text>
);
}
Web Considerations
On web, ensure fonts are preloaded to avoid FOUT (Flash of Unstyled Text):
<link rel="preload" href="/fonts/OpenSans-Regular.ttf" as="font" crossorigin>
Troubleshooting
Fonts not loading
- Ensure
MultinaireDesignProviderwraps your app - Check that expo-font is installed
- Clear Metro cache:
npx expo start --clear
Wrong font appearing
- Check the
fontFamilyin your theme.json - Verify weight matches: 'regular', 'medium', or 'bold'
- Ensure the type/weight combination exists in your theme