You can use the CSS as is, but you'll (naturally) have to tell Vaadin which CSS classes to use by calling
myComponent.setStyleName("myStyleClass");
or
myComponent.addStyleName("myStyleClass");
The difference between the two is that setStyleName replaces all existing styles with the provided one and addStyleName doesn't replace anything but adds the provided style for the component.
You can also modify your CSS to override default Vaadin styles, for example
.v-panel .v-panel-content {
background: yellow;
}
would change every Panel's background color to yellow.
I recommend that you create a new theme which is based on an existing Vaadin theme. Here's how to:
- Create a directory in the VAADIN/themes/ directory (eg. VAADIN/themes/myTheme).
- Create styles.css in your theme directory.
- Add
@import "../runo/styles.css";
to the beginning of your styles.css (you can replace runo by any other existing theme).
- Call
setTheme(myTheme);
in your Vaadin application class.
- If you want to apply application-wide styles, override the Vaadin component CSS definitions in your styles.css. If you don't know the names of the CSS classes, you can use firebug and check the HTML elements' classes.
- If you want to create a component-specific style, define it in styles.css and call
setStyleName
or addStyleName
methods.
See the CSS entry in the Book of Vaadin here.