Liquid toggle
A switch whose knob is a drop of liquid metal.
<piix-liquid-toggle>WebGLForm-readyNew<piix-liquid-toggle label="Dark mode"></piix-liquid-toggle>
Look
Flip it and the drop stretches across the track with a tail of liquid trailing behind, then snaps back into a bead as the track darkens. A real switch for forms.
Installation
<!-- once, anywhere on the page: every component --> <script src="https://cdn.jsdelivr.net/npm/piixpal@0.6/piixpal.min.js"></script>
<!-- just liquid toggle (the shared engine loads itself, once) --> <script src="https://cdn.jsdelivr.net/npm/piixpal@0.6/dist/c/liquid-toggle.min.js"></script>
npm install piixpal // once, in your entry file import "piixpal";
// npm install piixpal
import "piixpal";
export default function Page() {
return (
<piix-liquid-toggle label="Dark mode"></piix-liquid-toggle>
);
}
Usage
<piix-liquid-toggle label="Dark mode"></piix-liquid-toggle>
Examples
In a form
<label style="display:flex;gap:12px;align-items:center;color:#fff"> <piix-liquid-toggle name="alerts" checked label="Alerts"></piix-liquid-toggle> Alerts </label>
API reference
| Attribute | What it does | Default |
|---|---|---|
checked | on | – |
name | form field name (sends on) | – |
label | accessible name | Toggle |
look | chrome ink water honey: the liquid's material | chrome |
colors | your own material, three colours: floor, horizon, sky (overrides look) | – |
Events
| Event | When |
|---|---|
change | when it flips |
Accessibility
- A real switch: role="switch", Space and Enter flip it, aria-checked follows it.
- Form-associated.
- With reduced motion it jumps without the stretch.