Styling
Destyler are unstyled and compatible with any styling solution—giving you complete control over styling.
Overview
Functional styles
You are in control of all aspects of styling, including functional styles. For example, by default, a Dialog Overlay won't cover the entire viewport. You're responsible for adding those styles, plus any presentation styles.
Classes
All components accept class
attributes, just like normal component. This class will be passed through to the DOM element. You can use it in CSS as expected.
Teleported elements
Some elements, such as modals or popovers, are teleported to the body
. When using scoped style to apply CSS, you will need to use deep selectors to target them.
Data attributes
When components are stateful, their state will be exposed in a data-state
attribute. For example, when an Collapse Item is opened, it includes a data-state="open"
attribute.
Styling with CSS
Styling a part
You can style a component part by targeting the class
that you provide.
Styling a state
You can style a component state by targeting its data-state
attribute.
Scoped style
You can style a component using scoped style. Be wary of teleported elements, as they require the use of deep selectors to be targeted.
Styling with Atomic CSS
The examples below are using UnoCSS, but you can use any library of your choice.
Styling a part
Styling a state
With UnoCSS powerful variant selector, you can style a component state by targeting its data-state attribute.
Summary
Destyler is components were designed to encapsulate accessibility concerns and other complex functionalities, while ensuring you retain complete control over styling.
For convenience, stateful components include a data-state
attribute.