MaterialTheme
-
Cmn
object MaterialTheme
Contains functions to access the current theme values provided at the call site's position in the hierarchy.
Summary
Public properties |
||
|---|---|---|
CompositionLocal<MotionScheme> |
A read-only |
Cmn
|
ColorScheme |
Retrieves the current |
Cmn
|
MotionScheme |
Retrieves the current |
Cmn
|
Shapes |
Retrieves the current |
Cmn
|
Typography |
Retrieves the current |
Cmn
|
Public properties
LocalMotionScheme
@ExperimentalMaterial3ExpressiveApi
val LocalMotionScheme: CompositionLocal<MotionScheme>
A read-only CompositionLocal that provides the current MotionScheme to Material 3 components.
The motion scheme is typically supplied by MaterialTheme.motionScheme and can be overridden for specific UI subtrees by wrapping it with another MaterialTheme.
This API is exposed to allow retrieving motion values from inside CompositionLocalConsumerModifierNode implementations, but in most cases it's recommended to read the motion values from MaterialTheme.motionScheme.
colorScheme
val colorScheme: ColorScheme
Retrieves the current ColorScheme at the call site's position in the hierarchy.
import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.ui.Modifier import androidx.compose.ui.unit.sp val colorScheme = MaterialTheme.colorScheme Box(Modifier.aspectRatio(1f).fillMaxSize().background(color = colorScheme.primary))
motionScheme
@ExperimentalMaterial3ExpressiveApi
val motionScheme: MotionScheme
Retrieves the current MotionScheme at the call site's position in the hierarchy.
shapes
val shapes: Shapes
Retrieves the current Shapes at the call site's position in the hierarchy.
import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text val shape = MaterialTheme.shapes Button(shape = shape.small, onClick = {}) { Text("FAB with ${shape.small} shape") }
typography
val typography: Typography
Retrieves the current Typography at the call site's position in the hierarchy.
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text val typography = MaterialTheme.typography Text(text = "Headline small styled text", style = typography.headlineSmall)