📖
AppKickstarter docs
  • Get Started
    • Get started
    • Initialize third parties
    • Project organization
    • Application initialization
  • Tech things
    • Multi modules Architecture
    • Dependency injection
    • Library management
    • Secrets and Build Config
    • Backend as an implementation detail
  • Tutorials
    • Add a login page
    • Add a screen with tab bars
    • Add a settings screen
    • Display an In-App Changelog for a new published version
    • Update localizations
    • Update theme
    • Customize onboarding
    • Setup your paywall
    • Setup your first notifications
    • Format dates and save on database
    • Using a Different Backend Instead of Firebase
    • Make an infinite list with pagination
  • Features
    • Onboarding
    • Authentication
    • Firebase support
    • Offline support
    • Monetization
    • Whats new feature
    • Navigation in AppKickstarter
    • Theme
    • UI Kit
    • Dates management
    • Platform specific
    • Offline cache
    • Translations
    • Analytics
    • User management
    • Logger
    • Platform utilities
    • Maps and locations
    • Secured AI Backend Proxy
    • Settings
    • Application monitoring
    • Notifications
  • UI Kit
    • Adaptive
    • Advanced Components
    • Animated Components
    • Badges
    • Buttons
    • Cards
    • Containers
    • Dialogs
    • EmptyStates
    • Icons
    • Images
    • Lists
    • Modals
    • Tabs
    • Texts
    • Text fields
    • Toasts
    • Toggles
  • Other
    • Known issues
Powered by GitBook
On this page
  • Using Custom Fonts in KMP (Compose Multiplatform)
  • Change colors

Was this helpful?

  1. Tutorials

Update theme

PreviousUpdate localizationsNextCustomize onboarding

Last updated 1 year ago

Was this helpful?

Using Custom Fonts in KMP (Compose Multiplatform)

Place your new font files in the appropriate resources module in commonMain/resources/MR/fonts directory within your project.

For example, if you're using the Inter font family, you might have various font weights (e.g., Regular, Medium, Bold) stored as .ttf files in the resources/fonts directory.

Accessing Fonts with Resource Identifiers

Resource identifiers for fonts are automatically generated by the build system. To use a font in your custom typography, you access it through a fontFamilyResource function, specifying the path to the font resource. Here's an example of accessing the Inter Regular font:

val InterRegular: FontFamily = fontFamilyResource(SharedRes.fonts.Inter.regular)

This line of code creates a FontFamily instance for the Inter Regular font by referencing its resource identifier, which is resolved at compile time through SharedRes.fonts.Inter.regular.

You can specifically call the gradle task to generate all the resources identifiers via : ./gradle generateMRCommonMain

Defining Custom Typography

With your FontFamily instances ready, you can define a custom typography set that utilizes these fonts. The CustomTypography class allows you to specify text styles for different UI elements, such as labels, titles, and body text. Each style can be customized with attributes like fontFamily, fontWeight, fontSize, and more.

Here's how you can use the new Inter Regular font to all your labels in your app, update customTypography in the KickstarterTheme function:

val customTypography = CustomTypography(
    label = TextStyle(
        fontFamily = InterRegular,
        fontWeight = FontWeight.Medium,
        fontSize = 15.sp, 
    ),
    // Define other text styles as needed
)

Change colors

The fastest way to change the default colors is to update AppKickstarterColors to your needs:

val AppKickstarterColors: (Boolean) -> CustomColors = { useDarkTheme ->
    if (useDarkTheme) {
        CustomColors(
            background = Color(0XFF14121d),
            cardBackground = Color(0XFF241e34),
            sheetBackground = Color(0XFF432f5d),
            ...
        )
    }
}

But if you want to build a proper design system with all your own typography, colors, and dimensions then you will find more informations on .

this page
Using Custom Fonts in KMP (Compose Multiplatform)