Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Backgrounds

Pro

Neon Background for React

A wall lit by neon: a large rounded frame of glowing tube with a second colour inside it, humming softly and flickering now and then. For React with Base UI, when a music, gaming or event page wants the look of a night-time sign.

Framework

A large rounded frame of hot-pink neon runs round the box, with two cyan tubes inside it, each one turning a corner, and the light they cast washes the faintly textured wall. Each tube has a pale core, a tight glow, a wide bloom and a halo on the wall, all drawn once by a stack of static drop-shadows; only their brightness moves, a slow hum and, now and then, a quick flicker like a tired transformer, through CSS keyframes the install adds to your stylesheet, so the browser composites it and no script runs. On a light theme they turn into coloured glass tubes with a soft glow and a shadow on a pale wall.

Use it on music, gaming or event pages that want a night-time sign, with your headline inside the frame. For glowing rings receding into a tunnel, use Portal; for neon beams racing along a grid, Laser Grid; for the synthwave floor, Retro Grid; for the same mood broken up, Glitch.

Preview width

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

import { Neon } from "@/components/ui/neon";
<Neon className="flex min-h-[480px] items-center justify-center">
  <h1 className="text-5xl font-semibold">Live tonight</h1>
</Neon>

Neon is a container: give it a size, put your content inside, and the wall sits behind it. The tubes follow the box's proportions, so the frame fits a banner, a card or a phone screen. For the whole page, pass className="fixed inset-0 -z-10".

Demos

Colours

colors takes two CSS colours, the frame's and the inner tubes'; here amber and violet, with intensity="strong" for a wider bloom, on a card that stays dark in both themes.

Preview width

Steady

flicker={false} keeps only the hum, intensity="subtle" dims the glow and speed={0.5} slows the hum, for a calm card behind body text.

Preview width

Accessibility

The wall is decorative: it's hidden from screen readers and lets every click through to your content. The flicker is rare and shallow: each tube stutters about once every 11 to 17 seconds, two quick dips that never go dark, well under once a second over the whole wall, and the stylesheet clamps speed so a faster setting can't make it more frequent. With reduced motion the tubes shine steadily, with no hum and no flicker. The middle of the wall stays dark (pale, on a light theme), so text inside the frame keeps your page's contrast; keep it in your foreground colour.

FAQ

How are the tubes drawn?

Each tube is an element's border (the frame all four sides, the inner tubes two) in a pale tint of its colour, with a stack of drop-shadows for the glow: tight, wider, a bloom and the light on the wall. They're drawn once; only the opacity of each tube's wrapper animates.

Can I change the colours?

Yes: colors={["…", "…"]} takes the frame's colour, then the inner tubes'; one colour is used for both. You can also set --neon-color-1 and --neon-color-2 from your CSS.

Can I turn off the flicker?

Yes: flicker={false} keeps the slow hum and drops the stutter. Reduced motion turns both off.

How do I make it glow more or less?

intensity sets the glow's reach and strength: subtle, medium or strong. --neon-bloom multiplies the blur radii directly.

What does it look like in light mode?

Coloured glass tubes on a pale wall: the colour itself as the core, a soft glow and a little shadow underneath, as if the tubes stood off the wall. Put the component in a dark element to keep the night look in both themes.

Is it heavy?

No. The glows are painted once; three layers animate only their opacity, so the browser composites them, and no script runs.

API Reference

Neon

<div> data-slot="neon"

PropType
colors?string[]

The tubes' colours, any CSS colours: the outer frame takes the first, the inner tubes the second (the first again when there's one). By default a hot pink and a cyan.

Default
[]
flicker?boolean

Whether a tube now and then flickers, like a tired transformer: a couple of quick dips every ten seconds or so, none with reduced motion.

Default
true
intensity?"subtle" | "medium" | "strong"

How strongly the tubes glow and light the wall.

Type
"subtle" | "medium" | "strong"
Default
"medium"
speed?number

How fast the tubes hum and flicker: 2 is twice as often, 0.5 half.

Default
1
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

CSS variableType
--neon-bloomstring

How far the glow spreads, a multiplier (1).

--neon-color-1string

The frame's colour (a hot pink).

--neon-color-2string

The inner tubes' colour (a cyan).

--neon-speedstring

How fast it hums and flickers, a multiplier (1).

All 100 backgrounds