vUX · FontSplash · the loader is a word

Your name, loading.

FontSplash sets a word in the font you choose and makes it the loader: a gradient flows through the letters while they fade in a wave. It waits for the font, so the word never shows in the wrong face. You saw it when this page opened.

font
animation

01Playground

Every config property, live. Look settings restyle a splash that is already up, and changing the text or the font rebuilds the letters in place. Hide and Show to see the timing settings at work.

config
splash · container mode
hidden · press Show
state idle · fontStatus none
equivalent code

                
onShow / onHide

02When you know how far along it is

setProgress(0…1) turns the word into a progress bar: the gradient fills the letters from the left and the track shows what is left. setProgress(null) goes back to indeterminate. Screen readers get a progressbar with the percentage instead of a status.

03The font comes first

The backdrop goes up at once, and the word appears only when its font is ready, or when fontTimeout runs out. Each card replays a splash with a different kind of font and prints what happened, in milliseconds from show().

A face of its own

font: { family, src }. FontSplash registers the face with document.fonts and loads it. Here src is a local() font on this machine.

A family the page declares

font: "Page Display", declared by this page's own @font-face. FontSplash asks the browser to load it now, rather than whenever it would first paint.

A file that is not there

src: "fonts/missing.woff2". The load fails, a warning goes to the console, and the word is shown in the fallback list rather than not at all.

Bytes you hand it

src: arrayBuffer, from a file input. Pick a .woff2, .ttf or .otf from your machine; nothing is uploaded anywhere.

04Four animations, four exits

animation is how the word moves while it waits; exit is how the splash leaves. Press Hide on a card to see its exit; it comes back a moment later. With reduce motion set in your system, the gradient holds still and the letters do not pulse.

05As the page's splash screen

With no element, a splash covers the viewport. This is all this page does to get the splash you saw when it opened. The cloak in <head> is the part a library cannot do for you: it has to be there before any script runs.

index.html · <head>
<!-- hidden from the first paint -->
<html class="vux-fs-cloak">
<style>
  .vux-fs-cloak body{
    visibility:hidden;
    /* safety net if the script never runs */
    animation:vux-fs-uncloak 0s 4s forwards;
  }
  @keyframes vux-fs-uncloak{to{visibility:visible}}
</style>
main.js
const splash = new FontSplash();
splash.config.text = "vUX";
splash.config.font = { family: "Brand",
                       src: "/fonts/brand.woff2" };
splash.config.background = "#080b11";
splash.initialize();

// up until the page has loaded and booted
await splash.during(boot());

06What it refuses to do

Each button misuses the API on purpose and prints the Error it throws. Settings are checked when they are made, not later inside a timer.

pick one