### Navigation Drawer Setup in Material 2 Scaffold Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Illustrates the parameters for configuring a navigation drawer directly within the Material 2 Scaffold. ```kotlin import androidx.compose.material.DrawerValue import androidx.compose.material.Scaffold import androidx.compose.material.rememberDrawerState import androidx.compose.material.rememberScaffoldState val scaffoldState = rememberScaffoldState( drawerState = rememberDrawerState(DrawerValue.Closed) ) val scope = rememberCoroutineScope() Scaffold( scaffoldState = scaffoldState, drawerContent = { … }, drawerGesturesEnabled = …, drawerShape = …, drawerElevation = …, drawerBackgroundColor = …, drawerContentColor = …, drawerScrimColor = …, content = { … scope.launch { scaffoldState.drawerState.open() } } ) ``` -------------------------------- ### Navigation Drawer Setup in Material 3 using ModalNavigationDrawer Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Demonstrates how to implement a navigation drawer in Material 3 using the `ModalNavigationDrawer` composable, separate from the `Scaffold`. ```kotlin import androidx.compose.material3.DrawerValue import androidx.compose.material3.ModalDrawerSheet import androidx.compose.material3.ModalNavigationDrawer import androidx.compose.material3.Scaffold import androidx.compose.material3.rememberDrawerState val drawerState = rememberDrawerState(DrawerValue.Closed) val scope = rememberCoroutineScope() ModalNavigationDrawer( drawerState = drawerState, drawerContent = { ModalDrawerSheet( drawerShape = …, drawerTonalElevation = …, drawerContainerColor = …, drawerContentColor = …, content = { … } ) }, gesturesEnabled = …, scrimColor = …, content = { Scaffold( content = { … scope.launch { drawerState.open() } } ) } ) ``` -------------------------------- ### M3 Color Scheme Example Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Shows the M3 approach to theming, using `lightColorScheme` and `darkColorScheme`, and managing UI element properties like card elevation via `CompositionLocalProvider`. ```kotlin import androidx.compose.material3.lightColorScheme import androidx.compose.material3.darkColorScheme import androidx.compose.material3.MaterialTheme val LocalCardElevation = staticCompositionLocalOf { Dp.Unspecified } @Composable private fun AppTheme( darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit ) { val cardElevation = if (darkTheme) 4.dp else 0.dp CompositionLocalProvider(LocalCardElevation provides cardElevation) { val colorScheme = if (darkTheme) darkColorScheme(…) else lightColorScheme(…) MaterialTheme( colorScheme = colorScheme, content = content ) } } @Composable fun AppComposable() { AppTheme { val cardElevation = LocalCardElevation.current … } } ``` -------------------------------- ### M2 Color Scheme Example Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Demonstrates how to use the `isLight` property with M2 `MaterialTheme.colors` to determine light or dark theme for UI elements like card elevation. ```kotlin import androidx.compose.material.lightColors import androidx.compose.material.darkColors import androidx.compose.material.MaterialTheme @Composable private fun AppTheme( darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit ) { val colors = if (darkTheme) darkColors(…) else lightColors(…) MaterialTheme( colors = colors, content = content ) } @Composable fun AppComposable() { AppTheme { val cardElevation = if (MaterialTheme.colors.isLight) 0.dp else 4.dp … } } ``` -------------------------------- ### Setup Light and Dark Color Schemes Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Sets up the light and dark color schemes and the app theme using generated color roles. It includes a composable function to switch between themes based on system settings. ```kotlin private val LightColorScheme = lightColorScheme( primary = md_theme_light_primary, onPrimary = md_theme_light_onPrimary, primaryContainer = md_theme_light_primaryContainer, // .. ) private val DarkColorScheme = darkColorScheme( primary = md_theme_dark_primary, onPrimary = md_theme_dark_onPrimary, primaryContainer = md_theme_dark_primaryContainer, // .. ) @Composable fun ReplyTheme( darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit ) { val colorScheme = if (!darkTheme) { LightColorScheme } else { DarkColorScheme } MaterialTheme( colorScheme = colorScheme, content = content ) } ``` -------------------------------- ### Dynamic Color Scheme Setup Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Conditionally sets up a dynamic color scheme for Android 12+ or falls back to a custom light/dark color scheme. Requires checking the Android version and theme settings. ```kotlin // Dynamic color is available on Android 12+ val dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S val colors = when { dynamicColor && darkTheme -> dynamicDarkColorScheme(LocalContext.current) dynamicColor && !darkTheme -> dynamicLightColorScheme(LocalContext.current) darkTheme -> DarkColorScheme else -> LightColorScheme } ``` -------------------------------- ### M2 Badge with Background Color Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Example of a Badge composable in Material Design 2 using the 'backgroundColor' parameter. ```kotlin Badge( backgroundColor = MaterialTheme.colors.primary ) { … } ``` -------------------------------- ### M2 Surface Composable Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Example of using the Surface composable in Material Design 2, which uses an 'elevation' parameter. ```kotlin import androidx.compose.material.Surface Surface( elevation = … ) { … } ``` -------------------------------- ### M3 Surface Composable with Shadow and Tonal Elevation Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Example of using the Surface composable in Material Design 3, which supports both 'shadowElevation' and 'tonalElevation'. ```kotlin import androidx.compose.material3.Surface Surface( shadowElevation = …, tonalElevation = … ) { … } ``` -------------------------------- ### M3 Badge with Container Color Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Example of a Badge composable in Material Design 3, using the 'containerColor' parameter instead of 'backgroundColor'. ```kotlin Badge( containerColor = MaterialTheme.colorScheme.primary ) { … } ``` -------------------------------- ### Use Custom Typography and Shapes in Components Source: https://developer.android.com/develop/ui/compose/designsystems/custom Wrap Material components in custom composables to apply replacement theme values. This example demonstrates applying custom shapes and typography to a button. ```kotlin import androidx.compose.foundation.layout.RowScope import androidx.compose.material3.Button import androidx.compose.material3.ProvideTextStyle import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @Composable fun ReplacementButton( onClick: () -> Unit, modifier: Modifier = Modifier, content: @Composable RowScope.() -> Unit ) { Button( shape = ReplacementTheme.shapes.component, onClick = onClick, modifier = modifier, content = { ProvideTextStyle( value = ReplacementTheme.typography.body ) { content() } } ) } // CustomDesignSystem.kt ``` ```kotlin import androidx.compose.runtime.Composable @Composable fun ReplacementApp() { ReplacementTheme { // Assuming ReplacementTheme provides custom typography and shapes /*...*/ ReplacementButton(onClick = { /* ... */ }) { /* ... */ } } } // CustomDesignSystem.kt ``` -------------------------------- ### M2 Typography Definition Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Defines custom typography using the M2 `Typography` class. This example shows the import and instantiation of the M2 Typography object. ```kotlin import androidx.compose.material.Typography val AppTypography = Typography( // M2 TextStyle parameters ) ``` -------------------------------- ### M3 Typography Definition Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Defines custom typography using the M3 `Typography` class. This example shows the import and instantiation of the M3 Typography object. ```kotlin import androidx.compose.material3.Typography val AppTypography = Typography( // M3 TextStyle parameters ) ``` -------------------------------- ### Implement Dark Theme Source: https://developer.android.com/develop/ui/compose/designsystems/material Provide different sets of Colors to the MaterialTheme composable to implement light and dark themes. Query the device theme setting to get the default value for darkTheme. ```kotlin @Composable fun MyTheme( darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit ) { MaterialTheme( colors = if (darkTheme) DarkColors else LightColors, /*...*/ content = content ) } ``` -------------------------------- ### Add Material 3 Dependency Source: https://developer.android.com/develop/ui/compose/designsystems/material3 To start using Material 3 in your Compose app, add the Compose Material 3 dependency to your build.gradle files. This is the primary step to enable M3 features. ```gradle implementation "androidx.compose.material3:material3:$material3_version" ``` -------------------------------- ### M3 Shapes Definition Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Defines custom shapes using the M3 `Shapes` class. This example shows the import and instantiation of the M3 Shapes object. ```kotlin import androidx.compose.material3.Shapes val AppShapes = Shapes( // M3 Shape parameters ) ``` -------------------------------- ### Extend MaterialTheme with Custom Colors Source: https://developer.android.com/develop/ui/compose/designsystems/custom Wrap Material components in custom composables to use extended MaterialTheme values. This example shows how to customize button colors while retaining other MaterialTheme defaults. ```kotlin import androidx.compose.foundation.layout.RowScope import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @Composable fun ExtendedButton( onClick: () -> Unit, modifier: Modifier = Modifier, content: @Composable RowScope.() -> Unit ) { Button( colors = ButtonDefaults.buttonColors( containerColor = ExtendedTheme.colors.caution, contentColor = ExtendedTheme.colors.onCaution /* Other colors use values from MaterialTheme */ ), onClick = onClick, modifier = modifier, content = content ) } // CustomDesignSystem.kt ``` ```kotlin import androidx.compose.runtime.Composable @Composable fun ExtendedApp() { ExtendedTheme { // Assuming ExtendedTheme provides ExtendedTheme.colors /*...*/ ExtendedButton(onClick = { /* ... */ }) { /* ... */ } } } // CustomDesignSystem.kt ``` -------------------------------- ### M2 Shapes Definition Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Defines custom shapes using the M2 `Shapes` class. This example shows the import and instantiation of the M2 Shapes object. ```kotlin import androidx.compose.material.Shapes val AppShapes = Shapes( // M2 Shape parameters ) ``` -------------------------------- ### Theme System Composition Locals Source: https://developer.android.com/develop/ui/compose/designsystems/anatomy Provide theme system classes as CompositionLocal instances for static referencing in composables. Use staticCompositionLocalOf with a default factory for fallback values. ```kotlin val LocalColorSystem = staticCompositionLocalOf { ColorSystem( color = Color.Unspecified, gradient = emptyList() ) } val LocalTypographySystem = staticCompositionLocalOf { TypographySystem( fontFamily = FontFamily.Default, textStyle = TextStyle.Default ) } val LocalCustomSystem = staticCompositionLocalOf { CustomSystem( value1 = 0, value2 = "" ) } /* ... */ ``` -------------------------------- ### Opt into Experimental Material 3 APIs Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Use the `@OptIn(ExperimentalMaterial3Api::class)` annotation to enable experimental Material 3 APIs within a composable function or file. ```kotlin import androidx.compose.material3.ExperimentalMaterial3Api @OptIn(ExperimentalMaterial3Api::class) @Composable fun AppComposable() { // M3 composables } ``` -------------------------------- ### Using Container and On-Container Colors Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Illustrates using `primaryContainer` and `onPrimaryContainer` colors for emphasis on selected items within a Card component. This highlights how to contrast colors for UI elements. ```kotlin Card( colors = CardDefaults.cardColors( containerColor = if (isSelected) MaterialTheme.colorScheme.primaryContainer else MaterialTheme.colorScheme.surfaceVariant ) ) { Text( text = "Dinner club", style = MaterialTheme.typography.bodyLarge, color = if (isSelected) MaterialTheme.colorScheme.onPrimaryContainer else MaterialTheme.colorScheme.onSurface, ) } ``` -------------------------------- ### Accessing Theme Colors Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Demonstrates how to access theme colors, such as the primary color, using `MaterialTheme.colorScheme` for UI elements like Text. ```kotlin Text( text = "Hello theming", color = MaterialTheme.colorScheme.primary ) ``` -------------------------------- ### Top App Bar Import Difference (M2 vs M3) Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Illustrates the different import paths for the TopAppBar composable between Material Design 2 and Material Design 3. ```kotlin import androidx.compose.material.TopAppBar TopAppBar(…) ``` ```kotlin import androidx.compose.material3.TopAppBar TopAppBar(…) ``` -------------------------------- ### Opt-in to Experimental APIs Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Some M3 APIs are considered experimental. You need to opt in at the function or file level using the ExperimentalMaterial3Api annotation to use them. ```kotlin // import androidx.compose.material3.ExperimentalMaterial3Api @Composable fun AppComposable() { // M3 composables } ``` -------------------------------- ### Material Theme M2 Configuration Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Configure the Material 2 `MaterialTheme` composable using colors, typography, and shapes. ```kotlin import androidx.compose.material.MaterialTheme MaterialTheme( colors = AppColors, typography = AppTypography, shapes = AppShapes ) { // M2 content } ``` -------------------------------- ### M3 Text Emphasis using FontWeight and LocalContentColor Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Demonstrates emphasis for text in Material Design 3 using FontWeight for high and medium emphasis, and LocalContentColor for disabled emphasis. ```kotlin import androidx.compose.material3.LocalContentColor // High emphasis Text( …, fontWeight = FontWeight.Bold ) // Medium emphasis Text( …, fontWeight = FontWeight.Normal ) // Disabled emphasis CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)) { Text( …, fontWeight = FontWeight.Normal ) } ``` -------------------------------- ### Navigation Bar for Compact Devices Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Implements a NavigationBar for compact devices, supporting up to 5 destinations. Use for primary navigation on small screens. ```kotlin NavigationBar(modifier = Modifier.fillMaxWidth()) { Destinations.entries.forEach { replyDestination -> NavigationBarItem( selected = selectedDestination == replyDestination, onClick = { }, icon = { } ) } } ``` -------------------------------- ### Top App Bar Elevation Handling (M2 vs M3) Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Compares how elevation is handled in M2 TopAppBar using manual state checks versus M3 TopAppBar using the scrollBehavior parameter. ```kotlin import androidx.compose.material.AppBarDefaults import androidx.compose.material.Scaffold import androidx.compose.material.TopAppBar val state = rememberLazyListState() val isAtTop by remember { derivedStateOf { state.firstVisibleItemIndex == 0 && state.firstVisibleItemScrollOffset == 0 } } Scaffold( topBar = { TopAppBar( elevation = if (isAtTop) { 0.dp } else { AppBarDefaults.TopAppBarElevation }, … ) }, content = { LazyColumn(state = state) { … } } ) ``` ```kotlin import androidx.compose.material3.Scaffold import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarDefaults val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() Scaffold( modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), topBar = { TopAppBar( scrollBehavior = scrollBehavior, … ) }, content = { LazyColumn { … } } ) ``` -------------------------------- ### Create CompositionLocal Providers Source: https://developer.android.com/develop/ui/compose/designsystems/custom Create CompositionLocal providers for each custom theme attribute. These allow descendant composables to access the theme values. ```kotlin val LocalCustomColors = staticCompositionLocalOf { CustomColors( content = Color.Unspecified, component = Color.Unspecified, background = emptyList() ) } val LocalCustomTypography = staticCompositionLocalOf { CustomTypography( body = TextStyle.Default, title = TextStyle.Default ) } val LocalCustomElevation = staticCompositionLocalOf { CustomElevation( default = Dp.Unspecified, pressed = Dp.Unspecified ) } ``` -------------------------------- ### Use Theme Typography Styles Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Access and apply typography styles defined in the MaterialTheme using MaterialTheme.typography. ```kotlin Text( text = "Hello M3 theming", style = MaterialTheme.typography.titleLarge ) Text( text = "you are learning typography", style = MaterialTheme.typography.bodyMedium ) ``` -------------------------------- ### M2 Text Emphasis using ContentAlpha Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Illustrates applying high, medium, and disabled emphasis to text in Material Design 2 using ContentAlpha and LocalContentAlpha. ```kotlin import androidx.compose.material.ContentAlpha import androidx.compose.material.LocalContentAlpha // High emphasis CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.high) { Text(…) } // Medium emphasis CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { Text(…) } // Disabled emphasis CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.disabled) { Text(…) } ``` -------------------------------- ### Snackbar Handling in Material 2 Scaffold Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Demonstrates how to show a snackbar using `rememberScaffoldState` and `snackbarHostState` in Material 2. ```kotlin import androidx.compose.material.Scaffold import androidx.compose.material.rememberScaffoldState val scaffoldState = rememberScaffoldState() val scope = rememberCoroutineScope() Scaffold( scaffoldState = scaffoldState, content = { … scope.launch { scaffoldState.snackbarHostState.showSnackbar(…) } } ) ``` -------------------------------- ### Material Theme M3 Configuration Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Configure the Material 3 `MaterialTheme` composable using colorScheme, typography, and shapes. ```kotlin import androidx.compose.material3.MaterialTheme MaterialTheme( colorScheme = AppColorScheme, typography = AppTypography, shapes = AppShapes ) { // M3 content } ``` -------------------------------- ### M2 Icon Emphasis using ContentAlpha Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Demonstrates how to apply high, medium, and disabled emphasis to icons in Material Design 2 using ContentAlpha and LocalContentAlpha. ```kotlin import androidx.compose.material.ContentAlpha import androidx.compose.material.LocalContentAlpha // High emphasis CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.high) { Icon(…) } // Medium emphasis CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { Icon(…) } // Disabled emphasis CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.disabled) { Icon(…) } ``` -------------------------------- ### Snackbar Handling in Material 3 Scaffold Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Shows how to display snackbars in Material 3 using `SnackbarHostState` and `SnackbarHost` within the Scaffold. ```kotlin import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState val snackbarHostState = remember { SnackbarHostState() } val scope = rememberCoroutineScope() Scaffold( snackbarHost = { SnackbarHost(snackbarHostState) }, content = { … scope.launch { snackbarHostState.showSnackbar(…) } } ) ``` -------------------------------- ### Compose Theme Function with CompositionLocalProvider Source: https://developer.android.com/develop/ui/compose/designsystems/anatomy The Theme function constructs theme system CompositionLocals using real values and provides them to the composition tree via CompositionLocalProvider. It accepts a content lambda for nested composables. ```kotlin @Composable fun Theme( /* ... */ content: @Composable () -> Unit ) { val colorSystem = ColorSystem( color = Color(0xFF3DDC84), gradient = listOf(Color.White, Color(0xFFD7EFFF)) ) val typographySystem = TypographySystem( fontFamily = FontFamily.Monospace, textStyle = TextStyle(fontSize = 18.sp) ) val customSystem = CustomSystem( value1 = 1000, value2 = "Custom system" ) /* ... */ CompositionLocalProvider( LocalColorSystem provides colorSystem, LocalTypographySystem provides typographySystem, LocalCustomSystem provides customSystem, /* ... */ content = content ) } ``` -------------------------------- ### Set up MaterialTheme in Compose Source: https://developer.android.com/develop/ui/compose/designsystems/material Configure the MaterialTheme composable with color, typography, and shape attributes to theme your application. This is the root composable for applying Material Design theming. ```kotlin MaterialTheme( colors = // ... typography = // ... shapes = // ... ) { // app content } Material2Snippets.kt ``` -------------------------------- ### Create Material Design Color Palettes Source: https://developer.android.com/develop/ui/compose/designsystems/material Use the `darkColors` and `lightColors` builder functions from the `Colors` class to create distinct color sets for light and dark themes. Define primary, secondary, and variant colors. ```kotlin private val Yellow200 = Color(0xffffeb46) private val Blue200 = Color(0xff91a4fc) // ... private val DarkColors = darkColors( primary = Yellow200, secondary = Blue200, // ... ) private val LightColors = lightColors( primary = Yellow500, primaryVariant = Yellow400, secondary = Blue700, // ... ) Material2Snippets.kt ``` -------------------------------- ### Implement Custom Theme Composable Source: https://developer.android.com/develop/ui/compose/designsystems/custom Create a Composable function that defines and provides the custom theme values using CompositionLocalProvider. This function wraps the content that should use the custom theme. ```kotlin @Composable fun CustomTheme( /* ... */ content: @Composable () -> Unit ) { val customColors = CustomColors( content = Color(0xFFDD0D3C), component = Color(0xFFC20029), background = listOf(Color.White, Color(0xFFF8BBD0)) ) val customTypography = CustomTypography( body = TextStyle(fontSize = 16.sp), title = TextStyle(fontSize = 32.sp) ) val customElevation = CustomElevation( default = 4.dp, pressed = 8.dp ) CompositionLocalProvider( LocalCustomColors provides customColors, LocalCustomTypography provides customTypography, LocalCustomElevation provides customElevation, content = content ) } ``` -------------------------------- ### M3 Icon Emphasis using LocalContentColor Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Shows how to achieve high, medium, and disabled emphasis for icons in Material Design 3 using LocalContentColor and color scheme properties. ```kotlin import androidx.compose.material3.LocalContentColor // High emphasis CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) { Icon(…) } // Medium emphasis CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurfaceVariant) { Icon(…) } // Disabled emphasis CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)) { Icon(…) } ``` -------------------------------- ### Compose Theme Structure Source: https://developer.android.com/develop/ui/compose/designsystems/migrate-xml-theme-to-compose The `Theme.Material3.*` in XML corresponds to the `MaterialTheme` composable in Compose, which accepts `colorScheme`, `typography`, and `shapes` as parameters. ```kotlin MaterialTheme(colorScheme, typography, shapes) { } ``` -------------------------------- ### Scaffold Background Color Parameter: M2 vs M3 Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Illustrates the change in the background color parameter from `backgroundColor` in Material 2 to `containerColor` in Material 3. ```kotlin import androidx.compose.material.Scaffold Scaffold( backgroundColor = …, content = { … } ) ``` ```kotlin import androidx.compose.material3.Scaffold Scaffold( containerColor = …, content = { … } ) ``` -------------------------------- ### Importing Scaffold in Material 3 Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Shows the import statement for the Material 3 Scaffold composable. ```kotlin import androidx.compose.material3.Scaffold Scaffold( // M3 scaffold parameters ) ``` -------------------------------- ### Compose TopAppBar Colors Mapping Source: https://developer.android.com/develop/ui/compose/designsystems/migrate-xml-theme-to-compose The `Widget.*.Toolbar.Primary` style in XML is equivalent to `TopAppBar` in Compose, with its colors configured using `TopAppBarDefaults.topAppBarColors()`. ```kotlin TopAppBar(colors = TopAppBarDefaults.topAppBarColors(...)) ``` -------------------------------- ### Switch Component Import Difference (M2 vs M3) Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Highlights the different import paths for the Switch composable between Material Design 2 and Material Design 3. ```kotlin import androidx.compose.material.Switch Switch(…) ``` ```kotlin import androidx.compose.material3.Switch Switch(…) ``` -------------------------------- ### Apply Material Theme Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Jetpack Compose implements M3 theming concepts with the MaterialTheme composable. Apply your custom color scheme, typography, and shapes to theme your application content. ```kotlin MaterialTheme( colorScheme = /* ... typography = /* ... shapes = /* ... ) { // M3 app content } ``` -------------------------------- ### Button Accessibility Contrast Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Demonstrates correct and incorrect usage of container and content colors for Material 3 Buttons to ensure sufficient contrast ratios for accessibility. ```kotlin // ✅ Button with sufficient contrast ratio Button( onClick = { }, colors = ButtonDefaults.buttonColors( containerColor = MaterialTheme.colorScheme.primary, contentColor = MaterialTheme.colorScheme.onPrimary ) ) { } // ❌ Button with poor contrast ratio Button( onClick = { }, colors = ButtonDefaults.buttonColors( containerColor = MaterialTheme.colorScheme.tertiaryContainer, contentColor = MaterialTheme.colorScheme.primaryContainer ) ) { } ``` -------------------------------- ### Use Primary Surface Color Accent Source: https://developer.android.com/develop/ui/compose/designsystems/material Use the primarySurface extension property for custom scenarios to switch between primary in light themes and surface in dark themes. ```kotlin Surface( // Switches between primary in light theme and surface in dark theme color = MaterialTheme.colors.primarySurface, /*...*/ ) { /*...*/ } ``` -------------------------------- ### Importing Scaffold in Material 2 Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Shows the import statement for the Material 2 Scaffold composable. ```kotlin import androidx.compose.material.Scaffold Scaffold( // M2 scaffold parameters ) ``` -------------------------------- ### Apply Custom Elevation Overlays Source: https://developer.android.com/develop/ui/compose/designsystems/material For custom scenarios, use LocalElevationOverlay to apply overlays manually. This is useful when not using the Surface composable. ```kotlin // Elevation overlays // Implemented in Surface (and any components that use it) val color = MaterialTheme.colors.surface val elevation = 4.dp val overlaidColor = LocalElevationOverlay.current?.apply( color, elevation ) ``` -------------------------------- ### Bottom Navigation vs. Navigation Bar (M2 vs M3) Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Shows the renaming of bottom navigation components from BottomNavigation/BottomNavigationItem in M2 to NavigationBar/NavigationBarItem in M3. ```kotlin import androidx.compose.material.BottomNavigation import androidx.compose.material.BottomNavigationItem BottomNavigation { BottomNavigationItem(…) BottomNavigationItem(…) BottomNavigationItem(…) } ``` ```kotlin import androidx.compose.material3.NavigationBar import androidx.compose.material3.NavigationBarItem NavigationBar { NavigationBarItem(…) NavigationBarItem(…) NavigationBarItem(…) } ``` -------------------------------- ### Basic Material 3 Button Source: https://developer.android.com/develop/ui/compose/designsystems/material3 A standard Material 3 button for general use. Implement with a click handler and text content. ```kotlin Button(onClick = { /*..*/ }) { Text(text = "My Button") } ``` -------------------------------- ### Convenience Theme Object for Accessing Locals Source: https://developer.android.com/develop/ui/compose/designsystems/anatomy An object named 'Theme' provides convenient, composable access to the current values of theme system CompositionLocals via '.current'. ```kotlin // Use with eg. Theme.colorSystem.color object Theme { val colorSystem: ColorSystem @Composable get() = LocalColorSystem.current val typographySystem: TypographySystem @Composable get() = LocalTypographySystem.current val customSystem: CustomSystem @Composable get() = LocalCustomSystem.current /* ... */ } ``` -------------------------------- ### Button Components (M2 vs M3) Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Lists the common button, icon button, and FAB composables available in both Material Design 2 and Material Design 3. ```kotlin import androidx.compose.material.Button import androidx.compose.material.ExtendedFloatingActionButton import androidx.compose.material.FloatingActionButton import androidx.compose.material.IconButton import androidx.compose.material.IconToggleButton import androidx.compose.material.OutlinedButton import androidx.compose.material.TextButton // M2 buttons Button(…) OutlinedButton(…) TextButton(…) // M2 icon buttons IconButton(…) IconToggleButton(…) // M2 FABs FloatingActionButton(…) ExtendedFloatingActionButton(…) ``` ```kotlin import androidx.compose.material3.Button import androidx.compose.material3.ExtendedFloatingActionButton import androidx.compose.material3.FloatingActionButton import androidx.compose.material3.IconButton import androidx.compose.material3.IconToggleButton import androidx.compose.material3.OutlinedButton import androidx.compose.material3.TextButton // M3 buttons Button(…) OutlinedButton(…) TextButton(…) // M3 icon buttons IconButton(…) IconToggleButton(…) // M3 FABs FloatingActionButton(…) ExtendedFloatingActionButton(…) ``` -------------------------------- ### Define Custom Typography Source: https://developer.android.com/develop/ui/compose/designsystems/material Define a custom typography system using the Typography constructor, specifying font families and text styles. Apply it to MaterialTheme. ```kotlin val raleway = FontFamily( Font(R.font.raleway_regular), Font(R.font.raleway_medium, FontWeight.W500), Font(R.font.raleway_semibold, FontWeight.SemiBold) ) val myTypography = Typography( h1 = TextStyle( fontFamily = raleway, fontWeight = FontWeight.W300, fontSize = 96.sp ), body1 = TextStyle( fontFamily = raleway, fontWeight = FontWeight.W600, fontSize = 16.sp ) /*...*/ ) MaterialTheme(typography = myTypography, /*...*/) { /*...*/ } ``` -------------------------------- ### Create an Extended Theme Wrapper Source: https://developer.android.com/develop/ui/compose/designsystems/custom Define an extended theme that wraps MaterialTheme to introduce custom colors, typography, or shapes. This allows for multiple nested themes and maintains compatibility with MaterialTheme. ```kotlin @Immutable data class ExtendedColors( val caution: Color, val onCaution: Color ) val LocalExtendedColors = staticCompositionLocalOf { ExtendedColors( caution = Color.Unspecified, onCaution = Color.Unspecified ) } @Composable fun ExtendedTheme( /* ... */ content: @Composable () -> Unit ) { val extendedColors = ExtendedColors( caution = Color(0xFFFFCC02), onCaution = Color(0xFF2C2D30) ) CompositionLocalProvider(LocalExtendedColors provides extendedColors) { MaterialTheme( /* colors = ..., typography = ..., shapes = ... */ content = content ) } } object ExtendedTheme { val colors: ExtendedColors @Composable get() = LocalExtendedColors.current } ``` -------------------------------- ### Create a Custom Button Style Source: https://developer.android.com/develop/ui/compose/designsystems/material Wrap a Material Button in a custom composable to define default styles. This allows for consistent button appearance throughout your app. ```kotlin import androidx.compose.foundation.layout.RowScope import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @Composable fun MyButton( onClick: () -> Unit, modifier: Modifier = Modifier, content: @Composable RowScope.() -> Unit ) { Button( colors = ButtonDefaults.buttonColors( backgroundColor = MaterialTheme.colors.secondary ), onClick = onClick, modifier = modifier, content = content ) } ``` -------------------------------- ### Permanent Navigation Drawer Source: https://developer.android.com/develop/ui/compose/designsystems/material3 A permanent navigation drawer for medium-to-large tablets, providing persistent navigation options. Use when ample screen space is available. ```kotlin PermanentNavigationDrawer(modifier = Modifier.fillMaxHeight(), drawerContent = { Destinations.entries.forEach { replyDestination -> NavigationRailItem( selected = selectedDestination == replyDestination, onClick = { }, icon = { }, label = { } ) } }) { } ``` -------------------------------- ### Replace Material Typography and Shapes Source: https://developer.android.com/develop/ui/compose/designsystems/custom Define custom typography and shape data classes and provide them using CompositionLocalProvider. This allows replacing specific Material subsystems while keeping others, like colors, intact. ```kotlin import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Immutable import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Shape import androidx.compose.ui.text.TextStyle import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @Immutable data class ReplacementTypography( val body: TextStyle, val title: TextStyle ) @Immutable data class ReplacementShapes( val component: Shape, val surface: Shape ) val LocalReplacementTypography = staticCompositionLocalOf { ReplacementTypography( body = TextStyle.Default, title = TextStyle.Default ) } val LocalReplacementShapes = staticCompositionLocalOf { ReplacementShapes( component = RoundedCornerShape(0.dp), // Assuming ZeroCornerSize is 0.dp surface = RoundedCornerShape(0.dp) // Assuming ZeroCornerSize is 0.dp ) } @Composable fun ReplacementTheme( /* ... */ content: @Composable () -> Unit ) { val replacementTypography = ReplacementTypography( body = TextStyle(fontSize = 16.sp), title = TextStyle(fontSize = 32.sp) ) val replacementShapes = ReplacementShapes( component = RoundedCornerShape(percent = 50), surface = RoundedCornerShape(size = 40.dp) ) CompositionLocalProvider( LocalReplacementTypography provides replacementTypography, LocalReplacementShapes provides replacementShapes ) { MaterialTheme( /* colors = ... */ content = content ) } } // Use with eg. ReplacementTheme.typography.body object ReplacementTheme { val typography: ReplacementTypography @Composable get() = LocalReplacementTypography.current val shapes: ReplacementShapes @Composable get() = LocalReplacementShapes.current } // CustomDesignSystem.kt ``` -------------------------------- ### Apply Content Alpha for Emphasis Source: https://developer.android.com/develop/ui/compose/designsystems/material Use CompositionLocalProvider with LocalContentAlpha to de-emphasize content. Nested composables use this value to apply alpha treatment to their content. ```kotlin // By default, both Icon & Text use the combination of LocalContentColor & // LocalContentAlpha. De-emphasize content by setting content alpha CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { Text( // ... ) } CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.disabled) { Icon( // ... ) Text( // ... ) } ``` -------------------------------- ### Add Material 2 Dependency Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Include the Material 2 dependency for Compose projects. ```gradle implementation "androidx.compose.material:material:$m2-version" ``` -------------------------------- ### Access Custom Theme Values Source: https://developer.android.com/develop/ui/compose/designsystems/custom Define an object to easily access the current custom theme values from any composable. This provides a convenient way to retrieve colors, typography, and elevation. ```kotlin // Use with eg. CustomTheme.elevation.small object CustomTheme { val colors: CustomColors @Composable get() = LocalCustomColors.current val typography: CustomTypography @Composable get() = LocalCustomTypography.current val elevation: CustomElevation @Composable get() = LocalCustomElevation.current } ``` -------------------------------- ### Apply Theme Overlays with Nested MaterialTheme Source: https://developer.android.com/develop/ui/compose/designsystems/material Achieve theme overlays by nesting MaterialTheme composables. This allows different parts of your UI to inherit distinct theme properties. ```kotlin import androidx.compose.runtime.Composable @Composable fun DetailsScreen(/* ... */) { PinkTheme { // Assuming PinkTheme is a custom theme wrapper // other content RelatedSection() } } @Composable fun RelatedSection(/* ... */) { BlueTheme { // Assuming BlueTheme is a custom theme wrapper // content } } ``` -------------------------------- ### Immutable Theme System Classes Source: https://developer.android.com/develop/ui/compose/designsystems/anatomy Define immutable data classes for theme systems like colors, typography, and custom values. Annotate with @Immutable for compiler optimization. These classes group common visual and behavioral concepts. ```kotlin @Immutable data class ColorSystem( val color: Color, val gradient: List /* ... */ ) @Immutable data class TypographySystem( val fontFamily: FontFamily, val textStyle: TextStyle ) /* ... */ @Immutable data class CustomSystem( val value1: Int, val value2: String /* ... */ ) /* ... */ ``` -------------------------------- ### Add Material 3 Dependency Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Include the Material 3 dependency for Compose projects. ```gradle implementation "androidx.compose.material3:material3:$m3-version" ``` -------------------------------- ### Configure Button States with Custom Colors and Elevation Source: https://developer.android.com/develop/ui/compose/designsystems/material Customize the appearance of buttons in different states (enabled, disabled) by providing custom color and elevation values. This enhances visual feedback for user interaction. ```kotlin import androidx.compose.foundation.layout.RowScope import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp Button( onClick = { /* ... */ }, enabled = true, // Custom colors for different states colors = ButtonDefaults.buttonColors( backgroundColor = MaterialTheme.colors.secondary, disabledBackgroundColor = MaterialTheme.colors.onBackground .copy(alpha = 0.2f) .compositeOver(MaterialTheme.colors.background) // Also contentColor and disabledContentColor ), // Custom elevation for different states elevation = ButtonDefaults.elevation( defaultElevation = 8.dp, disabledElevation = 2.dp, // Also pressedElevation ) ) { /* ... */ } ``` -------------------------------- ### Define custom colors using Color class Source: https://developer.android.com/develop/ui/compose/designsystems/material Define custom colors using the Color class. It's recommended to organize these colors within your theme for better maintainability and support for dark themes. ```kotlin val Red = Color(0xffff0000) val Blue = Color(red = 0f, green = 0f, blue = 1f) Material2Snippets.kt ``` -------------------------------- ### Text Emphasis with Font Weights Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Defines text styles with different font weights for emphasis. Use for varying levels of importance in text content. ```kotlin bodyLarge = TextStyle( fontWeight = FontWeight.Bold ), bodyMedium = TextStyle( fontWeight = FontWeight.Normal ) ``` -------------------------------- ### Access Text Styles Source: https://developer.android.com/develop/ui/compose/designsystems/material Retrieve TextStyle elements from MaterialTheme.typography to apply predefined text styles to Text composables. ```kotlin Text( text = "Subtitle2 styled", style = MaterialTheme.typography.subtitle2 ) ``` -------------------------------- ### Apply Elevation Overlays with Surface Source: https://developer.android.com/develop/ui/compose/designsystems/material The Surface composable automatically applies elevation overlays in dark themes. Ensure the color is set to MaterialTheme.colors.surface for automatic adjustment. ```kotlin Surface( elevation = 2.dp, color = MaterialTheme.colors.surface, // color will be adjusted for elevation /*...*/ ) { /*...*/ } ``` -------------------------------- ### Compose Equivalent for XML Button Style Source: https://developer.android.com/develop/ui/compose/designsystems/migrate-xml-theme-to-compose When an XML element uses a custom style like `@style/MyPrimaryButton`, create a specific composable function in Compose instead of replicating the style inline. This promotes reusability and maintainability. ```kotlin MyPrimaryButton(onClick = { ... }) ``` -------------------------------- ### Extended Floating Action Button Source: https://developer.android.com/develop/ui/compose/designsystems/material3 An extended FAB for the highest emphasis action. Includes an icon and text. Use for primary actions. ```kotlin ExtendedFloatingActionButton( onClick = { /*..*/ }, modifier = Modifier ) { Icon( imageVector = Icons.Default.Edit, contentDescription = stringResource(id = R.string.edit) ) Text( text = stringResource(id = R.string.add_entry) ) } ``` -------------------------------- ### Material 2 Color Definitions Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Define light and dark color palettes for Material 2 using `lightColors` and `darkColors`. ```kotlin import androidx.compose.material.lightColors import androidx.compose.material.darkColors val AppLightColors = lightColors( // M2 light Color parameters ) val AppDarkColors = darkColors( // M2 dark Color parameters ) val AppColors = if (darkTheme) { AppDarkColors } else { AppLightColors } ``` -------------------------------- ### Apply Light or Dark Theme Colors Source: https://developer.android.com/develop/ui/compose/designsystems/material Conditionally apply the defined `DarkColors` or `LightColors` to the `MaterialTheme` based on the current theme state (e.g., dark theme enabled). ```kotlin MaterialTheme( colors = if (darkTheme) DarkColors else LightColors ) { // app content } Material2Snippets.kt ``` -------------------------------- ### Compose Component Color Mapping Source: https://developer.android.com/develop/ui/compose/designsystems/migrate-xml-theme-to-compose Attributes like `backgroundTint` in XML are mapped to `containerColor` within `ComponentDefaults.ComponentColors()` in Compose. ```kotlin containerColor in ComponentDefaults.ComponentColors() ``` -------------------------------- ### Define Light and Dark Color Roles Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Defines the color roles for light and dark themes, typically generated by the Material Theme Builder. These are used to set up the ColorScheme. ```kotlin val md_theme_light_primary = Color(0xFF476810) val md_theme_light_onPrimary = Color(0xFFFFFFFF) val md_theme_light_primaryContainer = Color(0xFFC7F089) // .. // .. val md_theme_dark_primary = Color(0xFFACD370) val md_theme_dark_onPrimary = Color(0xFF213600) val md_theme_dark_primaryContainer = Color(0xFF324F00) // .. // .. ``` -------------------------------- ### Compose Button Colors Mapping Source: https://developer.android.com/develop/ui/compose/designsystems/migrate-xml-theme-to-compose The `Widget.Material3.Button` style in XML is mapped to the `Button` composable in Compose, using `ButtonDefaults.buttonColors()` to define its appearance. ```kotlin Button(colors = ButtonDefaults.buttonColors(...)) ``` -------------------------------- ### Text Button for Low Emphasis Source: https://developer.android.com/develop/ui/compose/designsystems/material3 A text button for low emphasis actions. Suitable for secondary or less critical actions. ```kotlin TextButton(onClick = { /*..*/ }) { Text(text = stringResource(id = R.string.replated_articles)) } ``` -------------------------------- ### Compose Shapes Mapping Source: https://developer.android.com/develop/ui/compose/designsystems/migrate-xml-theme-to-compose XML `ShapeAppearance.*.SmallComponent` styles are represented by `Shapes` in Compose, where properties like `small` are defined using `RoundedCornerShape` with specific corner radii. ```kotlin Shapes(small = RoundedCornerShape(X.dp)) ``` -------------------------------- ### Compose Padding Mapping Source: https://developer.android.com/develop/ui/compose/designsystems/migrate-xml-theme-to-compose XML `android:padding` can be mapped to either `contentPadding` for specific components or `Modifier.padding()` for general layout padding in Compose. ```kotlin contentPadding = PaddingValues(...) ``` ```kotlin Modifier.padding() ``` -------------------------------- ### Apply Theme Shapes to Components Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Customize component shapes using the shapes defined in the MaterialTheme, such as Card and FloatingActionButton. ```kotlin Card(shape = MaterialTheme.shapes.medium) { /* card content */ } FloatingActionButton( shape = MaterialTheme.shapes.large, onClick = { } ) { /* fab content */ } ``` -------------------------------- ### Customize TextStyle Properties Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Customize individual TextStyle properties like fontFamily, fontStyle, and baselineShift for specific text styles. ```kotlin bodyLarge = TextStyle( fontWeight = FontWeight.Normal, fontFamily = FontFamily.SansSerif, fontStyle = FontStyle.Italic, fontSize = 16.sp, lineHeight = 24.sp, letterSpacing = 0.15.sp, baselineShift = BaselineShift.Subscript ), ``` -------------------------------- ### Material 3 Color Definitions Source: https://developer.android.com/develop/ui/compose/designsystems/material2-material3 Define light and dark color schemes for Material 3 using `lightColorScheme` and `darkColorScheme`. ```kotlin import androidx.compose.material3.lightColorScheme import androidx.compose.material3.darkColorScheme val AppLightColorScheme = lightColorScheme( // M3 light Color parameters ) val AppDarkColorScheme = darkColorScheme( // M3 dark Color parameters ) val AppColorScheme = if (darkTheme) { AppDarkColorScheme } else { AppLightColorScheme } ``` -------------------------------- ### Check Current Theme Colors Source: https://developer.android.com/develop/ui/compose/designsystems/material Use MaterialTheme.colors.isLight to check if the current Colors are light or dark. This is useful for conditionally displaying theme-specific resources like icons. ```kotlin val isLightTheme = MaterialTheme.colors.isLight Icon( painterResource( id = if (isLightTheme) { R.drawable.ic_sun_24 } else { R.drawable.ic_moon_24 } ), contentDescription = "Theme" ) ``` -------------------------------- ### Compose Typography Mapping Source: https://developer.android.com/develop/ui/compose/designsystems/migrate-xml-theme-to-compose XML `TextAppearance.Material3.BodyMedium` styles map to `TextStyle` definitions within the `Typography` object in Compose, specifically for the `bodyMedium` property. ```kotlin TextStyle(...) defined in Typography(bodyMedium = ...) ``` -------------------------------- ### Define Custom Shapes Source: https://developer.android.com/develop/ui/compose/designsystems/material Define a custom shape system using the Shapes class, specifying CornerBasedShape for small, medium, and large component categories. Apply it to MaterialTheme. ```kotlin val shapes = Shapes( small = RoundedCornerShape(percent = 50), medium = RoundedCornerShape(0f), large = CutCornerShape( topStart = 16.dp, topEnd = 0.dp, bottomEnd = 0.dp, bottomStart = 16.dp ) ) MaterialTheme(shapes = shapes, /*...*/) { /*...*/ } ``` -------------------------------- ### Set Surface and Content Color Source: https://developer.android.com/develop/ui/compose/designsystems/material Use Surface and TopAppBar to set a component's color and a default content color for its children. The contentColorFor() function retrieves the appropriate 'on' color for theme colors. ```kotlin Surface( color = MaterialTheme.colors.surface, contentColor = contentColorFor(color), // ... ) { /* ... */ } TopAppBar( backgroundColor = MaterialTheme.colors.primarySurface, contentColor = contentColorFor(backgroundColor), // ... ) { /* ... */ } ``` -------------------------------- ### Compose CardView Mapping Source: https://developer.android.com/develop/ui/compose/designsystems/migrate-xml-theme-to-compose XML `Widget.Material3.CardView` styles translate to the `Card` composable in Compose, allowing customization of `shape`, `elevation`, and `colors`. ```kotlin Card(shape=..., elevation=..., colors=...) ``` -------------------------------- ### Apply Typography to MaterialTheme Source: https://developer.android.com/develop/ui/compose/designsystems/material3 Pass your custom Typography object to the MaterialTheme composable to apply it throughout your M3 app. ```kotlin MaterialTheme( typography = replyTypography, ) { // M3 app Content } ``` -------------------------------- ### Compose MinHeight Mapping Source: https://developer.android.com/develop/ui/compose/designsystems/migrate-xml-theme-to-compose The `android:minHeight` attribute in XML is mapped to `Modifier.heightIn(min = X.dp)` in Compose to enforce a minimum height for composables. ```kotlin Modifier.heightIn(min = X.dp) ```