Theming
Lumo uses CSS custom properties to define typography, colors, sizing, spacing etc. Most visual styles can be achieved by tweaking these properties. For the more intricate theming use ThemableMixin.
Typography
https://cdn.vaadin.com/vaadin-lumo-styles/1.4.2/demo/typography.html
Property | Values | Example |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Colors
https://cdn.vaadin.com/vaadin-lumo-styles/1.4.2/demo/colors.html
Color | Values |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Java
UIUtils.setBackgroundColor(LumoStyles.Color.Contrast._20, component);
Styles
https://cdn.vaadin.com/vaadin-lumo-styles/1.4.2/demo/styles.html
Color | Values | Example |
---|---|---|
|
|
|
|
|
|
|
|
|
Sizing and Spacing
https://cdn.vaadin.com/vaadin-lumo-styles/1.4.2/demo/sizing-and-spacing.html
Property | Size | Direction |
---|---|---|
|
|
|
|
|
|
|
|
|
Java
// Using class names
component.addClassNames(
LumoStyles.Margin.Left.S,
LumoStyles.Padding.Vertical.XL,
LumoStyles.Spacing.Bottom.M
);
// FlexBoxLayout API
flexBoxLayout.setMargin(Left.S);
flexBoxLayout.setPadding(Vertical.XL);
flexBoxLayout.setSpacing(Bottom.S);
Utility Classes
A number of utility classes, most importantly UIUtils
, were introduced to make theming more consistent and efficient. UIUtils
can be used to create common button variants, labels and icons of different colors and sizes etc.
Buttons
The methods below accept String
and/or VaadinIcon
.
Variant | UIUtils method |
---|---|
Primary |
|
Tertiary |
|
Success |
|
Error |
|
Contrast |
|
Size |
|
Combinations can be created with createButton(String, ButtonVariant…)
, createButton(VaadinIcon, ButtonVariant…)
and createButton(String, VaadinIcon, ButtonVariant…)
.
Java
// Primary button (text only)
UIUtils.createPrimaryButton("Primary");
// Success button (icon only)
UIUtils.createSuccessButton(VaadinIcon.CHECK);
// Error button (text and icon)
UIUtils.createErrorButton("Error", VaadinIcon.WARNING);
// Small tertiary button (text and icon)
UIUtils.createButton(
"Small tertiary",
VaadinIcon.HOME,
ButtonVariant.LUMO_SMALL,
ButtonVariant.LUMO_TERTIARY
);
Labels
Type | UIUtils method |
---|---|
Color |
|
Size |
|
Size & color |
|
Heading |
|
Icons
Variant | UIUtils method |
---|---|
Primary |
|
Secondary |
|
Tertiary |
|
Disabled |
|
Success |
|
Error |
|
Small |
|
Large |
|
Combinations can be created with createIcon(IconSize, TextColor, VaadinIcon)
.
Numbers
UIUtils method | Description |
---|---|
| Formats a decimal amount for improved legibility. |
| Initialises a monospaced H5 label for improved legibility of decimal values. |
| Formats an integer amount for improved legibility. |
| Initialises a monospaced H5 label for improved legibility of integer values. |
Dates
UIUtils method | Description |
---|---|
| Formats a |
Misc
UIUtils method | Description |
---|---|
| Sets the column span for components in a |
| Initialises a |
| Creates an avatar with the given initials. |
Customise the Utility Classes
It is advised to create and modify the utility classes according to your needs. Creating custom components and utility methods for reoccurring UI patterns will make the code more consistent and easier to maintain.