Styling
Styling your widget with the provided CSS variables and classes helps it fit nicely alongside other widgets on the userโs dashboard.
Styling for widgets is not the same as for custom views. While there are some variables and classes with the same name, the actual styling might differ.
The provided CSS variables and classes are prefixed with homey, so --homey
for variables and .homey
for classes. We recommend using these CSS variables and classes as much as possible. Most widgets can be created using only these classes or by adding just a few lines of custom CSS. However, feel free to use them as a starting point and add custom styling to your liking.
Widget
Your widget consists of a title, a frame, and the content you provide. While you have limited control over the title and frame, most of this style guide focuses on styling the content within your widget.
Title
Frame
Background color
By default, the background color of your widget is set to --homey-background-color
. This semantic color variable (see Semantic) can also be used for other elements in your widget.
You can apply a different background color to the body of your widget:
Spacing
When widgets are next to each other, it's visually pleasing to have the elements inside of the widgets aligned. In addition, the distances between elements inside of a widget make a huge difference in how organised, or cluttered, the dashboard feels.
Space Units
To maintain consistent spacing across your widgets, we provide a set of predefined CSS variables based on a space unit, --homey-su
. This unit serves as the foundation for all spacing-related styles. You can use these variables to apply consistent margins, padding, and other spacing properties to your widget elements.
We don't use space units for sizing properties, like width and height. The size of an element is often determined by other factors, like text length, or by the available space left after applying margins and paddings (e.g. width: 100%;
).
The base space unit is set to 4px. Each derived variable is a multiple of the base space unit.
Usage Example
You can use these variables to ensure consistent spacing within your widgets. For example:
Widget Padding
To align the elements on the edges of your the widget to other widgets, we offer the following classes:
Usage Examples
The space between your widgetโs content and the edge of its frame affects how well it aligns with other widgets. To ensure a consistent look across the dashboard, weโve added the .homey-widget
class to the body of your widget by default. This class applies a padding of --homey-su-4
(16px, see Space Units) to your widget:
For smaller widgets, this padding might take up more space than desired. In such cases, you can use the .homey-widget-small
class, which sets the padding to --homey-su-2
(8px):
For widgets that include elements like tables or images that need to extend to the edges of the frame, you can either remove the .homey-widget
class or use the .homey-widget-full
class, which sets the padding to 0. Alternatively, you can move the .homey-widget
class to a child element for the rest of your content:
Text
Describing every possible combination of text properties would be too extensive. Instead, we offer several text presets as CSS classes that cover a wide range of use cases, along with CSS variables for font size, font weight, line height and color. Additionally, we provide classes for text alignment.
Text Presets
The following CSS classes are a great starting point for styling your widget. They apply a font size smaller than the widget title, and their combination of font weight, line height, and color helps establish a clear visual hierarchy within your widget.
In the image below are examples of when to use these classes.
Usage Example
Variables
We provide CSS variables for font size, font weight, line height, and color. To maintain consistency, all text on the dashboard follows specific combinations of font sizes and font weights. When using the provided CSS variables, refer to the table below for the recommended combinations. Additionally, ensure that the line height you choose matches the corresponding font size (see Line Height).
Table of combinations for font size and font weight
The image below shows several combinations used in widgets.
Font Size
It is recommended to use text sizes smaller than the title above the widgets, which is 20px. The default text size --homey-font-size-default
is 17px.
We provide the following variables:
Line Height
We have a specific line height for every font size. It is highly recommended to always use these together.
Font Weight
Important text, such as titles, can be made to stand out by adjusting the font weight. Refer to the table above (see Table of combinations for font size and font weight) to find the appropriate font weight for your chosen font size.
Text Color
The default text color is --homey-text-color
. This color depends on if the widget is shown in light or dark mode (see Light & Dark Mode) and fits nicely on a background with --homey-background-color
(see Background color).
For use on different backgrounds or different purposes, we offer the following semantic color variables (see Semantic).
Usage Example
Text Alignment
We have the following CSS classes to change the text alignment to left, center or right.
Colors
We provide a color palette that includes grayscale, blues, greens, orange, and reds, in addition to semantic colors for specific purposes. Our palette supports both light and dark mode, with each CSS variable automatically adjusting to the active mode. However, the actual color may differ between modes.
Light & Dark Mode
The dashboard switches between light and dark mode based on the userโs settings. By default, the widget background is white in light mode and dark grey in dark mode.
If you want your widget to always appear in dark mode, regardless of the user's settings, you can add the .homey-dark-mode
class to the element. This forces the widget to stay in dark mode.
Usage Example
Palette
Our color palette includes grayscale, blues, greens, orange, and reds. While you can use these CSS variables directly, we recommend using the semantic color variables where possible (see Semantic).
The grayscale is prefixed with --homey-color-mono
and ranges from --homey-color-mono-000
(white in light mode) to --homey-color-mono-1000
(black in light mode).
The blue, green, orange and red colors are prefixed as --homey-color-blue
, --homey-color-green
, --homey-color-orange
and --homey-color-red
respectively. These colors range from 050
to 900
, except for orange, which only has the 500
value available. These colors remain the same in both light and dark mode.
Semantic
To help you select the right color from our palette, we provide CSS variables for specific purposes, known as semantic color variables. These variables are defined using the palette CSS variables above ( see Palette). So no new colors are introducedโjust clarification on their intended use cases. This ensures consistent color usage across your widgets while keeping the palette simple and easy to apply.
The semantic CSS variables for Background color, Text Color, Lines & Borders and Icons can be found in their respective sections.
Lines & Borders
Because the widgetโs frame already has a shadow, we recommend avoiding additional shadows on elements inside your widget, as shadows within shadows can quickly become cluttered. Instead, we offer several CSS variables and classes to help you apply clean and consistent lines and borders to your elements.
Borders
Lines
The CSS classes for borders use the following CSS variables. These CSS variables can also be applied to other lines within your widget.
We provide two semantic color variables for line colors (see Semantic):
In almost all cases, we use a 1px solid line with the line colors mentioned above. You can use the following CSS variables to apply consistent lines like these to your widget elements:
Border Radius
We offer the following CSS variables for applying a border radius to your elements:
Usage Example
Icons
Custom Icons
If you want to add a custom icon, you can extend the .homey-custom-icon- class. Simply add a class starting with .homey-custom-icon-
(e.g., .homey-custom-icon-example
) to your element. In your CSS, use your SVG as the mask-image
and include -webkit-mask-image
for older browser support.
Usage Example
Variables
We have the following semantic color variables for icon colors (see Semantic):
We have the following CSS variable for icon sizing:
Usage Example
Tables
We offer two different table styles: tables with lines between cells, using the .homey-table
class, and tables with striped rows, using the .homey-table-striped
class. We recommend using the .homey-table-striped
class only for tables with a few columns or when the content has enough horizontal spacing that dividing lines arenโt necessary.
To change the text alignment in the cells of the table, you can apply the text alignment classes (see Text Alignment) to the table element.
Usage Example
Last updated