Skip to content

Instantly share code, notes, and snippets.

@vhugogarcia
Created May 25, 2022 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vhugogarcia/c72438fc8ed72f4d5da2e35ec0859de7 to your computer and use it in GitHub Desktop.
Save vhugogarcia/c72438fc8ed72f4d5da2e35ec0859de7 to your computer and use it in GitHub Desktop.
MAUI Font resources for Material Design 3
<?xml version="1.0" encoding="UTF-8" ?>
<?xaml-comp compile="true" ?>
<ResourceDictionary
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<x:String x:Key="FontRegular">NunitoRegular</x:String>
<x:String x:Key="FontMedium">NunitoMedium</x:String>
<x:String x:Key="FontMediumItalic">NunitoMediumItalic</x:String>
<x:String x:Key="FontBold">NunitoBold</x:String>
<x:String x:Key="FontBoldItalic">NunitoBoldItalic</x:String>
<x:String x:Key="FontSemiBold">NunitoSemiBold</x:String>
<x:String x:Key="FontSemiBoldItalic">NunitoSemiBoldItalic</x:String>
<x:String x:Key="FontLight">NunitoLight</x:String>
<x:String x:Key="FontLightItalic">NunitoLightItalic</x:String>
<x:String x:Key="FontItalic">NunitoItalic</x:String>
<Style Class="display-1" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="64"/>
</Style>
<Style Class="display-large" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="57"/>
</Style>
<Style Class="display-medium" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="45"/>
</Style>
<Style Class="display-small" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="36"/>
</Style>
<Style Class="headline-large" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="32"/>
</Style>
<Style Class="headline-medium" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="28"/>
</Style>
<Style Class="headline-small" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="24"/>
</Style>
<Style Class="title-large" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="22"/>
</Style>
<Style Class="title-medium" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontMedium}" />
<Setter Property="FontSize" Value="16"/>
</Style>
<Style Class="title-small" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontMedium}" />
<Setter Property="FontSize" Value="14"/>
</Style>
<Style Class="label-large" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontMedium}" />
<Setter Property="FontSize" Value="14"/>
</Style>
<Style Class="label-medium" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontMedium}" />
<Setter Property="FontSize" Value="12"/>
</Style>
<Style Class="label-small" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontMedium}" />
<Setter Property="FontSize" Value="11"/>
</Style>
<Style Class="body-large" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="16"/>
</Style>
<Style Class="body-medium" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="14"/>
</Style>
<Style Class="body-small" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="12"/>
</Style>
<Style Class="bold-italic" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontBoldItalic}" />
</Style>
<Style Class="bold" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontBold}" />
</Style>
<Style Class="italic" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontItalic}" />
</Style>
<Style Class="light" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontLight}" />
</Style>
<Style Class="light-italic" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontLightItalic}" />
</Style>
<Style Class="medium-italic" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontMediumItalic}" />
</Style>
<Style Class="semibold-italic" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontSemiBoldItalic}" />
</Style>
<Style Class="semibold" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource FontSemiBold}" />
</Style>
<Style TargetType="Button">
<Setter Property="FontFamily" Value="{StaticResource FontMedium}" />
<Setter Property="FontSize" Value="14"/>
</Style>
<Style TargetType="DatePicker">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="16"/>
</Style>
<Style TargetType="Picker">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="16"/>
</Style>
<Style TargetType="TimePicker">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="16"/>
</Style>
<Style TargetType="Editor">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="16"/>
</Style>
<Style TargetType="Entry">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="16"/>
</Style>
<Style TargetType="SearchBar">
<Setter Property="FontFamily" Value="{StaticResource FontRegular}" />
<Setter Property="FontSize" Value="16"/>
</Style>
</ResourceDictionary>
@vhugogarcia
Copy link
Author

The following XAML contains the font resources set for labels and other components for Material Design 3. It is following the official Material design 3 typography guidelines found here: https://m3.material.io/styles/typography/overview

  • Feel free to add/edit/remove the font names outlined here for the ones you prefer to use on your application only.
  • The font sizes are set based on the Material design guidelines, however, feel free to change them as well as needed.
  • The purpose of this code is to help integrate into your app the styling required for the fonts used on the mobile app following Google's Material Design 3.

Any feedback is always welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment