Custom CSS docs · Styles that adapt

Custom CSS

Styles that adapt

Use Linker's variables instead of fixed colours, so your CSS fits any page.

Fixed colours break when the Look tab changes. Variables follow it.

Two Linker pages with the same light, warm Look settings. On the left, CSS with hard-coded colours has painted a dark navy background, and the name and description have all but vanished into it. On the right, CSS built from variables keeps the warm background, with orange buttons and legible text.

Left: fixed colours. Right: variables.

Don’t:

:root {
  background: #111827;
}

:is([data-part="link"], [data-part="social"]) {
  background: #f9fafb;
  border-color: #f9fafb;
  color: #111827;
  border-radius: 999px;
}

Do:

:root {
  background: var(--linker-bg);
}

:is([data-part="link"], [data-part="social"]) {
  background: var(--linker-button);
  border-color: var(--linker-button);
  color: var(--linker-button-text);
  border-radius: 999px;
}

Mixing your own shades

Use color-mix() for tints and shades:

[data-part="description"] {
  /* Softer text. */
  color: color-mix(in oklab, var(--linker-text) 70%, var(--linker-bg));
}

:is([data-part="link"], [data-part="social"]) {
  /* A slightly darker frame. */
  border-color: color-mix(in oklab, var(--linker-button), black 20%);
}

:root {
  /* A glow in the corner. */
  background-image: radial-gradient(
    circle at 15% 10%,
    color-mix(in oklab, var(--linker-button) 40%, transparent),
    transparent 45%
  );
}

For corners, use var(--linker-radius).

What your CSS takes over

Whatever you set yourself stops following the Look tab:

  • Colours you set override the Look tab’s colours.
  • A background on :root replaces your background picture. See the recipe to keep it.
  • Your own button background, border and colour override the button style.
  • Your own transform or box-shadow on hover override the hover effect.

To change something only for some settings, see State attributes.