Recline
import { useId } from 'react';
const css = `
.radio-recline { --radio-recline-b: -8deg; --radio-recline-l: 0deg; display: grid; justify-items: center; gap: 16px; }
.radio-recline:has(.radio-recline__input[value='premium']:checked) { --radio-recline-b: -26deg; --radio-recline-l: -38deg; }
.radio-recline:has(.radio-recline__input[value='business']:checked) { --radio-recline-b: -58deg; --radio-recline-l: -82deg; }
.radio-recline__seat { position: relative; width: 120px; height: 78px; }
.radio-recline__floor { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 1px; background: light-dark(#dbdde1, #2e3035); }
.radio-recline__post { position: absolute; left: 44px; bottom: 2px; width: 6px; height: 20px; background: light-dark(#cbced3, #393c41); }
.radio-recline__foot { position: absolute; left: 30px; bottom: 2px; width: 34px; height: 4px; border-radius: 2px; background: light-dark(#cbced3, #393c41); }
.radio-recline__cushion { position: absolute; left: 30px; top: 44px; width: 46px; height: 12px; border-radius: 4px 6px 5px 4px; background: linear-gradient(light-dark(#50535b, #c6c8cd), light-dark(#6d7179, #7d8087)); }
.radio-recline__back {
position: absolute;
left: 28px;
top: 6px;
width: 12px;
height: 44px;
border-radius: 6px 6px 4px 4px;
background: linear-gradient(90deg, light-dark(#6d7179, #7d8087), light-dark(#50535b, #c6c8cd));
transform-origin: 50% 100%;
transform: rotate(var(--radio-recline-b));
transition: transform 0.75s cubic-bezier(0.35, 1.3, 0.5, 1);
}
.radio-recline__back::before { content: ''; position: absolute; left: -1px; top: 0; width: 14px; height: 10px; border-radius: 6px; background: light-dark(#42454c, #e5e6e9); }
.radio-recline__leg {
position: absolute;
left: 70px;
top: 50px;
width: 9px;
height: 22px;
border-radius: 3px 3px 5px 5px;
background: linear-gradient(90deg, light-dark(#5f626a, #a7abb2), light-dark(#6d7179, #7d8087));
transform-origin: 50% 0;
transform: rotate(var(--radio-recline-l));
transition: transform 0.75s cubic-bezier(0.35, 1.3, 0.5, 1) 0.12s;
}
.radio-recline__arm { position: absolute; left: 40px; top: 34px; width: 28px; height: 5px; border-radius: 3px; background: light-dark(#cbced3, #393c41); }
.radio-recline__opts { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: light-dark(#f3f4f7, #1a1c1f); box-shadow: inset 0 0 0 1px light-dark(#dbdde1, #2e3035); }
.radio-recline__opt {
position: relative;
padding: 5px 10px;
border-radius: 7px;
color: light-dark(#5f626a, #a7abb2);
font-size: 12px;
font-weight: 600;
cursor: pointer;
transition: color 0.2s, background-color 0.2s;
}
.radio-recline__opt:hover { color: light-dark(#42454c, #e5e6e9); }
.radio-recline__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.radio-recline__opt:has(.radio-recline__input:focus-visible) { outline: 2px solid light-dark(#5f626a, #a7abb2); outline-offset: 2px; }
.radio-recline__opt:has(.radio-recline__input:checked) { background: light-dark(#42454c, #e5e6e9); color: light-dark(#fbfcfd, #121417); }
@media (prefers-reduced-motion: reduce) {
.radio-recline * { transition-duration: 0.01s !important; transition-delay: 0s !important; }
}
`;
const CLASSES = [
{ value: 'economy', label: 'Economy' },
{ value: 'premium', label: 'Premium' },
{ value: 'business', label: 'Business' },
];
export function ReclineRadio() {
const name = useId();
return (
<>
<style>
{css}
</style>
<div className="radio-recline">
<span className="radio-recline__seat" aria-hidden="true">
<span className="radio-recline__floor" />
<span className="radio-recline__foot" />
<span className="radio-recline__post" />
<span className="radio-recline__back" />
<span className="radio-recline__leg" />
<span className="radio-recline__cushion" />
<span className="radio-recline__arm" />
</span>
<div className="radio-recline__opts" role="radiogroup" aria-label="Cabin">
{CLASSES.map((c, i) => (
<label key={c.value} className="radio-recline__opt">
<input className="radio-recline__input" type="radio" name={name} value={c.value} defaultChecked={i === 0} />
{c.label}
</label>
))}
</div>
</div>
</>
);
}Markup where the component goes, CSS in your stylesheet. No JavaScript.
<div class="radio-recline">
<span class="radio-recline__seat" aria-hidden="true">
<span class="radio-recline__floor"></span>
<span class="radio-recline__foot"></span>
<span class="radio-recline__post"></span>
<span class="radio-recline__back"></span>
<span class="radio-recline__leg"></span>
<span class="radio-recline__cushion"></span>
<span class="radio-recline__arm"></span>
</span>
<div class="radio-recline__opts" role="radiogroup" aria-label="Cabin">
<label class="radio-recline__opt"><input class="radio-recline__input" type="radio" name="radio-recline" checked="" value="economy"/>Economy</label>
<label class="radio-recline__opt"><input class="radio-recline__input" type="radio" name="radio-recline" value="premium"/>Premium</label>
<label class="radio-recline__opt"><input class="radio-recline__input" type="radio" name="radio-recline" value="business"/>Business</label>
</div>
</div>.radio-recline { --radio-recline-b: -8deg; --radio-recline-l: 0deg; display: grid; justify-items: center; gap: 16px; }
.radio-recline:has(.radio-recline__input[value='premium']:checked) { --radio-recline-b: -26deg; --radio-recline-l: -38deg; }
.radio-recline:has(.radio-recline__input[value='business']:checked) { --radio-recline-b: -58deg; --radio-recline-l: -82deg; }
.radio-recline__seat { position: relative; width: 120px; height: 78px; }
.radio-recline__floor { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 1px; background: light-dark(#dbdde1, #2e3035); }
.radio-recline__post { position: absolute; left: 44px; bottom: 2px; width: 6px; height: 20px; background: light-dark(#cbced3, #393c41); }
.radio-recline__foot { position: absolute; left: 30px; bottom: 2px; width: 34px; height: 4px; border-radius: 2px; background: light-dark(#cbced3, #393c41); }
.radio-recline__cushion { position: absolute; left: 30px; top: 44px; width: 46px; height: 12px; border-radius: 4px 6px 5px 4px; background: linear-gradient(light-dark(#50535b, #c6c8cd), light-dark(#6d7179, #7d8087)); }
.radio-recline__back {
position: absolute;
left: 28px;
top: 6px;
width: 12px;
height: 44px;
border-radius: 6px 6px 4px 4px;
background: linear-gradient(90deg, light-dark(#6d7179, #7d8087), light-dark(#50535b, #c6c8cd));
transform-origin: 50% 100%;
transform: rotate(var(--radio-recline-b));
transition: transform 0.75s cubic-bezier(0.35, 1.3, 0.5, 1);
}
.radio-recline__back::before { content: ''; position: absolute; left: -1px; top: 0; width: 14px; height: 10px; border-radius: 6px; background: light-dark(#42454c, #e5e6e9); }
.radio-recline__leg {
position: absolute;
left: 70px;
top: 50px;
width: 9px;
height: 22px;
border-radius: 3px 3px 5px 5px;
background: linear-gradient(90deg, light-dark(#5f626a, #a7abb2), light-dark(#6d7179, #7d8087));
transform-origin: 50% 0;
transform: rotate(var(--radio-recline-l));
transition: transform 0.75s cubic-bezier(0.35, 1.3, 0.5, 1) 0.12s;
}
.radio-recline__arm { position: absolute; left: 40px; top: 34px; width: 28px; height: 5px; border-radius: 3px; background: light-dark(#cbced3, #393c41); }
.radio-recline__opts { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: light-dark(#f3f4f7, #1a1c1f); box-shadow: inset 0 0 0 1px light-dark(#dbdde1, #2e3035); }
.radio-recline__opt {
position: relative;
padding: 5px 10px;
border-radius: 7px;
color: light-dark(#5f626a, #a7abb2);
font-size: 12px;
font-weight: 600;
cursor: pointer;
transition: color 0.2s, background-color 0.2s;
}
.radio-recline__opt:hover { color: light-dark(#42454c, #e5e6e9); }
.radio-recline__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.radio-recline__opt:has(.radio-recline__input:focus-visible) { outline: 2px solid light-dark(#5f626a, #a7abb2); outline-offset: 2px; }
.radio-recline__opt:has(.radio-recline__input:checked) { background: light-dark(#42454c, #e5e6e9); color: light-dark(#fbfcfd, #121417); }
@media (prefers-reduced-motion: reduce) {
.radio-recline * { transition-duration: 0.01s !important; transition-delay: 0s !important; }
}Goal: Create a "Recline" radio.
Visual behavior: Cabin class as a seat: pick economy, premium or business and the seat reclines further for each, its legrest rising to match.
Technique:
- Real native radios (visually hidden: absolute, 1x1, opacity 0) inside <label>s; the scene is aria-hidden and every state is read from the checked input with :has().
- The backrest and legrest are hinged blocks whose angles come from CSS variables set with :has(); the legrest follows a beat later on the same springy curve. Pure CSS, no script.
Accessibility: A role="radiogroup" with an aria-label around native radio inputs sharing one name, so the arrow keys move the choice and Tab enters the group once; :focus-visible on the input outlines its option. Under prefers-reduced-motion the seat changes instantly.
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 "Recline" radio.
Visual behavior: Cabin class as a seat: pick economy, premium or business and the seat reclines further for each, its legrest rising to match.
Technique:
- Real native radios (visually hidden: absolute, 1x1, opacity 0) inside <label>s; the scene is aria-hidden and every state is read from the checked input with :has().
- The backrest and legrest are hinged blocks whose angles come from CSS variables set with :has(); the legrest follows a beat later on the same springy curve. Pure CSS, no script.
Accessibility: A role="radiogroup" with an aria-label around native radio inputs sharing one name, so the arrow keys move the choice and Tab enters the group once; :focus-visible on the input outlines its option. Under prefers-reduced-motion the seat changes instantly.
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
Cabin class as a seat: pick economy, premium or business and the seat reclines further for each, its legrest rising to match.
- Dependencies
- None
- Difficulty
- Beginner
- Triggers
- click, state change, spring
- Techniques
- css variables, css transition
- Reduced motion
- Respected
- Theme
- Light and dark (follows your page's color-scheme)
A role="radiogroup" with an aria-label around native radio inputs sharing one name, so the arrow keys move the choice and Tab enters the group once; :focus-visible on the input outlines its option. Under prefers-reduced-motion the seat changes instantly.