Alex Styl

12/09/2021, 1:19 PM
What is the css DSL counter part of the following css?
@font-face {
    src: url("/fonts/Urbanist.ttf");
    font-family: urbanist;
So far I got:
call.respondCss {
    fontFace {
        fontFamily = "urbanist"
but I cannot find a way to populate the src value. (also, please let me know if this is not the right place to ask this)
Couldn’t find a way to do it so I created (copy-pasted) my own CssProperty. Seems to be working
var StyledElement.src: String by CssProperty()

// copy pasted in my file to be accessible
private class CssProperty<T>(private val default: (() -> T)? = null) {
    operator fun getValue(thisRef: StyledElement, property: KProperty<*>): T {
        default?.let { default ->
            if (!thisRef.declarations.containsKey( {
                thisRef.declarations[] = default() as Any

        return thisRef.declarations[] as T

    operator fun setValue(thisRef: StyledElement, property: KProperty<*>, value: T) {
        thisRef.declarations[] = value as Any

Matteo Mirk

12/09/2021, 2:50 PM
wow, so you had to copy CssProperty, which is private in Ktor, and modify it to your needs? If you think this is a missing feature you should open a PR to Ktor.

Aleksei Tirman [JB]

12/10/2021, 7:25 AM
I suggest filing an issue to the kotlin-wrappers repository.
💯 1

Alex Styl

12/10/2021, 10:02 AM
Fixed already