Mixins and functions

The Sass API you use when authoring a theme. Every accessor returns a var(--jf-*) reference (so runtime overrides flow through) unless noted; interpolate (#{…}) when using one inside another value.

Tokens

Token functions
FunctionDoes
token($name, $fallback?)Reference a custom property, applying the $token-prefix. token(font-primary)var(--jf-font-primary). (Was v() in v4.)
token-or($stem, $fallback-stem)A component token that falls back to a shared one. token-or(card-border-color, border-color)var(--jf-card-border-color, var(--jf-border-color)). For opt-in seams not declared by default.
token-name($name)Just the prefixed name, for declaring: #{token-name(x)}: …--jf-x: ….

Colour

The consumer-facing colour API is five functions plus token().

Colour functions
FunctionUse whenExample
get-color($family, $shade: 500)you want a specific numbered shade.get-color(primary, 700)
var(--jf-color-primary-700)
get-color-role($family, $role)you want a family by intent (subtle / muted / emphasis / strong) — flips in dark mode.get-color-role(primary, emphasis)
var(--jf-color-primary-emphasis)
get-on-color($x, $shade?)you need text for a background — a family + shade, or a single resolved value (a --jf-color-* ref, a --jf-color-bg*, or a one-off colour).get-on-color(primary, 700)
var(--jf-color-on-primary-700)
get-color-raw($family, $shade)you need the literal colour — SVG data-URIs, rgba(), Sass colour maths.get-color-raw(primary, 500)
#eb567d (the seed)
role-shade($role)you need the raw shade number a role maps to.role-shade(emphasis)
700

makeColorPalette($seed) — turns one seed colour into the 25–1000 ramp, with the seed as 500. Jellyfish calls it for you on every $colors entry, so you write ("brand": #0b7) and get this. Call it yourself only to build a ramp outside the palette:

1000
900
800
700
600
500
400
300
200
100
50
25

Under the hood

The .bg-* / surface() code calls these — you shouldn't need them directly. resolve-contrast-color($bg, $dark?) picks WCAG-safe text (white / $color-text / black). raw-color(), palette-ref-parts(), surface-contrast-color(), surface-heading-color() do the contrast plumbing for a coloured background.

Type

Type functions and mixins
HelperDoesExample
#{headings($from: 1, $to: 6)}Selector list for h1h6 (or a sub-range).#{headings(1, 3)}
h1, h2, h3
@include type($step, $important?)Sets font-size (a fluid clamp() for md+) and the paired line-height from $type-leading — they can't drift apart.@include type(lg);
font-size: clamp(…); line-height: 1.35;
@include h1()h6()type() with the step from $heading-scale. The .h1.h6 classes call these with $important: true.@include h3();
→ same output as an <h3>
fluid($minPx, $maxPx, $minVw?, $maxVw?)A clamp() sliding between two px sizes across a viewport range.fluid(24px, 30px)
clamp(1.5rem, …, 1.875rem)
rem($value)px → rem (against $root-size); non-px passes through.rem(24px)
1.5rem
em($px)px → em (16px root). For media queries.em(900px)
56.25em
@include text-replace / .text-replaceHide text, show a background image in its place. See the example below.

.text-replace keeps the text for semantics / SEO / screen readers, but paints a background image over it — give the element a fixed width / height matching the image:

Jellyfish UI

Design-axis accessors

One per non-colour scale — each validates the step (build-time error listing valid keys if you mistype) and returns the --jf-* reference. See Design Tokens for the values.

Axis accessor functions
FunctionStepsReturns
get-space($step)3xs 2xs xs sm md lg xl 2xlvar(--jf-space-md) — margin / padding / gap
get-size($n)$sizing-system keysraw length (4rem) — fixed dimensions, calc operands
get-radius($step)none xs sm md lg xl 2xl fullvar(--jf-radius-md)
get-leading($step)flush tight snug base loosevar(--jf-leading-tight)
get-weight($step)hairline thin light normal medium semibold bold xbold blackvar(--jf-font-weight-bold)
get-shadow($step)none xs sm md lg xlvar(--jf-shadow-md)
get-duration($step)instant fast base slow slowervar(--jf-duration-base)
get-ease($step)in out in-out springvar(--jf-ease-out)

Motion

@include motion($properties...) transitions each property on var(--jf-transition), so prefers-reduced-motion (which zeroes the duration tokens) switches it off. For one property, write transition: var(--jf-transition) directly. To change speed / curve for a region, redeclare --jf-transition (or a --jf-duration-* / --jf-ease-*) on a scope.


    .drawer {
      --jf-transition: var(--jf-duration-slow) var(--jf-ease-out);
      @include motion(transform, opacity);
    }
  

motion(transform) — hover.

motion(background, transform, color) — hover.

Misc

Other mixins
MixinDoes
@include icon($size: 1em)A mask-based icon in the current text colour, masked from --jf-icon (set that to a url() on the same selector). Backs .icon — see Utilities.
@include pseudo($content: "", $display: block, $pos: absolute)The three properties a pseudo-element always needs.
@include do-not-print / .do-not-printdisplay: none in @media print.
@include in-dark-mode / in-light-modeWrap a non-token override (nested inside the selector it applies to) in the same dark-mode precedence as :root. See Theme colours.
above() / below() / between()Media-query mixins — see Breakpoints.
container-above() / -below() / -between()Container-query equivalents — see the dedicated Container Queries page.