Liquid metal
A chrome surface that ripples like mercury.
<piix-shader>WebGL<piix-shader kind="liquid" height="420px"></piix-shader>
Palette
A height field shaded like polished metal, with sharp highlights sliding over it. In mono it is pure chrome; in a colour palette it turns into anodised metal.
Installation
<!-- once, anywhere on the page: every component --> <script src="https://cdn.jsdelivr.net/npm/piixpal@0.6/piixpal.min.js"></script>
<!-- just liquid metal (the shared engine loads itself, once) --> <script src="https://cdn.jsdelivr.net/npm/piixpal@0.6/dist/c/shader.min.js"></script>
npm install piixpal // once, in your entry file import "piixpal";
// npm install piixpal
import "piixpal";
export default function Page() {
return (
<piix-shader kind="liquid" height="420px"></piix-shader>
);
}
Usage
<piix-shader kind="liquid" height="420px"></piix-shader>
Examples
Behind your content
With fill it sits behind everything else in the element it's in. Give that element position: relative (the shader does this for you if it's static).
Ship it loud
Your content sits on top.
<section class="ex-fill"> <piix-shader kind="liquid" fill pixel="5"></piix-shader> <h2>Ship it loud</h2> <p>Your content sits on top.</p> </section>
Other palettes
Every palette works with every background.
<div class="ex-row"> <piix-shader kind="liquid" palette="ocean" height="180px"></piix-shader> <piix-shader kind="liquid" palette="gameboy" height="180px"></piix-shader> <piix-shader kind="liquid" palette="#0b0a10,#3a2a6b,#ff6b4a,#ffe8a8" height="180px"></piix-shader> </div>
Smooth bands
dither="0" swaps the dither pattern for flat colour bands, like a poster.
<piix-shader kind="liquid" dither="0" pixel="6" height="220px"></piix-shader>
API reference
| Attribute | What it does | Default |
|---|---|---|
kind | mesh warp aurora crystal liquid horizon nebula topo dots fire | mesh |
palette | the colours: lime aurora sunset ocean candy violet fire gameboy paper mono, or your own, dark to light: "#000,#6b4cff,#fff" | mono |
pixel | size of one pixel, in px | 4 |
dither | 0 for flat colour bands, 1 for full dither | 1 |
speed | 1 is normal, 0 holds still | 1 |
height | when not filling: px or any CSS length | 360px |
fill | sit behind the content of the parent element | – |
Accessibility
- It is decoration: hidden from screen readers.
- With reduced motion it renders one still frame.
- It only draws while it is on screen, and every Pixel UI component shares one GPU context.