Doodle is a UI framework for building Web and Desktop apps entirely in Kotlin. No HTML, no CSS, no XML layouts, no separate toolkit to learn for each platform you ship to. You describe your interface in Kotlin, and Doodle draws it — pixel by pixel — wherever it happens to be running.
Before we get into the why, here's a taste: a gradient-stroked headline, centered and sized from its own measured text.
package io.nacular.doodle.docs.apps
import io.nacular.doodle.application.Application
import io.nacular.doodle.core.Display
import io.nacular.doodle.core.view
import io.nacular.doodle.docs.utils.DEFAULT_FONT_FAMILIES
import io.nacular.doodle.drawing.Color.Companion.Blue
import io.nacular.doodle.drawing.Color.Companion.Red
import io.nacular.doodle.drawing.Color.Companion.Transparent
import io.nacular.doodle.drawing.Color.Companion.White
import io.nacular.doodle.drawing.FontLoader
import io.nacular.doodle.drawing.Stroke
import io.nacular.doodle.drawing.Stroke.LineJoint.Round
import io.nacular.doodle.drawing.SweepGradientPaint
import io.nacular.doodle.drawing.TextMetrics
import io.nacular.doodle.drawing.paint
import io.nacular.doodle.geometry.Point
import io.nacular.doodle.layout.constraints.constrain
import io.nacular.doodle.layout.constraints.fill
import io.nacular.doodle.utils.lerp
import io.nacular.measured.units.Angle.Companion.degrees
import io.nacular.measured.units.times
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import kotlin.math.min
class HelloDoodle(
fonts : FontLoader,
display : Display,
appScope : CoroutineScope,
textMetrics: TextMetrics
): Application {
init {
appScope.launch {
// Fonts are loaded async
val bold = fonts {
families = DEFAULT_FONT_FAMILIES
size = lerp(10.0, 80.0, min(1f, (display.size.width / 700.0).toFloat())).toInt()
weight = 700
}
val textSize = textMetrics.size("Hello Doodle!", bold)
//sampleStart
display += view {
render = {
text(
"Hello Doodle!",
at = Point((width - textSize.width) / 2, (height - textSize.height) / 2),
font = bold,
fill = Transparent.paint,
stroke = Stroke(
thickness = 4.0,
lineJoint = Round,
fill = SweepGradientPaint(
color1 = Red,
color2 = Blue,
center = bounds.atOrigin.center,
rotation = 45 * degrees,
),
),
)
}
}
//sampleEnd
display.fill(White.paint)
display.layout = constrain(display.first(), fill)
}
}
override fun shutdown() {}
}
If that looks like a lot at once, don't worry — you're not meant to follow every line yet. Fonts, the display, layout, and rendering all get unpacked from scratch, starting on the Applications page. Consider this a postcard from where you're headed.
Why Doodle?
One codebase, genuinely multiplatform
Write your UI once in Kotlin and target Web (JS or Wasm) and Desktop — Views never know or care which one they're running on.
Pixel-level control over rendering
No fixed widget palette. Every View draws itself with a full Canvas API — shapes, paths, gradients, text, images, even 3D. If you can describe it, you can draw it.
Layout via constraints, not manual math
Describe relationships between Views — it.left eq parent.left + 8 — and Doodle's constraint solver works out the rest.
Dependency injection, not global state
Apps get what they need — Display, input, fonts, images — through the constructor. No singletons, no globals, easy to test.
Modular by design
Pointer input, keyboard input, fonts, images, paths — all opt-in modules. Include what you use, keep Web bundles lean.
A real component library, not just primitives
Buttons, sliders, tables, trees, and a typed Form system ship out of the box — see the full Catalog.
Try it yourself
Enough pitching. Here's the smallest real Doodle app there is — and it's the very thing the Applications page picks up and builds from the ground up:
import io.nacular.doodle.application.Application
import io.nacular.doodle.application.application
import io.nacular.doodle.core.Display
import io.nacular.doodle.core.view
import io.nacular.doodle.drawing.Color.Companion.Black
import io.nacular.doodle.drawing.text
import org.kodein.di.instance
//sampleStart
class HelloWorld(display: Display): Application {
init {
display += view {
render = {
text("Hello, world!", color = Black)
}
}
}
override fun shutdown() {}
}
fun main() {
application {
HelloWorld(display = instance())
}
}
//sampleEnd
Next: Installation gets Doodle into a project, then Applications builds this example back up from scratch — one piece at a time.
Feedback
Doodle is still very much under active development, which means you'll run into gaps and the occasional bug. When you do, please report issues and send along feature requests — and come say hello in the #doodle channel on Kotlin Slack.
slack.kotl.in has instructions for getting an invitation to Kotlin Slack.
Leave a star
Don't forget to drop us a ★ if you like what you see.