Over a million developers have joined DZone.

Vaadin 7 Eases Your Theme Development

DZone's Guide to

Vaadin 7 Eases Your Theme Development

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more– name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

Vaadin theming is a nice way to reuse your Cascading Style Sheets across different projects. Vaadin 7 adds even more sugar to the whole theming thing since it allows you to use Syntactically Awesome Stylesheets.

The purpose of this article is not to describe technology since it's already well documented on the SASS website but to expose how to use SASS within Vaadin.

In order to use the SASS technology, a few steps are necessary:

  • First, the UI base class has to be annotated with the @Theme annotation referencing our own new theme.
    public class SassUI extends UI {
  • Remember to set this UI as the Vaadin servlet parameter in the web deployment descriptor:
  • Finally, instead of a CSS file, provide a styles.scss file under /VAADIN/themes/<name> (in your case, the name is "custom"). The code below is just an example:
    @import "../reindeer/styles.css";
    $color: rgb(51,204,255);
    $dark-color: darken($color, 20%);
    $spacing: 4px;
    .v-button-caption {
        color: $color;
    @mixin border-radius($radius) {
        -webkit-border-radius: $radius;
        -moz-border-radius: $radius;
        border-radius: $radius;
    .rounded-borders {
        @include border-radius(4px);
        border: 1px solid $color;
    .v-label {
        color: $dark-color;
        padding-left: $spacing;
        margin-top: $spacing;
        margin-bottom: $spacing;
        font-weight: bold;
That's it. Empowering your themes with SASS technology is as simple as that! Sources for this article can be found on GitHub.

Note that some SASS features are still missing at the time of this writing.

From http://morevaadin.com/content/vaadin-7-eases-your-theme-development

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. Our APIs verify, standardize, and correct the Big 4 + more – name, email, phone and global addresses – to ensure accurate delivery, prevent blacklisting and identify risks in real-time.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}