MdcTheme

@Composable()
fun MdcTheme(context: Context = LocalContext.current, readColors: Boolean = true, readTypography: Boolean = true, readShapes: Boolean = true, setTextColors: Boolean = false, setDefaultFontFamily: Boolean = false, content: @Composable() () -> Unit)

A MaterialTheme which reads the corresponding values from a Material Components for Android theme in the given context.

By default the text colors from any associated TextAppearances from the theme are not read. This is because setting a fixed color in the resulting TextStyle breaks the usage of androidx.compose.material.ContentAlpha through androidx.compose.material.LocalContentAlpha. You can customize this through the setTextColors parameter.

For Shapes, the configuration layout direction is taken into account when reading corner sizes of ShapeAppearances from the theme. For example, Shapes.medium.topStart will be read from cornerSizeTopLeft for View.LAYOUT_DIRECTION_LTR and cornerSizeTopRight for View.LAYOUT_DIRECTION_RTL.

Parameters

context

The context to read the theme from.

readColors

whether the read the MDC color palette from the context's theme. If false, the current value of MaterialTheme.colors is preserved.

readTypography

whether the read the MDC text appearances from context's theme. If false, the current value of MaterialTheme.typography is preserved.

readShapes

whether the read the MDC shape appearances from the context's theme. If false, the current value of MaterialTheme.shapes is preserved.

setTextColors

whether to read the colors from the TextAppearances associated from the theme. Defaults to false.

setDefaultFontFamily

whether to read and prioritize the fontFamily attributes from context's theme, over any specified in the MDC text appearances. Defaults to false.