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
| Property | Values | Example |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Colors
| Color | Values |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Source code
Java
UIUtils.setBackgroundColor(LumoStyles.Color.Contrast._20, component);Styles
| Color | Values | Example |
|---|---|---|
|
|
|
|
|
|
|
|
|
Sizing and Spacing
| Property | Size | Direction |
|---|---|---|
|
|
|
|
|
|
|
|
|
Source code
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…).
Source code
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. |