This library is meant to be used with Compose-HTML.
CiC allows you to define CSS (as opposed to Style) directly into HTML Composables. It basically does the same thing as Kotlin Wrapper Styled Components, but for Compose-HTML.
In addition to regular element style, it allows you to style children and pseudo-classes.
IMPORTANT: You should only use css
for immutable style.
As a new CSS class is generated every time the content changes, you should use style
for changing style.
build.gradle.kts
dependencies {
implementation("org.kodein.compose.html.css:css-in-composable:1.7.0")
}
Have a look at that example:
@Composable
fun ColoredDiv(text: String) {
Div({
css {
//(1)
backgroundColor(Color.blue)
padding(1.em)
textAlign("center")
(self + hover) { //(2)
backgroundColor(Color.red)
}
"a" { //(3)
backgroundColor(Color.orange)
textDecoration("none")
}
}
}) {
Text(text)
}
}
-
Basic style
-
Self + pseudo-class
-
Children