Sunrise run5 km along the river, fog still on the water.
Noodle barThe spicy one, again. No regrets.
RooftopFriends, a slow sunset and one more song.
import { useId, useRef, useState } from 'react';
const TABS = [
{ label: 'Today', lines: ['Call the printer', 'Send invoice', 'Water plants'] },
{ label: 'Week', lines: ['Draft the talk', 'Book the venue', 'Team lunch'] },
{ label: 'Later', lines: ['Learn to sail', 'Fix the bike'] },
];
const css = `
@keyframes tabs-sticky-settle { 0% { transform: rotate(-3deg) translateY(-4px); opacity: 0.4; } 60% { transform: rotate(1deg); } 100% { transform: none; } }
.tabs-sticky { position: relative; width: 230px; padding-top: 38px; }
.tabs-sticky__list { position: absolute; left: 18px; top: 0; display: flex; gap: 6px; }
.tabs-sticky__tab {
width: 58px;
height: 40px;
padding: 6px 0 0;
border: 0;
border-radius: 3px 3px 0 0;
background: var(--tabs-sticky-c);
color: light-dark(#fbfcfd, #121417);
font: inherit;
font-size: 11px;
font-weight: 600;
vertical-align: top;
cursor: pointer;
transform: translateY(8px);
transition: transform 0.35s cubic-bezier(0.3, 1.7, 0.5, 1), filter 0.2s;
filter: brightness(0.85);
}
.tabs-sticky__tab:hover { transform: translateY(4px); }
.tabs-sticky__tab[aria-selected='true'] { transform: translateY(0); filter: none; }
.tabs-sticky__tab:focus-visible { outline: 2px solid light-dark(#373a40, #f1f2f3); outline-offset: 2px; }
.tabs-sticky__pad { position: relative; z-index: 1; height: 128px; padding: 14px 16px; border-radius: 4px; background: repeating-linear-gradient(transparent 0 23px, color-mix(in oklab, light-dark(#6d7179, #7d8087) 40%, transparent) 23px 24px) 0 12px / 100% 100% no-repeat, light-dark(#42454c, #e5e6e9); box-shadow: 0 14px 24px -14px light-dark(rgba(0, 0, 0, 0.21), rgba(0, 0, 0, 0.7)); }
.tabs-sticky[data-armed] .tabs-sticky__panel { animation: tabs-sticky-settle 0.45s ease-out; transform-origin: 10% 0; }
.tabs-sticky__item { display: flex; align-items: center; gap: 8px; height: 24px; color: light-dark(#f3f4f7, #1a1c1f); font-size: 12.5px; }
.tabs-sticky__item::before { content: ''; width: 9px; height: 9px; border-radius: 2px; box-shadow: inset 0 0 0 1.5px light-dark(#dbdde1, #2e3035); }
@media (prefers-reduced-motion: reduce) {
.tabs-sticky__tab { transition: none; }
.tabs-sticky__panel { animation: none !important; }
}
`;
const SHADES = ['light-dark(#50535b, #c6c8cd)', 'light-dark(#5f626a, #a7abb2)', 'light-dark(#6d7179, #7d8087)'];
export function StickyTabs() {
const id = useId();
const [sel, setSel] = useState(0);
const [armed, setArmed] = useState(false);
const tabs = useRef<(HTMLButtonElement | null)[]>([]);
const select = (i: number) => {
setArmed(true);
setSel(i);
};
const onKeyDown = (e: React.KeyboardEvent) => {
const n = TABS.length;
const 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.current[next]?.focus();
};
return (
<>
<style>
{css}
</style>
<div className="tabs-sticky" data-armed={armed ? '' : undefined}>
<div className="tabs-sticky__list" role="tablist" aria-label="To-do lists" onKeyDown={onKeyDown}>
{TABS.map((t, i) => (
<button
key={t.label}
ref={(el) => {
tabs.current[i] = el;
}}
className="tabs-sticky__tab"
type="button"
role="tab"
id={`${id}-tab-${i}`}
aria-selected={sel === i}
aria-controls={`${id}-panel-${i}`}
tabIndex={sel === i ? 0 : -1}
style={{ '--tabs-sticky-c': SHADES[i] } as React.CSSProperties}
onClick={() => select(i)}
>
{t.label}
</button>
))}
</div>
<div className="tabs-sticky__pad">
{TABS.map((t, i) => (
<div key={t.label} className="tabs-sticky__panel" role="tabpanel" id={`${id}-panel-${i}`} aria-labelledby={`${id}-tab-${i}`} hidden={sel !== i}>
{t.lines.map((l) => (
<div key={l} className="tabs-sticky__item">
{l}
</div>
))}
</div>
))}
</div>
</div>
</>
);
}Markup where the component goes, CSS in your stylesheet, script before </body>. In Vue, Svelte or Angular, call initTabsSticky(el) on the mounted element instead.
<div class="tabs-sticky">
<div class="tabs-sticky__list" role="tablist" aria-label="To-do lists">
<button class="tabs-sticky__tab" type="button" role="tab" id="tabs-sticky-tab-0" aria-selected="true" aria-controls="tabs-sticky-panel-0" tabindex="0" style="--tabs-sticky-c:light-dark(#50535b, #c6c8cd)">Today</button>
<button class="tabs-sticky__tab" type="button" role="tab" id="tabs-sticky-tab-1" aria-selected="false" aria-controls="tabs-sticky-panel-1" tabindex="-1" style="--tabs-sticky-c:light-dark(#5f626a, #a7abb2)">Week</button>
<button class="tabs-sticky__tab" type="button" role="tab" id="tabs-sticky-tab-2" aria-selected="false" aria-controls="tabs-sticky-panel-2" tabindex="-1" style="--tabs-sticky-c:light-dark(#6d7179, #7d8087)">Later</button>
</div>
<div class="tabs-sticky__pad">
<div class="tabs-sticky__panel" role="tabpanel" id="tabs-sticky-panel-0" aria-labelledby="tabs-sticky-tab-0">
<div class="tabs-sticky__item">Call the printer</div>
<div class="tabs-sticky__item">Send invoice</div>
<div class="tabs-sticky__item">Water plants</div>
</div>
<div class="tabs-sticky__panel" role="tabpanel" id="tabs-sticky-panel-1" aria-labelledby="tabs-sticky-tab-1" hidden="">
<div class="tabs-sticky__item">Draft the talk</div>
<div class="tabs-sticky__item">Book the venue</div>
<div class="tabs-sticky__item">Team lunch</div>
</div>
<div class="tabs-sticky__panel" role="tabpanel" id="tabs-sticky-panel-2" aria-labelledby="tabs-sticky-tab-2" hidden="">
<div class="tabs-sticky__item">Learn to sail</div>
<div class="tabs-sticky__item">Fix the bike</div>
</div>
</div>
</div>@keyframes tabs-sticky-settle { 0% { transform: rotate(-3deg) translateY(-4px); opacity: 0.4; } 60% { transform: rotate(1deg); } 100% { transform: none; } }
.tabs-sticky { position: relative; width: 230px; padding-top: 38px; }
.tabs-sticky__list { position: absolute; left: 18px; top: 0; display: flex; gap: 6px; }
.tabs-sticky__tab {
width: 58px;
height: 40px;
padding: 6px 0 0;
border: 0;
border-radius: 3px 3px 0 0;
background: var(--tabs-sticky-c);
color: light-dark(#fbfcfd, #121417);
font: inherit;
font-size: 11px;
font-weight: 600;
vertical-align: top;
cursor: pointer;
transform: translateY(8px);
transition: transform 0.35s cubic-bezier(0.3, 1.7, 0.5, 1), filter 0.2s;
filter: brightness(0.85);
}
.tabs-sticky__tab:hover { transform: translateY(4px); }
.tabs-sticky__tab[aria-selected='true'] { transform: translateY(0); filter: none; }
.tabs-sticky__tab:focus-visible { outline: 2px solid light-dark(#373a40, #f1f2f3); outline-offset: 2px; }
.tabs-sticky__pad { position: relative; z-index: 1; height: 128px; padding: 14px 16px; border-radius: 4px; background: repeating-linear-gradient(transparent 0 23px, color-mix(in oklab, light-dark(#6d7179, #7d8087) 40%, transparent) 23px 24px) 0 12px / 100% 100% no-repeat, light-dark(#42454c, #e5e6e9); box-shadow: 0 14px 24px -14px light-dark(rgba(0, 0, 0, 0.21), rgba(0, 0, 0, 0.7)); }
.tabs-sticky[data-armed] .tabs-sticky__panel { animation: tabs-sticky-settle 0.45s ease-out; transform-origin: 10% 0; }
.tabs-sticky__item { display: flex; align-items: center; gap: 8px; height: 24px; color: light-dark(#f3f4f7, #1a1c1f); font-size: 12.5px; }
.tabs-sticky__item::before { content: ''; width: 9px; height: 9px; border-radius: 2px; box-shadow: inset 0 0 0 1.5px light-dark(#dbdde1, #2e3035); }
@media (prefers-reduced-motion: reduce) {
.tabs-sticky__tab { transition: none; }
.tabs-sticky__panel { animation: none !important; }
}function initTabsSticky(root) {
var list = root.querySelector('[role="tablist"]');
var tabs = Array.prototype.slice.call(list.querySelectorAll('[role="tab"]'));
var panels = root.querySelectorAll('[role="tabpanel"]');
var sel = tabs.findIndex(function (tab) { return tab.getAttribute('aria-selected') === 'true'; });
function select(i) {
// Armed on the first change, so nothing animates on load.
root.setAttribute('data-armed', '');
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 n = tabs.length;
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-sticky').forEach(initTabsSticky);Goal: Create a "Sticky" tab set.
Visual behavior: Sticky flags on a notepad as to-do tabs: the chosen flag stands up and the note under it settles into place.
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 flags sit along the top of the pad in their own shades; the selected one rises and the others tuck down behind it. The panel settles in with a small rotation on keyframes.
- A data-armed attribute is set on the first change, so nothing plays on page load.
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 flags and the note change without moving.
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 "Sticky" tab set.
Visual behavior: Sticky flags on a notepad as to-do tabs: the chosen flag stands up and the note under it settles into place.
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 flags sit along the top of the pad in their own shades; the selected one rises and the others tuck down behind it. The panel settles in with a small rotation on keyframes.
- A data-armed attribute is set on the first change, so nothing plays on page load.
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 flags and the note change without moving.
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
Sticky flags on a notepad as to-do tabs: the chosen flag stands up and the note under it settles into place.
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 flags and the note change without moving.