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.

VariantMatches when the parent layer is…
ak-darkDark (would render white-ish text).
ak-lightLight (would render black-ish text).
ak-dark-highThe darkest tier.
ak-dark-lowA dark mid-tier.
ak-light-lowA light mid-tier.
ak-light-highThe 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.

Stronger edges on the darkest surfaces.

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-light and their band variants require a parent ak-layer. They’re implemented as @container style 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 an ak-layer when 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.

VariantMatches when the layer around the parent layer is…
ak-outset-darkDark.
ak-outset-lightLight.
ak-outset-dark-highThe darkest tier.
ak-outset-dark-lowA dark mid-tier.
ak-outset-light-lowA light mid-tier.
ak-outset-light-highThe 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

VariantMatches when…
contrast-moreThe 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>