Need help with material-components-android-compose-theme-adapter?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

281 Stars 31 Forks Other 244 Commits 4 Opened issues


A library that enables reuse of Material themes defined in XML for theming in Jetpack Compose.

Services available


Need anything else?

Contributors list

MDC-Android Compose Theme Adapter

A library that enables reuse of Material Components for Android XML themes for theming in Jetpack Compose.

MDC-Android Compose Theme Adapter header

The basis of theming in Jetpack Compose is the

composable, where you provide
instances containing your styling parameters:

    typography = type,
    colors = colors,
    shapes = shapes
) {
    // Surface, Scaffold, etc

Material Components for Android themes allow for similar theming for views via XML theme attributes, like so:

This library attempts to bridge the gap between Material Components for Android XML themes, and themes in Jetpack Compose, allowing your composable

to be based on the

's XML theme:
MdcTheme {
    // MaterialTheme.colors, MaterialTheme.shapes, MaterialTheme.typography
    // will now contain copies of the context's theme

This is especially handy when you're migrating an existing app, a fragment (or other UI container) at a time.

!!! caution If you are using an AppCompat (i.e. non-MDC) theme in your app, you should use the AppCompat Compose Theme Adapter instead, as it attempts to bridge the gap between AppCompat XML themes, and themes in Jetpack Compose.

Customizing the theme


function will automatically read the host context's MDC theme and pass them to
on your behalf, but if you want to customize the generated values, you can do so via the
val context = LocalContext.current
val layoutDirection = LocalLayoutDirection.current
var (colors, type, shapes) = createMdcTheme(
    context = context,
    layoutDirection = layoutDirection

// Modify colors, type or shapes as required. Then pass them // through to MaterialTheme...

MaterialTheme( colors = colors, typography = type, shapes = shapes ) { // rest of layout }


There are some known limitations with the implementation at the moment:

  • This relies on your
    theme extending one of the
  • Text colors are not read from the text appearances by default. You can enable it via the
    function parameter.
  • Variable fonts are not supported in Compose yet, meaning that the value of
    are currently ignored.
  • MDC
    allow setting of different corner families (cut, rounded) on each corner, whereas Compose's Shapes allows only a single corner family for the entire shape. Therefore only the
    attribute is read, others (
    , etc) are ignored.
  • You can modify the resulting
    in Compose as required, but this only works in Compose. Any changes you make will not be reflected in the Activity theme.


repositories {

dependencies { implementation "" }

The latest release is: latest release badge

Library Snapshots

Snapshots of the current development version of this library are available, which track the latest commit. See here for more information on how to use them.


Please contribute! We will gladly review any pull requests. Make sure to read the Contributing page first though.


Copyright 2020 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.