Styling Our Components with CSS Variables
Our components are designed to be easily customizable via CSS variables. By using custom properties, you can change everything from colors and fonts to spacing and animations without modifying the component’s underlying CSS. This guide explains the available variables, their default settings, and usage examples.
Tip: To override any variable, simply redeclare it in a parent element or within your component’s host. For example:
:host {
--contribe-primary-color: #007bff; /* Change primary color to blue */
}
Global Settings
These variables control the overall look and feel of our components:
Variable | Default Value | Description |
|
| The default line height for the component host. |
|
| Primary color used for text, icons, and various highlights. |
|
| Secondary color typically used for backgrounds or contrasts. |
|
| Default border style applied to various elements. |
|
| Border radius used by multiple components. |
|
| Base font family. |
|
| Font size for larger text elements. |
|
| Font size for smaller text elements. |
Container Settings
These variables customize the main container that wraps our component:
Variable | Default Value | Description |
|
| Container text or element color (linked to the primary color by default). |
|
| Background color of the container. |
|
| Border radius applied to the container. |
|
| Border style for the container. |
|
| Padding inside the container. |
|
| Maximum width of the container. |
|
| Minimum width of the container. |
|
| Font size within the container. |
Project Button Settings
These variables control the appearance and behavior of project buttons and related elements:
Button Colors and States
Variable | Default Value | Description |
|
| Text (and default icon) color for project buttons. |
|
| Text color for an active project button. |
|
| Background color when a project is active. |
|
| Icon color in the active state. |
| Uses | Default hover background by mixing the active background with white. |
| Falls back to | Hover background color for project buttons; override this to customize hover behavior. |
|
| Default background color for project buttons. |
|
| Border style for project buttons. |
|
| Border radius for project buttons. |
|
| Padding within project buttons. |
Project Icons
Variable | Default Value | Description |
|
| Icon size within the project button. |
|
| Default color for project icons. |
Project Text
Variable | Default Value | Description |
|
| Padding around the project button’s text. |
|
| Font size for the project text. |
Project Description
Variable | Default Value | Description |
|
| Font size for the header text in project descriptions. |
|
| Font size for the description text. |
|
| Padding for the project description container. |
|
| Text color in the project description. |
|
| Background color for the project description. |
|
| Border radius for the description box. |
|
| Border style for the project description. |
|
| Margin around the project description. |
|
| Color for any links within the project description. |
Selector & Text Settings
These variables determine the typography and color for header and descriptive texts:
Variable | Default Value | Description |
|
| Font size for the selector header title. |
|
| Font size for the selector header description. |
|
| Overall color for the selector header. |
|
| Color for checkboxes in the header. |
|
| Color for the header title text. |
|
| Color for the header description text. |
|
| Color for the title text within project descriptions. |
|
| Color for the description text within project descriptions. |
Custom Overrides Using styleOverride
In addition to CSS variables, our LIT components support direct style overrides via the styleOverride attribute. This allows you to apply custom styles dynamically without modifying global styles or redefining CSS variables.
Internally
How to Use styleOverride
To override styles for a specific instance of a component, set the styleOverride attribute with the desired CSS rules. The styles you provide will be injected into the component’s shadow DOM.
Example Usage
If we want to override the color of any html element within the plugin like the color of a project button, we can simply write css as follows
.contribe-selector-project-button {
color: red !important;
}
and then pass it as an attribute to the plugin as follows
<contribe-plugin styleOverride=".contribe-selector-project-button {color: red !important;}"/>When to Use styleOverride
When you need instance-specific styling without modifying global styles.
When using dynamic styles generated at runtime.
When customizing third-party components without modifying their source code.