In this article, you’ll learn how to implement theming for apps that are built using Jetpack Compose. Themes in Compose have three main aspects: colors, fonts, and shapes.
Introduction
In the traditional UI kit (i.e. view-/XML-based layouts), we usually use the themes.xml
file to design themes. But when it comes to Jetpack Compose, everything will be done in Kotlin files.
Jetpack Compose themes primarily have two advantages over conventional themes.
It’s a lot simpler to implement custom themes or Day/Night theming options when compared to the traditional approach.
Themes in Jetpack Compose are based on Material Design, so we no longer need to worry about following Material Design guidelines when using themes in Jetpack Compose.
If you love Kotlin, then you’re going to enjoy using themes in Jetpack Compose. The named parameters, lambda functions, default parameter values, and other cool features of Kotlin make it fun to implement theming in Compose.