Skip to content

shadcn.io is an independent project built on shadcn/ui

Pro

Heatmap Background for Vue

A thermal camera view: bodies of heat, isotherms and a pointer trail. For Vue with Ark UI, when a page should feel measured.

On this page10 sections
UI library: Ark UI

A thermal camera's view of nothing in particular: slow bodies of heat drift across the box, drawn through a cold-to-hot ramp that is cut into isotherms, each marked with a thin line. It's a GLSL scene on WebGL2 with no dependency, plus a small simulation that keeps the heat the pointer leaves behind while it spreads and cools. The cold end of the ramp fades into the surface, so the image sits on a light page as well as a dark one, and the hottest colors keep to the top and bottom edges.

Use it behind an analytics hero, an observability page or an energy product. For the same stepped bands without the thermal ramp or the trail, use Plasma; for contour lines alone, with no fill, Topography; for soft color with no isotherms at all, Gradient Animation. With reduced motion it holds one still frame.

Playground
Heatmap Background, still
Customize

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Usage

<script setup lang="ts">
import { Heatmap } from "@/components/ui/heatmap";
</script>
<template>
  <Heatmap class="flex min-h-[32rem] items-center justify-center">
    <h1 class="text-5xl font-semibold">See where visitors slow down</h1>
  </Heatmap>
</template>

Heatmap is a container: whatever you put inside sits on top of the image, in normal flow. It fills its own box, so give it a height or content. For a backdrop behind the whole page, render it empty with className="fixed inset-0 -z-10".

Presets

Thermalthe default lookTry it
<Heatmap />
ArcticTry it
<Heatmap
  :colors="['#0b1d51', '#1565c0', '#26c6da', '#e0f7fa']"
  :contours="0.3"
  :lines="0.6"
  :spread="0.6"
/>
EmberTry it
<Heatmap
  :colors="['#3b0a0a', '#b71c1c', '#ff5722', '#ffc107']"
  :detail="0.8"
  :intensity="1.3"
  :scale="1.3"
  :spread="0.3"
/>
Hazethe default lookTry it
<Heatmap
  :contours="0"
  :lines="0"
  :scale="0.7"
  :spread="0.7"
  :trail="0.8"
/>
MonoTry it
<Heatmap
  :colors="['var(--muted)', 'var(--muted-foreground)']"
  :contours="1"
  :lines="0.8"
/>
Stepsthe default lookTry it
<Heatmap :contours="1" :levels="5" :lines="1" />
ViridisTry it
<Heatmap
  :colors="['#440154', '#3b528b', '#21918c', '#5ec962', '#fde725']"
  :contours="1"
  :levels="7"
  :lines="0.6"
/>

Each preset is a set of props, so copy one and keep tuning. Thermal is the default, an ironbow ramp from indigo to pale yellow. Arctic is the cold half of a camera's range, Viridis uses the scientific colormap with hard steps, Haze drops the isotherms for one smooth glow, and Mono takes its two colors from your theme and reads as a contour map.

Examples

Hero

The default look behind a centered hero. Across the middle of the box the heat is held to the cooler half of the ramp, so the headline sits on indigo and crimson on a dark page and on their lifted tones on a light one; the orange and yellow cores show along the top and bottom edges.

Preview width

Colors

colors runs from cold to hot: here navy, blue, cyan and ice on a dark surface. contours={0.3} softens the steps, lines={0.6} strengthens the line on each isotherm, and spread={0.6} warms a little more of the box.

Preview width

In a card

Hard steps for a small box: contours={1} with levels={6} and lines={0.8}, and scale={0.8} for larger bodies of heat. fade="bottom" clears the lower edge, where the copy sits.

Preview width

Customization

Every color is a CSS color, so a theme variable works and follows a theme switch: colors={["var(--muted)", "var(--chart-1)", "var(--chart-2)"]}. The list runs from cold to hot, and the cold end always fades into the surface. levels sets how many steps the ramp has, contours how flat each step is, and lines how strongly a line marks each isotherm. spread and scale set how much of the box is warm and how large the bodies of heat are; radius and trail set the size of the heat the pointer leaves and how long it takes to cool.

The surface is the root's own background, bg-background by default. Give the root another (bg-slate-950, a brand color) and the image adapts: on a light surface the deep colors of the ramp are lifted to a lighter tone and the cold end fades out sooner. fade masks an edge, opacity turns the whole effect down, and grain adds sensor noise.

<Heatmap
  className="min-h-[32rem] bg-slate-950"
  colors={["var(--muted)", "var(--chart-1)", "var(--chart-2)"]}
  contours={1}
  grain={0.2}
  levels={6}
/>

Performance

It's one WebGL2 canvas with two small shaders. The scene takes four samples of simplex noise for the field and four texture reads for the pointer's heat, then maps the sum through the ramp. The simulation is a buffer a quarter of the box's size on each side, which takes five reads a texel 60 times a second. It draws only while it's on screen and the tab is visible, shares one frame loop with every other background on the page, and lowers its own resolution if frames run long. quality sets the render scale yourself, and paused holds the frame.

Accessibility

The image is decoration: it's hidden from assistive tech and lets every click through to your content. With reduced motion it draws one still frame, with no trail. Nothing flashes: a press adds a burst of heat that fades over a second or two.

At contrast 1 or lower, copy in the foreground color (text-foreground) reads across the middle of the box: with the default palette the worst frame measured 5.4:1 on a light surface and 4.7:1 on a dark one. The top and bottom fifth of a dark box can hold orange and yellow, which white text doesn't read on, so keep copy off those edges, use fade, or lower intensity. Past contrast 1 the full ramp runs anywhere.

FAQ

How do I change the colors?

Pass two to eight CSS colors to colors, from cold to hot. The first one fades into the page, so it barely shows; the last is the core of the hottest spots. Hex, oklch() and theme variables all work. For a ramp that reads as temperature, go from a dark color to a bright one.

How does the pointer's heat trail work?

A small simulation keeps a buffer of heat. Each step, the pointer warms the stretch it has covered since the last one, and every texel spreads a little to its neighbors and cools. radius is the size of the warm spot in pixels and trail is how long it takes to cool, from at once to a few seconds. interactive={false} turns it off.

Does it work on a light page?

Yes, with no prop to set. The scene reads the color behind it. On a light surface the cold end of the ramp fades out sooner and the deep colors are lifted to a lighter tone, so dark copy stays readable over them. Set the surface with a class on the component, such as bg-slate-950.

Can I remove the contour steps?

contours={0} gives one smooth ramp and lines={0} removes the line on each isotherm; the Haze preset sets both. Going the other way, contours={1} makes every step flat and levels sets how many there are, from 3 to 16.

How do I put it behind the whole page?

Render it empty with className="fixed inset-0 -z-10". It still follows the pointer there, since it listens on the window, so the trail runs under your content. To put it behind one section, wrap that section's content in it and give it a height, such as min-h-svh.

Is the simulation expensive?

No. The buffer holds one sixteenth of the box's pixels and each step is five texture reads a texel. The scene itself is four noise samples a pixel. Nothing runs while the background is off screen or the tab is hidden, and if a device can't keep up it renders fewer pixels by itself.

Does it work with Next.js and server components?

Yes. Import it into a server component and it renders its box and your content on the server; the canvas starts in the browser and fades in over the surface. It needs WebGL2, which every current browser has. Without it the box keeps its background, or the fallback you pass.

What happens with reduced motion?

It draws one still frame of the heat and stops. The pointer leaves no trail and a press adds no burst. The frame is the same every time, so the page looks the same on each visit, and seed picks another layout.

API Reference

Heatmap

data-slot="heatmap"

PropType
colors?string[]

Two to eight CSS colors, from cold to hot. The cold end fades into the surface. Theme variables such as var(--chart-1) follow your theme.

Default
["#2a1675", "#8a1fa6", "#e0245e", "#ff7a2b", "#ffd75e"]
contours?number

How stepped the colors are, from 0 (one smooth ramp) to 1 (flat bands between the isotherms).

Default
0.6
contrast?number

How strongly the image shows, from 0 to 2. Up to 1 it stays in a tone copy reads on; past 1 the palette runs at full strength everywhere.

Default
1
detail?number

How much the isotherms wander, from 0 (round bodies of heat) to 1.

Default
0.5
fade?"none" | "radial" | "top" | "bottom" | "left" | "right"

Which edges fade out to the surface: radial keeps the middle, the others name the side that fades.

Type
"none" | "radial" | "top" | "bottom" | "left" | "right"
Default
"none"
fallback?string

What shows until the first frame and in browsers without WebGL2: a CSS background value that looks like the scene.

grain?number

Film grain over the scene, from 0 to 1.

Default
0
intensity?number

How hot the scene runs, from 0 to 2.

Default
1
interactive?boolean

Whether the scene follows the pointer and answers a press. Touch never moves it, so scrolling a page on a phone isn't disturbed.

Default
true
levels?number

How many steps the ramp is cut into, from 3 to 16.

Default
9
lines?number

How strongly a thin line marks each isotherm, from 0 to 1.

Default
0.4
opacity?number

How strongly the scene shows over the surface, from 0 to 1.

Default
1
paused?boolean

Holds the current frame.

Default
false
quality?number

Render scale, from 0.25 to 1, of the screen's pixels (capped at 2×). Lower is cheaper and softer.

Default
1
radius?number

The size of the heat the pointer leaves, in pixels.

Default
56
scale?number

The size of the bodies of heat, from 0.4 to 2: higher packs more, smaller ones.

Default
1
seed?number

Another layout of the heat, from 0 to 20.

Default
0
speed?number

Animation speed: 1 is normal, 0 holds the frame.

Default
1
spread?number

How much of the box is warm, from 0 (a few hot spots) to 1 (heat across most of it).

Default
0.5
time?number

A fixed moment, in seconds: draws it and doesn't animate.

trail?number

How long the pointer's heat takes to cool, from 0 (at once) to 1 (a few seconds).

Default
0.5