EndCore Framework

CSS tokens and components

Every design token and component class in en-ui's encore.css, with markup for buttons, panels, gauges, badges, fields, toggles, ranges and dialogs.

encore.css holds every colour, typeface, size and curve an EndCore interface uses, plus the components built from them. Your own style.css only positions things. This page lists what is available.

html
<link rel="stylesheet" href="https://cfx-nui-en-ui/ui/encore.css">

Tokens

All tokens are CSS custom properties on :root. Use them with var(--enc-...).

Surfaces and hairlines

TokenValueUse
--enc-void#060605Deepest black
--enc-base#0b0a08Solid backgrounds
--enc-panel#121009Default panel surface
--enc-panel-2#1a170fRaised surface
--enc-panel-3#241f15Highest surface
--enc-glassrgba(11, 10, 8, 0.78)Translucent surface for persistent overlays
--enc-wellrgba(0, 0, 0, 0.35)Recessed areas in overlays
--enc-rulergba(154, 137, 102, 0.16)Default 1px hairline
--enc-rule-strongrgba(196, 169, 112, 0.38)Emphasised hairline

Text

TokenValueUse
--enc-text-hi#fbf8f0Headings, focused values
--enc-text#e0daccBody text
--enc-text-dim#9a9180Labels, secondary text
--enc-text-off#5c5342Fine print, disabled
--enc-legibletwo-layer dark text shadowPut on bare text in overlays so it reads over bright scenes

Accent and danger

TokenValue
--enc-amber#d9a441
--enc-amber-hot#f0c368
--enc-amber-edgergba(217, 164, 65, 0.45)
--enc-amber-washrgba(217, 164, 65, 0.10)
--enc-oxide#b33a2b
--enc-oxide-hot#d9584a
--enc-oxide-flashrgba(179, 58, 43, 0.55)
--enc-oxide-washrgba(179, 58, 43, 0.12)

Stats

TokenValue
--enc-health#b8453a
--enc-armor#6d8ba8
--enc-hunger#c98a3c
--enc-thirst#4d94a8
--enc-stamina#8a9a4a
--enc-radiation#a8c23a
--enc-infection#8b5a9e
--enc-immunity#7a9440
--enc-cold#5a8fa8
--enc-heat#c4622f
--enc-oxygen#8fb8c9

Typefaces

TokenStack
--enc-font-uiBahnschrift, then DIN Alternate, Franklin Gothic Medium, Segoe UI, system-ui, sans-serif
--enc-font-monoConsolas, then SF Mono, Roboto Mono, ui-monospace, monospace

Type scale

TokenSize
--enc-t-micro0.66rem
--enc-t-label0.72rem
--enc-t-small0.82rem
--enc-t-body0.95rem
--enc-t-lead1.15rem
--enc-t-h31.4rem
--enc-t-h22rem
--enc-t-h1clamp(2.4rem, 4vw, 3.6rem)
--enc-t-displayclamp(3.5rem, 9vw, 8rem)

Tracking

TokenValue
--enc-ls-label0.22em
--enc-ls-display0.14em
--enc-ls-ui0.06em
--enc-ls-body0.012em

Spacing

On a 4px grid at the default root size.

TokenValue
--enc-s10.25rem
--enc-s20.5rem
--enc-s30.75rem
--enc-s41rem
--enc-s51.5rem
--enc-s62rem
--enc-s73rem
--enc-s84rem

Easing and durations

TokenValueUse
--enc-easecubic-bezier(0.22, 0.61, 0.36, 1)State changes
--enc-ease-incubic-bezier(0.55, 0.06, 0.68, 0.19)Exits
--enc-ease-hardcubic-bezier(0.16, 1, 0.3, 1)Entrances
--enc-d-instant90ms
--enc-d-fast150msHover
--enc-d-base240msTransitions
--enc-d-slow420ms
--enc-d-reveal650msReveals

Base styles

Loading encore.css also applies a reset suited to NUI:

  • box-sizing: border-box and zero margins and padding on everything.
  • html and body fill the screen and never scroll. Opt specific regions in with .enc-scroll.
  • body is transparent, uses --enc-font-ui at --enc-t-body, and disables text selection.
  • Form controls inherit font, tracking and colour. Buttons have no background or border.
  • [hidden] and .enc-hidden are display: none !important.

Typography

ClassWhat it is
.enc-labelStencil label: small, bold, uppercase, 0.22em tracking, dim. The workhorse for section headers, field names and button text
.enc-label--accentLabel in amber
.enc-microFine print: micro size, uppercase, tracked, faint
.enc-displayHuge condensed uppercase display type
.enc-h1Condensed uppercase page heading
.enc-h2Uppercase section heading
.enc-h3Sub-heading
.enc-dimDim text colour
.enc-offFaint text colour
.enc-numConsolas with tabular figures. Use it for every number
.enc-rule-accentDraws a short amber rule under the element
html
<header>
    <span class="enc-label enc-label--accent">Camp stash</span>
    <h1 class="enc-h1 enc-rule-accent">North Ridge</h1>
    <span class="enc-micro">Weight <span class="enc-num">42.5</span> / <span class="enc-num">80</span> kg</span>
</header>

Panels and brackets

ClassWhat it is
.enc-panelSurface with --enc-panel background and a 1px hairline border
.enc-panel--raisedUses --enc-panel-2
.enc-panel--solidUses --enc-base
.enc-bracketsAmber corner marks at top-left and bottom-right, shown on hover or with .is-active
html
<article class="enc-panel enc-brackets is-active">
    <span class="enc-label">Selected</span>
    <p>Hunting rifle</p>
</article>

Buttons

ClassWhat it is
.enc-btnUppercase button with the clipped corner and a light sweep across it on hover
.enc-btn--primarySolid amber
.enc-btn--dangerOxide red; fills red on hover
.enc-btn--ghostTransparent with a faint border
  • Disabled buttons turn faint and lose the hover sweep.
  • Keyboard focus is drawn as an inset amber ring, because the clipped corner would cut off an outline.
html
<button class="enc-btn enc-btn--primary">Take all <span class="enc-key">E</span></button>
<button class="enc-btn">Split</button>
<button class="enc-btn enc-btn--danger">Drop</button>
<button class="enc-btn enc-btn--ghost">Cancel <span class="enc-key">ESC</span></button>

Keycaps

.enc-key is a small monospace keycap for hints like [E] or [ENTER], inside buttons or on its own. Inside a primary button it switches to dark ink.

Gauges

.enc-bar is a thin horizontal gauge with calibration ticks, used for survival stats and load progress.

ClassWhat it is
.enc-barThe track, 4px tall
.enc-bar--thick7px tall
.enc-bar__fillThe fill. Set its width as a percentage. Amber with a glow by default
.enc-bar__ticksTick overlay at every 10%
.enc-bar--health, --hunger, --thirst, --radiation, --infection, --immunityStat-coloured fill
html
<div class="enc-bar enc-bar--thick enc-bar--hunger">
    <div class="enc-bar__fill" style="width: 64%"></div>
    <div class="enc-bar__ticks"></div>
</div>

The fill animates its width with --enc-d-slow and --enc-ease-hard. For bursty values such as load progress, drive it with Encore.progress, which never moves backwards.

Stat modifiers exist for the six stats above. For armour, stamina, oxygen, cold and heat, use the stat tokens.

Badges and status dots

ClassWhat it is
.enc-badgeSmall uppercase tag in amber
.enc-badge--dangerOxide red
.enc-badge--muteFaint, no background
.enc-dot6px status dot, faint by default
.enc-dot--liveAmber, glowing and slowly pulsing
html
<span class="enc-badge">Leader</span>
<span class="enc-badge enc-badge--danger">Infected</span>
<span class="enc-dot enc-dot--live"></span> <span class="enc-label">On radio</span>

Form controls

Fields

.enc-field styles text inputs, selects and text areas.

  • Focus brightens the background and turns the border amber.
  • Number and date inputs use the monospace face with tabular figures and dark native pickers.
  • select.enc-field has its native arrow removed. Wrap it and add Encore.icon('chevron') yourself.
  • textarea.enc-field is at least 4.5rem tall and resizes vertically.
html
<label>
    <span class="enc-label">Base name</span>
    <input class="enc-field" type="text" maxlength="24" placeholder="North Ridge">
</label>

Toggles

.enc-toggle is a rectangular switch with a sliding .enc-toggle__knob. Its state lives in aria-checked.

html
<button class="enc-toggle" role="switch" aria-checked="false" id="blip">
    <span class="enc-toggle__knob"></span>
</button>
js
const toggle = document.getElementById('blip');
toggle.addEventListener('click', () => {
    const on = toggle.getAttribute('aria-checked') !== 'true';
    toggle.setAttribute('aria-checked', String(on));
});

Ranges

.enc-range styles a range input. Set the --fill custom property from script so the track shows the value.

html
<input class="enc-range" type="range" min="0" max="100" value="40" id="volume">
js
const range = document.getElementById('volume');
const paint = () => range.style.setProperty('--fill', `${range.value}%`);
range.addEventListener('input', paint);
paint();

Scroll regions

The page itself never scrolls. Give a list .enc-scroll to make it scroll vertically with a thin hairline scrollbar.

Modals

ClassWhat it is
.enc-scrimFixed full-screen backdrop that darkens and blurs the game, and centres its child
.enc-dialogPanel with an amber top edge that rises into place
.enc-dialog--dangerOxide red top edge, for destructive confirmations
html
<div class="enc-scrim" id="confirm" hidden>
    <div class="enc-dialog enc-dialog--danger" role="dialog" aria-modal="true" aria-labelledby="confirm-title">
        <h2 class="enc-h3" id="confirm-title">Abandon base?</h2>
        <p class="enc-dim">Everything stored here will be lost.</p>
        <button class="enc-btn enc-btn--ghost" id="confirm-no">Keep it</button>
        <button class="enc-btn enc-btn--danger" id="confirm-yes">Abandon</button>
    </div>
</div>

Trap focus inside an open dialog with Encore.trapFocus.

Persistent overlay root

Put class="enc-overlay" on the html element of always-on interfaces such as HUD pieces. The root font size then tracks screen height:

css
html.enc-overlay {
    font-size: calc(clamp(11px, 1.4815vh, 26px) * var(--enc-overlay-scale, 1));
}

That is 16px at 1080p, clamped between 11px and 26px. Size everything in rem and the overlay is the same physical size on any monitor. Set --enc-overlay-scale to let players resize the whole overlay.

Icons

.enc-icon styles the SVGs from Encore.icon(): 1.25em square, no fill, currentColor stroke at 1.75, square caps and mitred joins. Change an icon's colour by setting color on it or its parent. See Icons.

Motion classes

ClassAnimation
.enc-anim-riseFades in while rising 14px, over --enc-d-reveal
.enc-anim-slideFades in while sliding from the left, over --enc-d-base
.enc-anim-wipeWipes in from left to right, over --enc-d-slow
.enc-staggerDelays the animation by --enc-i × 55ms. Set --enc-i with Encore.stagger(nodes)
html
<ul id="roster">
    <li class="enc-panel enc-anim-rise enc-stagger">...</li>
    <li class="enc-panel enc-anim-rise enc-stagger">...</li>
</ul>
js
Encore.stagger(document.querySelectorAll('#roster li'));

All animation and transition durations collapse to almost nothing under prefers-reduced-motion: reduce.

Texture layers

.enc-grain, .enc-scanlines, .enc-vignette and .enc-haze are fixed, click-through layers. You don't write them by hand: Encore.mountTexture() injects them. See Texture.