Skip to main content

Theming

Xyba Elements is designed to be fully customizable through CSS. The elements base their colors on the currentColor which is inherited from from the document.

To change the default styles from dark to light, is as simple as setting the css property color on the body element.

body {
color: white;
}

Custom Properties

The Xyba Elements default styles can be customized at a very high-level using custom properties. Elements that provides a default visual style also implements element specific custom properties as well.

You can set custom properties on the whole document.

:root {
--xyba-color: blue;
}

You can set custom properties on a selector in your stylesheet.

xyba-button.my-button {
--xyba-text-color-active: red;
}

Alternatively you can inline the custom properties

<xyba-button style="--xyba-text-color-active: red;">A</xyba-button>

High-level Properties

namedescription
--xyba-colorThe base color used for inheriting. Set this to eg. green to have everything be green.
--xyba-backdrop-filterThe backdrop filter for elements. Eg. set this to 0 to disable blur on the elements.
--xyba-backgroundThe background
--xyba-background-activeThe background when elements are active
--xyba-border-widthThe border width
--xyba-border-styleThe style, eg. solid or dashed
--xyba-border-colorThe color of the borders
--xyba-border-color-activeThe color of the borders when elements are active or pressed
--xyba-text-colorThe color for text or icons
--xyba-text-color-activeThe color for text or icons when elements are active or pressed

See Analog or Button documentation for for element specific custom properties.

CSS Parts

Xyba Elements utilizes Shadow DOM to ensure that the structures of the elements are left intact in any environment. As a result, you can’t simply target their internals with the usual CSS selectors.

Instead elements expose parts that can safely be target with the CSS part selector ::part styled without concerns for the general structure.

Here's an example that modifies the Analog element using the ::part(base) selector.

<xyba-analog class="base-modification"></xyba-analog>

All visual elements expose parts. You can find them in each component’s API documentation under the “CSS Parts” section.

The no-style attribute

All visual elements implements the no-style attribute / noStyle property that completely disables all predefined visual aspects. This is very useful in combination with using slots as it provides full styling accessibility to your disposal without the need for overriding default styles.

This also means that any theming done with custom properties will be ignored, unless implemented again manually.

Here's an example of a highly custom button.

Start
<xyba-button class="custom-button" no-style><span>Start</span></xyba-button>