Concepts
CSS Customization
NEW: Try out the Theme Playground to visually customize and preview your themes.
Velt components can be styled in two main ways:
- Themes
- Custom CSS
Themes
You can use the Theme Playground to customize and preview the themes fast.
CSS Variables
- You can customize:
- Border radius
- Spacing
- Typography
- Colors for light and dark modes
- Z-Index
- Set CSS variables on your
<body>
tag to customize all Velt components:
Example:
Available Theme Variables:
Dark Mode
- Enable dark mode globally or per component.
- Most components accept a
darkMode
prop (dark-mode="true"
for non-React). - Some components that are not directly injected by you like dialogs and pins use specific props (e.g.
dialogDarkMode
,pinDarkMode
). You can add these props to the root component responsible for injecting them. - Check each component’s UI customization documentation for its dark mode props.
Custom CSS or libraries
Custom CSS
You can use your own CSS or libraries like Tailwind CSS to style the Velt components. You will need to disable the Shadow DOM to apply your styles.
- Using CSS on rendered components.
- Inspect the DOM using browser dev tools to find the class names and selectors of the target Velt components.
- Override the styles using your CSS.
- Make sure to disable the Shadow DOM to apply your styles.
- Using CSS on Wireframes.
- Add the relevant wireframe component.
- Add class or inline styles to the wireframe component like you would on a normal HTML element.
- When the actual component is rendered, the styles will be applied to that component.
- Make sure to disable the Shadow DOM to apply your styles.
Disable Shadow DOM
- By default, Velt components use Shadow DOM to isolate their styles from your application’s CSS. This ensures that styles don’t conflict with each other.
- If you want your application’s CSS to affect the styling of Velt components, you can disable the Shadow DOM.
- Most components accept a
shadowDom
prop (shadow-dom="false"
for non-React). - Some components that are not directly injected by you like dialogs and pins use specific props (e.g.
dialogShadowDom
,pinShadowDom
). - Check each component’s UI customization documentation for its shadow DOM props.
Conditional Classes
Apply classes conditionally based available template variables.
Syntax:
<evaluation-string>: 'class-name': {velt-template-variable} <operator> 'value'
- class-name: The class name to apply. This should be within single quotes
'
. - template-variable: The template variable to evaluate. This should be within curly braces
{}
. - operator: The operator to use for the comparison. This should be one of the following:
===
,!==
,>
,>=
,<
,<=
. You can also use&&
and||
to combine multiple conditions. - value: The value to compare the template variable to. This should be within single quotes
'
.
Example:
Was this page helpful?