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
The default title of your widget is the name set in widget.compose.json
(see widget.compose.json). When users add your widget to their dashboard, they can choose to either change the title or hide it entirely.
Frame
Your widgetβs content is placed inside a frame with rounded corners and a shadow. While you can't change the border radius, shadow or width of the frame, you do have control over the height (see widget.compose.json) and the background color.
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.
CSS Variable | Value |
---|---|
|
|
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:
CSS Class | Purpose |
---|---|
| Default and recommended for most widgets. This class applies a padding of |
| Used to save space in small widgets, this class applies a padding of |
| Use this class, or omit the class entirely, for widgets where you need the full space (e.g. tables or images). The default padding for the element is 0. |
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.
CSS Class | Purpose |
---|---|
| Used for titles or a singular important text. |
| Used to make text stand out, for strong text or subtitles. |
| Default for most text. |
| Used for small text on it's own. |
| Used for small text next to other texts. |
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
regular | medium | bold | |
---|---|---|---|
xxlarge | |||
xlarge | |||
large | |||
default | |||
small |
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:
CSS Variable | Value | Purpose |
---|---|---|
| 32px | Used for numbers only. |
| 24px | Use sparingly, only for short phrases or single words that really have to stand out. |
| 20px | Used for numbers only. |
| 17px | Default for most text. |
| 14px | For captions, tables, underneath other text, or inside specific elements. |
Line Height
We have a specific line height for every font size. It is highly recommended to always use these together.
CSS Variable | Value | Use with font size |
---|---|---|
| 40px |
|
| 32px |
|
| 28px |
|
| 24px |
|
| 20px |
|
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.
CSS Variable | Value | Purpose |
---|---|---|
| 700 | Used for titles. |
| 500 | Used to make text stand out, for strong text or subtitles. |
| 400 | Default for most text. |
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).
CSS Variable | Purpose |
---|---|
| Default text color. |
| Used for text that's less important, or disabled. |
| White text, independent of light or dark mode. Used for text on dark or colored backgrounds. |
| Blue text. |
| Green text. |
| Orange text. |
| Red text. |
| Text to highlight something. |
| Text for success case. |
| Text for warnings. |
| Text for errors. |
Usage Example
Text Alignment
We have the following CSS classes to change the text alignment to left, center or right.
CSS Class | Purpose |
---|---|
| Align text left. |
| Align text center. |
| Align text 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.
CSS Class | Purpose |
---|---|
| Force widget to dark mode independent of user settings. |
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.
CSS Variable | Purpose |
---|---|
| White color independent of light or dark mode. |
| General purpose blue color. |
| General purpose green color. |
| General purpose orange color. |
| General purpose red color. |
| Highlight. |
| Success. |
| Warning. |
| Danger. |
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
CSS Class | Purpose |
---|---|
| Adds a border to all sides of the element. |
| Add a border to the top of the element. |
| Add a border to the right side of the element. |
| Add a border to the bottom of the element. |
| Add a border to the left side of the element. |
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):
CSS Variable | Purpose |
---|---|
| Used for most lines. The default line color. |
| Used for light lines that should stand out less. |
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:
CSS Variable | Purpose |
---|---|
| Used for most lines. |
| Used for light lines that should stand out less. |
Border Radius
We offer the following CSS variables for applying a border radius to your elements:
CSS Variable | Purpose |
---|---|
| Only use where the default border radius is too big. |
| Default border radius. |
Usage Example
Icons
For our icons, we always use SVGs and recommend you do the same for your custom icons, as SVGs ensure sharp display at any size. You can place your custom icons, along with other assets, in your public folder (see index.html).
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):
CSS Variable | Purpose |
---|---|
| Default icon color. |
| Used less important icons or disabled states. |
| White icons, independent of light or dark mode. |
| Blue icons. |
| Green icons. |
| Orange icons. |
| Red icons. |
We have the following CSS variable for icon sizing:
CSS Variable | Value | Purpose |
---|---|---|
| 20px | Default icon size. |
| 16px | Used in line with regular text. |
| 14px | Used in line with small text. |
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.
CSS Class | Purpose |
---|---|
| Default table styling. |
| Used for tables with only a few columns. |
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