Ribbon badge
A status badge wrapped like a present: on hover a ribbon slides across it and a tiny bow pops on top.
"use client";
import { useState, type ReactNode } from "react";
import "./ribbon-badge.css";
type Props = {
children: ReactNode;
/** "signal" (orange) or "volt" (lime) background. */
tone?: "signal" | "volt";
theme?: "light" | "dark";
};
/**
* RibbonBadge: a small label that gets "gift wrapped" on hover or tap.
* It is a button so it can be focused and toggled on touch screens.
*/
export function RibbonBadge({
children,
tone = "signal",
theme = "light",
}: Props) {
const [wrapped, setWrapped] = useState(false);
return (
<button
type="button"
className="gu-ribbon-badge"
data-tone={tone}
data-theme={theme}
data-wrapped={wrapped}
aria-pressed={wrapped}
onClick={() => setWrapped((w) => !w)}
>
<span className="gu-ribbon-badge__label">{children}</span>
<span className="gu-ribbon-badge__ribbon" aria-hidden="true" />
<svg
className="gu-ribbon-badge__bow"
viewBox="0 0 24 12"
aria-hidden="true"
>
<path d="M12 9C8 9 3 8 3 4.5S8 2 12 9Z" />
<path d="M12 9c4 0 9-1 9-4.5S16 2 12 9Z" />
</svg>
</button>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: Ribbon badge
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A small status badge (like "New" or "Free") that gets gift wrapped on hover: a ribbon band slides down across the left side of the badge and a tiny two-loop bow pops up on top.
## Layout and look
- Rounded rectangle, radius 10px, minimum height 44px, padding 20px on the right and 36px on the left (room for the ribbon).
- Text: system sans-serif, weight 800, 15px, letter-spacing -0.01em.
- Two tones: orange #ff5a1f or lime #d7ff3a, both with near-black #0e0e10 text.
- Ribbon: an 8px-wide vertical band 17px from the left edge, so it never covers the label, near-black (cream #f3eee3 on a lime badge in dark mode).
- Bow: two teardrop loops drawn as a 2.2px stroke, about 26px wide, sitting on the badge's top edge right above the ribbon.
## Behavior and motion
1. On hover, the ribbon reveals from top to bottom in 450ms (clip-path), easing cubic-bezier(0.16, 1, 0.3, 1).
2. 150ms later the bow scales from 0 to 1 in 500ms, growing from its base.
3. Leaving reverses both.
## Touch
On touch screens a tap toggles the wrapped state; tapping again unwraps it.
## Accessibility
- It is a real <button> with aria-pressed showing the wrapped state. Ribbon and bow are decorative (aria-hidden).
- Keyboard focus shows the wrapped look plus a 3px outline (#2b35ff on light, #d7ff3a on dark).
- prefers-reduced-motion: ribbon and bow appear instantly, with no transitions.
## Props
tone ("signal" | "volt"), theme ("light" | "dark"), children (the label).
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: none (plain React and CSS). Translate it faithfully; do not add new libraries unless my framework needs them.
### RibbonBadge.tsx
```tsx
"use client";
import { useState, type ReactNode } from "react";
import "./ribbon-badge.css";
type Props = {
children: ReactNode;
/** "signal" (orange) or "volt" (lime) background. */
tone?: "signal" | "volt";
theme?: "light" | "dark";
};
/**
* RibbonBadge: a small label that gets "gift wrapped" on hover or tap.
* It is a button so it can be focused and toggled on touch screens.
*/
export function RibbonBadge({
children,
tone = "signal",
theme = "light",
}: Props) {
const [wrapped, setWrapped] = useState(false);
return (
<button
type="button"
className="gu-ribbon-badge"
data-tone={tone}
data-theme={theme}
data-wrapped={wrapped}
aria-pressed={wrapped}
onClick={() => setWrapped((w) => !w)}
>
<span className="gu-ribbon-badge__label">{children}</span>
<span className="gu-ribbon-badge__ribbon" aria-hidden="true" />
<svg
className="gu-ribbon-badge__bow"
viewBox="0 0 24 12"
aria-hidden="true"
>
<path d="M12 9C8 9 3 8 3 4.5S8 2 12 9Z" />
<path d="M12 9c4 0 9-1 9-4.5S16 2 12 9Z" />
</svg>
</button>
);
}
```
### ribbon-badge.css
```css
/* RibbonBadge: change the colors below to match your brand. */
.gu-ribbon-badge {
--bg: #ff5a1f; /* badge color */
--fg: #0e0e10; /* text color */
--ribbon: #0e0e10; /* ribbon and bow color */
--ease: cubic-bezier(0.16, 1, 0.3, 1);
position: relative;
display: inline-flex;
align-items: center;
min-height: 2.75rem;
padding: 0 1.25rem 0 2.25rem; /* room on the left for the ribbon */
border: 0;
border-radius: 0.6rem;
overflow: visible;
background: var(--bg);
color: var(--fg);
font:
800 0.95rem/1 system-ui,
sans-serif;
letter-spacing: -0.01em;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.gu-ribbon-badge[data-tone="volt"] {
--bg: #d7ff3a;
}
.gu-ribbon-badge[data-theme="dark"] {
--ribbon: #f3eee3;
}
.gu-ribbon-badge[data-theme="dark"][data-tone="signal"] {
--ribbon: #0e0e10;
}
.gu-ribbon-badge__label {
position: relative;
z-index: 2;
}
/* The ribbon: a vertical band near the left edge that slides down over the badge. */
.gu-ribbon-badge__ribbon {
position: absolute;
z-index: 1;
top: 0;
bottom: 0;
left: 1.05rem;
width: 0.5rem;
translate: -50% 0;
border-radius: 1px;
background: var(--ribbon);
opacity: 0.9;
clip-path: inset(0 0 100% 0);
transition: clip-path 0.45s var(--ease);
}
/* The bow: two loops that pop up on top. */
.gu-ribbon-badge__bow {
position: absolute;
z-index: 3;
left: 1.05rem;
bottom: calc(100% - 4px);
width: 1.6rem;
translate: -50% 0;
scale: 0;
transform-origin: 50% 90%;
fill: none;
stroke: var(--ribbon);
stroke-width: 2.2;
stroke-linejoin: round;
transition: scale 0.5s var(--ease) 0.15s;
}
.gu-ribbon-badge[data-theme="dark"] .gu-ribbon-badge__bow {
stroke: #f3eee3;
}
/* Wrapped: on hover (mouse), focus, or after a tap. */
@media (hover: hover) {
.gu-ribbon-badge:hover .gu-ribbon-badge__ribbon {
clip-path: inset(0 0 0 0);
}
.gu-ribbon-badge:hover .gu-ribbon-badge__bow {
scale: 1;
}
}
.gu-ribbon-badge:focus-visible .gu-ribbon-badge__ribbon,
.gu-ribbon-badge[data-wrapped="true"] .gu-ribbon-badge__ribbon {
clip-path: inset(0 0 0 0);
}
.gu-ribbon-badge:focus-visible .gu-ribbon-badge__bow,
.gu-ribbon-badge[data-wrapped="true"] .gu-ribbon-badge__bow {
scale: 1;
}
.gu-ribbon-badge:focus-visible {
outline: 3px solid #2b35ff;
outline-offset: 4px;
}
.gu-ribbon-badge[data-theme="dark"]:focus-visible {
outline-color: #d7ff3a;
}
@media (prefers-reduced-motion: reduce) {
.gu-ribbon-badge__ribbon,
.gu-ribbon-badge__bow {
transition: none;
}
}
```
You might also want
Next piece: Rotating words3D tilt card
Components, intermediate
Avatar stack
Components, beginner
Expanding image accordion
Components, beginner