Variants
Apply utilities based on the appearance of the parent layer or on user preferences.
Variants apply utilities conditionally based on the parent layer or user preference. Use them like any Tailwind variant: ak-dark:ak-ink-80.
Layer appearance
These variants are scoped to an ak-layer container and match based on the layer’s computed lightness.
| Variant | Matches when the parent layer is… |
|---|---|
ak-dark | Dark (would render white-ish text). |
ak-light | Light (would render black-ish text). |
ak-dark-high | The darkest tier. |
ak-dark-low | A dark mid-tier. |
ak-light-low | A light mid-tier. |
ak-light-high | The lightest tier. |
Each layer appearance variant also has a not-* counterpart, such as
not-ak-dark, not-ak-light, and not-ak-dark-high.
Appearance-adjusted secondary text.
Subdued when the current layer is not dark.
<div class="ak-layer ak-layer-canvas">
<p class="ak-dark:ak-ink-80 ak-light:ak-ink-70">
Appearance-adjusted secondary text.
</p>
<div
class="ak-layer ak-frame ak-frame-xl/2 ak-frame-border ak-dark-high:ak-edge-20 ak-light-high:ak-edge-10"
>
Stronger edges on the darkest surfaces.
</div>
<p class="not-ak-dark:ak-ink-60">
Subdued when the current layer is not dark.
</p>
</div>
ak-dark/ak-lightand their band variants require a parentak-layer. They’re implemented as@containerstyle queries, so they silently fail to match outside a layer rather than falling back to a default. Negated variants match whenever the queried layer value is absent or different, so wrap them in anak-layerwhen relying on layer appearance.
For ::before and ::after, the originating element can be the query container. For example, ak-light:before:border-t on an ak-layer element draws a top border on its pseudo-element when that element’s own layer is light. This also works when its layer is inverted relative to the parent.
Outset layer appearance
These variants are for an element with ak-outset. They match the layer around the parent layer, in the same way as the layer appearance variants match on a direct child of that layer.
| Variant | Matches when the layer around the parent layer is… |
|---|---|
ak-outset-dark | Dark. |
ak-outset-light | Light. |
ak-outset-dark-high | The darkest tier. |
ak-outset-dark-low | A dark mid-tier. |
ak-outset-light-low | A light mid-tier. |
ak-outset-light-high | The lightest tier. |
Each of these variants also has a not-* counterpart, such as not-ak-outset-dark.
<div class="ak-layer ak-layer-canvas">
<button class="ak-layer ak-layer-primary relative ak-frame ak-frame-xl/2">
Selected tab
<span
class="ak-layer ak-layer-contrast ak-outset ak-outset-light:h-[3px] ak-outset-dark:h-[2px] absolute inset-x-0 -bottom-2"
></span>
</button>
</div>The bar is 3px thick on a light canvas and 2px thick on a dark canvas, whatever the color of the tab.
On a direct child of a layer, these variants match the outer layer whether or not ak-outset applies to the element. For example, [.ak-layer>&:not(.over)]:ak-outset does not apply to an element with the over class, but these variants on it still match the outer layer. To match its parent layer instead, add the regular variants for that case, such as [&.over]:ak-light:h-[3px] [&.over]:ak-dark:h-[2px].
When the parent of the element is not a layer, these variants match the nearest layer like the layer appearance variants.
Accessibility
| Variant | Matches when… |
|---|---|
contrast-more | The user has requested higher contrast (@media (prefers-contrast: more)). Automatically sets --contrast: 100, which pushes ak-text, ak-edge, and ak-outline lightness farther from the layer. |
You can opt extra utilities into high-contrast mode with contrast-more::
<button
class="ak-layer ak-frame ak-frame-xl/2 ak-frame-ring contrast-more:ak-frame-border-2"
>
Extra border weight in high-contrast mode.
</button>