Type-safe CSS properties
Every Kilua component has a full range of properties based on CSS specification. Most of them are 100% type-safe - based on enumeration values, dedicated classes and functions. You can of course use custom CSS stylesheets and assign predefined classes to your components, but Kilua gives you a choice. With CSS properties you can style any component's size, position, margins, paddings, borders, colors, backgrounds, text and fonts with pure Kotlin code.
CSS units
Kilua supports all CSS units as an extension properties on Number
type. So you can specify dimensions, sizes, position and thickness with such example notations: 50.px
, 12.pt
, 2.em
, 90.perc
, 100.vh
, 1.49.em
etc. In addition auto
, normal
, initial
and inherit
values are also supported.
Colors
Kilua offers a few convenient ways to specify colors. You can use methods defined in the Color
class to create values with hexadecimal Int
literals or direct RGB(A) values. You can also use predefined constants for all CSS color names.
CSS helper classes
To specify borders, backgrounds, text decorations, text shadows, box shadows, transitions and list styles you use the dedicated classes.
Style functions
When the CSS properties are set directly inside the component, the corresponding style attributes are inlined in the generated HTML code. Sometimes it's better to define a CSS class, which can be reused by other parts of the UI. In Kilua you can do this by using the style()
function. It creates a CSS class which can be used by other components.
By default the class name is automatically generated, but you can use your own with optional parameters.
Styles can also be nested to create CSS subclasses.
You can also easily use CSS pseudo-classes or media queries.
Last updated