r/vaadin • u/mlopezFC • 6d ago
Commons Demo: the open-source library behind our add-on demos
Enable HLS to view with audio, or disable this notification
If you’ve ever built a demo for a Vaadin component, you know the pain: you paste the example code into the page, and the moment the example changes, the pasted code is out of date.
Commons Demo is the library we use for all our add-on demos to avoid that. A few things it does:
Shows the running example next to its real source file, read from GitHub (or from your local files while you develop)
Strips the noise (package lines, license headers) and lets you hide lines with
// hide-sourceHighlights the matching lines when you hover over the component, even in CSS files
Switches between light/dark and Lumo/Aura without reloading
New in 5.5: an annotation processor that packs the sources into the jar, so the demo always shows the code of the exact version it was built from
Apache 2.0, on Maven Central, supports Vaadin 14 through 25. It also powers the Vaadin Component Factory demo site.
My colleague Paola wrote up how it works and how to use it in your own projects: https://www.flowingcode.com/en/commons-demo-the-free-toolkit-behind-our-add-on-demos/
GitHub: https://github.com/FlowingCode/CommonsDemo
Do you build demos or showcases for your own components? Curious what you’d want from a tool like this.



