Animated canvas background component with slotted content. Renders particle/character animations behind any content placed inside the element.
<x-kinetic-canvas type="starfield">
<h1>Content renders on top</h1>
</x-kinetic-canvas>
| Attribute | Type | Default | Description |
|---|---|---|---|
type | string | starfield | Animation type: starfield, bubbles, matrix |
variant | string | motion | Type-specific variant. Starfield: motion, twinkle |
speed | string | medium | Animation speed: slow, medium, fast, or numeric multiplier |
density | string | medium | Entity density: low, medium, high, or numeric multiplier |
fullscreen | boolean | false | When present, positions fixed to fill the viewport |
paused | boolean | false | When present, pauses the animation loop |
| Property | Type | Reflects Attribute |
|---|---|---|
type | string | type |
variant | string | variant |
speed | string | speed |
density | string | density |
fullscreen | boolean | fullscreen |
paused | boolean | paused |
None.
None.
| Slot | Description |
|---|---|
| default | Content rendered on top of the animated background |
| Property | Default (light) | Default (dark) | Description |
|---|---|---|---|
--x-kinetic-canvas-bg | var(--x-color-bg, #f0f0f5) | var(--x-color-bg, #0a0a1a) | Canvas background fill |
--x-kinetic-canvas-color-1 | var(--x-color-text, #1a1a2e) | var(--x-color-text, #ffffff) | Primary entity colour |
--x-kinetic-canvas-color-2 | var(--x-color-primary, #2563eb) | var(--x-color-primary, #60a5fa) | Secondary entity colour |
--x-kinetic-canvas-color-3 | var(--x-color-secondary, #7c3aed) | var(--x-color-secondary, #c084fc) | Tertiary entity colour |
--x-kinetic-canvas-matrix-font-size | 14 | 14 | Font size (px) for matrix rain characters |
--x-kinetic-canvas-z | -1 | -1 | z-index for fullscreen mode (behind content by default) |
Colours integrate with x-theme tokens and adapt to light/dark colour scheme automatically.
Stars at varying depths with two variants:
Soft circles floating upward with horizontal drift. Wrap around at screen edges.
Falling columns of characters (Katakana + Latin) with brightness falloff from head to tail.
aria-hidden="true"prefers-reduced-motion: reduce — renders a single static frame, no animation looprequestAnimationFrame for smooth 60fps animationdevicePixelRatio for sharp rendering on HiDPI displays<!-- Page background -->
<x-kinetic-canvas type="starfield" fullscreen></x-kinetic-canvas>
<!-- Section background -->
<x-kinetic-canvas type="bubbles" speed="slow" density="low" style="height: 400px;">
<div style="padding: 2rem; color: white;">
<h2>Hero section</h2>
<p>Content on top of animated bubbles</p>
</div>
</x-kinetic-canvas>
<!-- Custom colours -->
<x-kinetic-canvas type="matrix"
style="--x-kinetic-canvas-bg: #000;
--x-kinetic-canvas-color-1: #0f0;
--x-kinetic-canvas-color-2: #0a0;
--x-kinetic-canvas-color-3: #050;">
</x-kinetic-canvas>
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |