Skip to main content

Sizing

Ask AIView as Markdown
Copy a prompt to ask an AI assistant about this page.

Sizing tokens adapt sizes, spacing and icon dimensions to enable applications to switch between the default and a compact layout. Compact mode is experimental and may change.

Sizing

Experimental feature

Compact mode is a new feature and is currently experimental. We are still evaluating how well it works across components and use cases. Its token coverage, values and behavior may change as we learn from its use and make further adaptations. Test compact mode with your application before relying on it in production.

The system supports two densities. Default is the base density. Compact is a sparse override: it only redefines the sizing tokens listed on this page, and the font-size and line-height from the typography variables. Every other token is inherited from the default density.

Default and compact density comparison

Enable compact density by adding data-ix-density="compact" to the element that sets the theme and color schema:

<html
data-ix-theme="community"
data-ix-color-schema="dark"
data-ix-density="compact"
>
...
</html>

Scoped density​

data-ix-density also works on any element inside the themed root. The density applies to that element and its descendants. Density scopes can be nested, and the closest data-ix-density ancestor wins:

<html data-ix-theme="community" data-ix-color-schema="dark">
<body>
<!-- Default density -->
<section data-ix-density="compact">
<!-- Compact density -->
<div data-ix-density="default">
<!-- Default density again -->
</div>
</section>
</body>
</html>

Using the tokens​

Reference the tokens with the CSS var() function. Their values switch automatically when the density changes:

.some-example {
min-height: var(--si-sys-sizing-size-100);
padding-inline: var(--si-sys-sizing-spacing-x-40);
}

Do not hardcode the values shown below. They are resolved from the installed theme and differ between densities.

Sizing unit​

Size and spacing tokens (--si-sys-sizing-size-* and --si-sys-sizing-spacing-*) resolve to px. Component dimensions driven by these tokens therefore stay the same when the root font size changes. Icon, avatar and typography tokens use rem, so text and icons still scale with the root font size and components grow to fit them.

If your application changes the root font size and expects component dimensions to scale with it, add data-ix-sizing="rem". It switches the size and spacing tokens back to rem for that element and its descendants. Nested density scopes inside it keep rem sizing:

<html
data-ix-theme="community"
data-ix-color-schema="dark"
data-ix-sizing="rem"
>
...
</html>

Every size and spacing token also has a --si-sys-sizing-rem-* twin that always resolves to rem, for example --si-sys-sizing-rem-size-80. The twins are converted from the px values (see Rem size).

data-ix-sizing="rem" only affects the tokens. Fixed values in component and global styles use px and do not change.

Size​

Spacing X​

Spacing Y​

Icon​

Rem size​

The --si-sys-sizing-rem-* tokens are converted from the px size and spacing tokens above. iX components only use the standard px tokens, never the rem twins, so prefer the standard tokens in your own styles as well. Only use the rem twins when you know a custom element must scale with the root font size, for example a container that wraps text-driven content.

Rem spacing X​

Rem spacing Y​