- Harbour, 6am
- Market stalls
- Fog on the pier
Neon
import { useId, useRef, useState } from 'react';
const SIGNS = [
{ label: 'Diner', body: 'Open all night. Pie of the day is cherry.' },
{ label: 'Motel', body: 'Vacancies on the ground floor, pool round the back.' },
{ label: 'Arcade', body: 'Forty cabinets, two pinball tables, tokens at the door.' },
];
const css = `
.tabs-neon { width: 240px; }
.tabs-neon__list { display: flex; justify-content: space-between; gap: 8px; }
.tabs-neon__tab {
flex: 1;
height: 38px;
padding: 0;
border: 1.5px solid light-dark(#dbdde1, #2e3035);
border-radius: 10px;
background: none;
color: light-dark(#5f626a, #a7abb2);
font: inherit;
font-size: 14px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
cursor: pointer;
transition: color 0.7s, border-color 0.7s, text-shadow 0.7s, box-shadow 0.7s;
}
.tabs-neon__tab:focus-visible { outline: 2px solid light-dark(#50535b, #c6c8cd); outline-offset: 3px; }
/* Lit: the tube glows. Switching on, it stutters a few times before it holds; switched off, it fades. */
.tabs-neon__tab[aria-selected='true'] {
color: light-dark(#373a40, #f1f2f3);
border-color: light-dark(#42454c, #e5e6e9);
text-shadow: 0 0 3px light-dark(#373a40, #f1f2f3), 0 0 12px light-dark(#50535b, #c6c8cd);
box-shadow: 0 0 8px light-dark(#5f626a, #a7abb2), inset 0 0 8px light-dark(#cbced3, #393c41);
transition: none;
animation: tabs-neon-on 0.9s linear;
}
@keyframes tabs-neon-on {
0%, 9%, 16%, 25%, 32%, 40% { color: light-dark(#5f626a, #a7abb2); border-color: light-dark(#dbdde1, #2e3035); text-shadow: none; box-shadow: none; }
10%, 15%, 26%, 31% { color: light-dark(#373a40, #f1f2f3); border-color: light-dark(#42454c, #e5e6e9); text-shadow: 0 0 3px light-dark(#373a40, #f1f2f3), 0 0 12px light-dark(#50535b, #c6c8cd); box-shadow: 0 0 8px light-dark(#5f626a, #a7abb2), inset 0 0 8px light-dark(#cbced3, #393c41); }
}
/* Once lit, one letter buzzes now and then. */
.tabs-neon__tab[aria-selected='true'] .tabs-neon__buzz { animation: tabs-neon-buzz 5s steps(1) 2s infinite; }
@keyframes tabs-neon-buzz {
92% { opacity: 0.35; }
93% { opacity: 1; }
95% { opacity: 0.5; }
96% { opacity: 1; }
}
.tabs-neon__panel { padding: 14px 2px 0; min-height: calc(3.1em + 14px); color: light-dark(#50535b, #c6c8cd); font-size: 13px; line-height: 1.55; }
@media (prefers-reduced-motion: reduce) {
.tabs-neon__tab, .tabs-neon__tab[aria-selected='true'], .tabs-neon__tab[aria-selected='true'] .tabs-neon__buzz { animation: none; transition: none; }
}
`;
export function NeonTabs() {
const id = useId();
const [sel, setSel] = useState(0);
const tabs = useRef<(HTMLButtonElement | null)[]>([]);
const n = SIGNS.length;
const onKeyDown = (e: React.KeyboardEvent) => {
const next = { ArrowRight: (sel + 1) % n, ArrowLeft: (sel + n - 1) % n, Home: 0, End: n - 1 }[e.key];
if (next === undefined) return;
e.preventDefault();
setSel(next);
tabs.current[next]?.focus();
};
return (
<>
<style>
{css}
</style>
<div className="tabs-neon">
<div className="tabs-neon__list" role="tablist" aria-label="Signs" onKeyDown={onKeyDown}>
{SIGNS.map((s, i) => (
<button
key={s.label}
ref={(el) => {
tabs.current[i] = el;
}}
className="tabs-neon__tab"
type="button"
role="tab"
id={`${id}-tab-${i}`}
aria-selected={sel === i}
aria-controls={`${id}-panel-${i}`}
tabIndex={sel === i ? 0 : -1}
onClick={() => setSel(i)}
>
{s.label.slice(0, 2)}
<span className="tabs-neon__buzz">{s.label[2]}</span>
{s.label.slice(3)}
</button>
))}
</div>
{SIGNS.map((s, i) => (
<div key={s.label} className="tabs-neon__panel" role="tabpanel" id={`${id}-panel-${i}`} aria-labelledby={`${id}-tab-${i}`} hidden={sel !== i}>
{s.body}
</div>
))}
</div>
</>
);
}Markup where the component goes, CSS in your stylesheet, script before </body>. In Vue, Svelte or Angular, call initTabsNeon(el) on the mounted element instead.
<div class="tabs-neon">
<div class="tabs-neon__list" role="tablist" aria-label="Signs">
<button class="tabs-neon__tab" type="button" role="tab" id="tabs-neon-tab-0" aria-selected="true" aria-controls="tabs-neon-panel-0" tabindex="0">
Di<span class="tabs-neon__buzz">n</span>er
</button>
<button class="tabs-neon__tab" type="button" role="tab" id="tabs-neon-tab-1" aria-selected="false" aria-controls="tabs-neon-panel-1" tabindex="-1">
Mo<span class="tabs-neon__buzz">t</span>el
</button>
<button class="tabs-neon__tab" type="button" role="tab" id="tabs-neon-tab-2" aria-selected="false" aria-controls="tabs-neon-panel-2" tabindex="-1">
Ar<span class="tabs-neon__buzz">c</span>ade
</button>
</div>
<div class="tabs-neon__panel" role="tabpanel" id="tabs-neon-panel-0" aria-labelledby="tabs-neon-tab-0">Open all night. Pie of the day is cherry.</div>
<div class="tabs-neon__panel" role="tabpanel" id="tabs-neon-panel-1" aria-labelledby="tabs-neon-tab-1" hidden="">Vacancies on the ground floor, pool round the back.</div>
<div class="tabs-neon__panel" role="tabpanel" id="tabs-neon-panel-2" aria-labelledby="tabs-neon-tab-2" hidden="">Forty cabinets, two pinball tables, tokens at the door.</div>
</div>.tabs-neon { width: 240px; }
.tabs-neon__list { display: flex; justify-content: space-between; gap: 8px; }
.tabs-neon__tab {
flex: 1;
height: 38px;
padding: 0;
border: 1.5px solid light-dark(#dbdde1, #2e3035);
border-radius: 10px;
background: none;
color: light-dark(#5f626a, #a7abb2);
font: inherit;
font-size: 14px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
cursor: pointer;
transition: color 0.7s, border-color 0.7s, text-shadow 0.7s, box-shadow 0.7s;
}
.tabs-neon__tab:focus-visible { outline: 2px solid light-dark(#50535b, #c6c8cd); outline-offset: 3px; }
/* Lit: the tube glows. Switching on, it stutters a few times before it holds; switched off, it fades. */
.tabs-neon__tab[aria-selected='true'] {
color: light-dark(#373a40, #f1f2f3);
border-color: light-dark(#42454c, #e5e6e9);
text-shadow: 0 0 3px light-dark(#373a40, #f1f2f3), 0 0 12px light-dark(#50535b, #c6c8cd);
box-shadow: 0 0 8px light-dark(#5f626a, #a7abb2), inset 0 0 8px light-dark(#cbced3, #393c41);
transition: none;
animation: tabs-neon-on 0.9s linear;
}
@keyframes tabs-neon-on {
0%, 9%, 16%, 25%, 32%, 40% { color: light-dark(#5f626a, #a7abb2); border-color: light-dark(#dbdde1, #2e3035); text-shadow: none; box-shadow: none; }
10%, 15%, 26%, 31% { color: light-dark(#373a40, #f1f2f3); border-color: light-dark(#42454c, #e5e6e9); text-shadow: 0 0 3px light-dark(#373a40, #f1f2f3), 0 0 12px light-dark(#50535b, #c6c8cd); box-shadow: 0 0 8px light-dark(#5f626a, #a7abb2), inset 0 0 8px light-dark(#cbced3, #393c41); }
}
/* Once lit, one letter buzzes now and then. */
.tabs-neon__tab[aria-selected='true'] .tabs-neon__buzz { animation: tabs-neon-buzz 5s steps(1) 2s infinite; }
@keyframes tabs-neon-buzz {
92% { opacity: 0.35; }
93% { opacity: 1; }
95% { opacity: 0.5; }
96% { opacity: 1; }
}
.tabs-neon__panel { padding: 14px 2px 0; min-height: calc(3.1em + 14px); color: light-dark(#50535b, #c6c8cd); font-size: 13px; line-height: 1.55; }
@media (prefers-reduced-motion: reduce) {
.tabs-neon__tab, .tabs-neon__tab[aria-selected='true'], .tabs-neon__tab[aria-selected='true'] .tabs-neon__buzz { animation: none; transition: none; }
}function initTabsNeon(root) {
var list = root.querySelector('[role="tablist"]');
var tabs = Array.prototype.slice.call(list.querySelectorAll('[role="tab"]'));
var panels = Array.prototype.slice.call(root.querySelectorAll('[role="tabpanel"]'));
var n = tabs.length;
var sel = tabs.findIndex(function (tab) { return tab.getAttribute('aria-selected') === 'true'; });
function select(i) {
if (i === sel) return;
var prev = sel;
sel = i;
tabs.forEach(function (tab, k) {
tab.setAttribute('aria-selected', String(k === i));
tab.tabIndex = k === i ? 0 : -1;
});
panels.forEach(function (panel, k) { panel.hidden = k !== i; });
}
function onClick(e) {
var tab = e.target.closest('[role="tab"]');
if (tab) select(tabs.indexOf(tab));
}
function onKeyDown(e) {
var next = { ArrowRight: (sel + 1) % n, ArrowLeft: (sel + n - 1) % n, Home: 0, End: n - 1 }[e.key];
if (next === undefined) return;
e.preventDefault();
select(next);
tabs[next].focus();
}
list.addEventListener('click', onClick);
list.addEventListener('keydown', onKeyDown);
return function () {
list.removeEventListener('click', onClick);
list.removeEventListener('keydown', onKeyDown);
};
}
document.querySelectorAll('.tabs-neon').forEach(initTabsNeon);Goal: Create a "Neon" tab set.
Visual behavior: Neon signs as tabs: the chosen sign stutters on a few times before it holds, the old one fades off, and a letter of the lit sign buzzes now and then.
Technique:
- The ARIA tabs pattern: a role="tablist" with an aria-label, buttons with role="tab", aria-selected and aria-controls, and role="tabpanel" panels labelled by their tab. Only the selected tab is in the Tab order (roving tabindex); the arrow keys, Home and End move between tabs and select as they go.
- The chosen sign plays a keyframe that switches its colour, border and glow (layered text-shadow and box-shadow) on and off a few times before it holds, while the others transition off.
- One letter of the lit sign runs a long stepped keyframe that dims it briefly every few seconds, like a failing tube.
Accessibility: Real ARIA tabs: arrow keys, Home and End move between tabs, only the selected tab is in the Tab order, and each panel is labelled by its tab. Decoration is aria-hidden. Under prefers-reduced-motion the sign lights without flicker and nothing buzzes.
My stack: {{USER_STACK}}
My styling: {{USER_STYLING}}
My constraints: {{USER_CONSTRAINTS}}
My colors: neutral only. Black, white and grays, no hues. Use the color values above as written, or my project's closest neutral tokens.
Return a single self-contained component. No dependencies.Goal: Create a "Neon" tab set.
Visual behavior: Neon signs as tabs: the chosen sign stutters on a few times before it holds, the old one fades off, and a letter of the lit sign buzzes now and then.
Technique:
- The ARIA tabs pattern: a role="tablist" with an aria-label, buttons with role="tab", aria-selected and aria-controls, and role="tabpanel" panels labelled by their tab. Only the selected tab is in the Tab order (roving tabindex); the arrow keys, Home and End move between tabs and select as they go.
- The chosen sign plays a keyframe that switches its colour, border and glow (layered text-shadow and box-shadow) on and off a few times before it holds, while the others transition off.
- One letter of the lit sign runs a long stepped keyframe that dims it briefly every few seconds, like a failing tube.
Accessibility: Real ARIA tabs: arrow keys, Home and End move between tabs, only the selected tab is in the Tab order, and each panel is labelled by its tab. Decoration is aria-hidden. Under prefers-reduced-motion the sign lights without flicker and nothing buzzes.
My stack: {{USER_STACK}}
My styling: {{USER_STYLING}}
My constraints: {{USER_CONSTRAINTS}}
My colors: use my project's existing color tokens. The color values above are grayscale placeholders. Map each one by its role (surface, text, border, accent, glow) to my theme, and keep their relative lightness so contrast and the effect still read.
Return a single self-contained component. No dependencies.Paste into Claude, ChatGPT or Cursor after filling in {{USER_STACK}}, {{USER_STYLING}} and {{USER_CONSTRAINTS}}. Neutral keeps the greys you see here; Match my project asks the model to map them onto your own colour tokens.
Free to use in any project, commercial included. MIT-0, no attribution required. Licence
About this component
Neon signs as tabs: the chosen sign stutters on a few times before it holds, the old one fades off, and a letter of the lit sign buzzes now and then.
- Dependencies
- None
- Difficulty
- Beginner
- Triggers
- click, state change, neon, glow, keyframe
- Techniques
- keyframes, filter
- Reduced motion
- Respected
- Theme
- Light and dark (follows your page's color-scheme)
Real ARIA tabs: arrow keys, Home and End move between tabs, only the selected tab is in the Tab order, and each panel is labelled by its tab. Decoration is aria-hidden. Under prefers-reduced-motion the sign lights without flicker and nothing buzzes.