Skip to content

Theme System

Miuix provides a complete theme system that allows you to easily maintain a consistent design style throughout your application. The theme system consists of color schemes and text styles.

Using MiuixTheme

Use ThemeController to control the color scheme mode, then wrap your content with MiuixTheme:

kotlin
@Composable
fun App() {
    // Available modes: System, Light, Dark, MonetSystem, MonetLight, MonetDark
    val controller = remember { ThemeController(ColorSchemeMode.System) }
    MiuixTheme(controller = controller) { /* Content */ }
}

ColorSchemeMode.System / ColorSchemeMode.MonetSystem automatically follows the system's dark mode.

Specific Modes

  • Dynamic Colors (Monet)

    Use ThemeController with Monet modes to enable dynamic colors.

    • If keyColor is provided, colors are generated from this seed color.
    • If keyColor is null (default), it attempts to use the system's wallpaper colors (Android "Material You").
    kotlin
    @Composable
    fun AppWithMonet() {
        val controller = remember {
            ThemeController(
                ColorSchemeMode.MonetSystem, // or MonetLight, MonetDark
                // keyColor = Color(0xFF3482FF) // Optional: Custom seed color
            )
        }
        MiuixTheme(controller = controller) { /* Content */ }
    }
  • Palette Style and Color Spec

    You can customize the palette style and color specification used by Monet color generation via paletteStyle and colorSpec:

    kotlin
    val controller = remember {
        ThemeController(
            ColorSchemeMode.MonetSystem,
            keyColor = Color(0xFF3482FF),
            paletteStyle = ThemePaletteStyle.Vibrant,
            colorSpec = ThemeColorSpec.Spec2025
        )
    }
    MiuixTheme(controller = controller) { /* Content */ }

    TIP

    ThemeColorSpec.Spec2025 is only supported by TonalSpot, Neutral, Vibrant, and Expressive palette styles. For other styles, it gracefully falls back to Spec2021.

  • Manual Dark Mode Control

    Use the isDark parameter to explicitly control the dark state, overriding the system setting.

    kotlin
    val controller = remember {
        ThemeController(
            ColorSchemeMode.System,
            isDark = true // Force dark mode
        )
    }
  • Custom Color Schemes

    You can provide custom lightColors and darkColors directly to the ThemeController.

    kotlin
    val controller = remember {
        ThemeController(
            ColorSchemeMode.System,
            lightColors = myLightColors,
            darkColors = myDarkColors
        )
    }
  • Smooth Rounding

    By default, Miuix uses G2-continuity smooth rounded corners (squircle) for all components. Set smoothRounding = false to fall back to standard RoundedCornerShape for better HWUI rendering performance on lower-end devices:

    kotlin
    MiuixTheme(
        controller = controller,
        smoothRounding = false // Disable G2-continuity corners
    ) { /* Content */ }
  • Direct Usage

    Provide a color scheme directly to MiuixTheme(colors = ...) for full customization without a controller:

    kotlin
    @Composable
    fun AppWithColors() {
        val colors = lightColorScheme() // or darkColorScheme()
        MiuixTheme(colors = colors) { /* Content */ }
    }

ThemeController

The ThemeController manages the current color scheme of the Miuix theme.

ThemeController Properties

Property NameTypeDescriptionDefault Value
colorSchemeModeColorSchemeModeThe color scheme modeColorSchemeMode.System
lightColorsColorsLight color schemelightColorScheme()
darkColorsColorsDark color schemedarkColorScheme()
keyColorColor?Seed color for dynamic color generation. null uses system wallpaper colorsnull
colorSpecThemeColorSpecMaterial color specification versionThemeColorSpec.Spec2021
paletteStyleThemePaletteStylePalette style for dynamic color generationThemePaletteStyle.TonalSpot
isDarkBoolean?Override system dark mode. null follows systemnull

ColorSchemeMode

ValueDescription
SystemFollows system light/dark setting
LightForces light mode
DarkForces dark mode
MonetSystemDynamic colors, follows system light/dark
MonetLightDynamic colors, forces light mode
MonetDarkDynamic colors, forces dark mode

ThemePaletteStyle

ValueSpec2025 SupportDescription
TonalSpotYesDefault Material You style with balanced tonal variations
NeutralYesMuted, low-chroma palette
VibrantYesHigh-chroma, vivid palette
ExpressiveYesBold and artistic palette with creative color shifts
RainbowNoBroad spectrum of hues
FruitSaladNoPlayful, multi-hue palette
MonochromeNoSingle-hue grayscale palette
FidelityNoClosely matches the seed color
ContentNoDerived from content colors for maximum accuracy

ThemeColorSpec

ValueDescription
Spec2021Original Material Design 3 color specification
Spec2025Updated 2025 color specification (only supported by TonalSpot, Neutral, Vibrant, Expressive)

MiuixTheme Object

Access the current theme values through the MiuixTheme object:

kotlin
val colors = MiuixTheme.colorScheme
val textStyles = MiuixTheme.textStyles
val mode = MiuixTheme.colorSchemeMode
val isDynamic = MiuixTheme.isDynamicColor
PropertyTypeDescription
colorSchemeColorsCurrent color scheme
textStylesTextStylesCurrent text styles
colorSchemeModeColorSchemeMode?Current color scheme mode (null if using direct colors overload)
smoothRoundingBooleanWhether G2-continuity smooth rounding is enabled
isDynamicColorBooleanWhether the current mode is a Monet dynamic color mode

Customizing the Theme

You can customize the theme in the following ways:

  • Select a color scheme mode via ThemeController(ColorSchemeMode.*).
  • Opt into dynamic colors via MonetSystem / MonetLight / MonetDark.
  • Choose a palette style via paletteStyle and a color spec via colorSpec.
  • Override text styles by passing textStyles:
kotlin
val customTextStyles = defaultTextStyles(
    title1 = TextStyle(
        fontSize = 36.sp,
        fontWeight = FontWeight.Bold
    ),
    // Other text styles...
)

val controller = remember { ThemeController(ColorSchemeMode.Light) }
MiuixTheme(
    controller = controller,
    textStyles = customTextStyles
) {
    // Your application content
}

Follow System Dark Mode

Following the system's dark mode is built-in. Use ColorSchemeMode.System:

kotlin
@Composable
fun MyApp() {
    val controller = remember { ThemeController(ColorSchemeMode.System) }
    MiuixTheme(controller = controller) {
        // Application content
    }
}

Changelog

Released under the Apache-2.0 License