Orbit border button
Buttons with a comet of light racing around their border; on hover it speeds up and the glow spills out.
import type { ButtonHTMLAttributes } from "react";
import "./orbit-button.css";
type OrbitButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
/** "solid" (dark body) or "ghost" (see-through body). */
variant?: "solid" | "ghost";
theme?: "light" | "dark";
};
/**
* OrbitButton
* - A conic gradient spins behind the button; a 1.5px "window" around the edge
* (mask) shows only the border, so it looks like a comet circling the outline.
* - The angle is a registered CSS property (@property --gu-orbit), so it animates smoothly.
* - Pure CSS: no JavaScript needed.
*/
export function OrbitButton({
variant = "solid",
theme = "light",
className = "",
children,
...rest
}: OrbitButtonProps) {
return (
<button
type="button"
className={`gu-orbit ${className}`}
data-variant={variant}
data-theme={theme}
{...rest}
>
<span className="gu-orbit__label">{children}</span>
</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: Orbit border button
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
Pill buttons with a comet of light that keeps orbiting around their border. Hovering (or pressing) speeds the comet up and adds a soft glow around it.
## Layout and look
- 54px tall pill, padding 0 28px, weight 700.
- Solid variant: #0e0e10 body with #f3eee3 text (inverted in dark mode). Ghost variant: transparent body.
- Border: a 1.5px ring that is mostly a faint resting color (18% of the text color) with a bright comet: lime #d7ff3a tail fading into an orange #ff5a1f head.
## Behavior and motion
1. Register an angle property: @property --gu-orbit { syntax: "<angle>"; initial-value: 0deg; inherits: false }.
2. ::before: inset -1.5px, padding 1.5px, background conic-gradient(from var(--gu-orbit), rim 0 70%, lime 82%, orange 92%, rim 100%), masked to only the padding ring (mask: content-box exclude). Animate --gu-orbit to 360deg, linear, infinite, 3.2s.
3. ::after: same conic but only the orange head, blurred 10px, behind the button at opacity 0; on hover/active it fades to 0.8 and the speed variable drops to 1.4s.
4. Hover lifts the button 1px.
## Touch
The orbit runs on its own; :active gives the speed-up and glow on press.
## Accessibility
- Native <button> with all normal attributes passed through.
- 2px focus outline with 4px offset (#2b35ff, dark #d7ff3a).
- prefers-reduced-motion: no animation; the comet rests at a fixed angle.
## Props
variant ("solid" | "ghost"), theme, plus every native button attribute.
## 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.
### OrbitButton.tsx
```tsx
import type { ButtonHTMLAttributes } from "react";
import "./orbit-button.css";
type OrbitButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
/** "solid" (dark body) or "ghost" (see-through body). */
variant?: "solid" | "ghost";
theme?: "light" | "dark";
};
/**
* OrbitButton
* - A conic gradient spins behind the button; a 1.5px "window" around the edge
* (mask) shows only the border, so it looks like a comet circling the outline.
* - The angle is a registered CSS property (@property --gu-orbit), so it animates smoothly.
* - Pure CSS: no JavaScript needed.
*/
export function OrbitButton({
variant = "solid",
theme = "light",
className = "",
children,
...rest
}: OrbitButtonProps) {
return (
<button
type="button"
className={`gu-orbit ${className}`}
data-variant={variant}
data-theme={theme}
{...rest}
>
<span className="gu-orbit__label">{children}</span>
</button>
);
}
```
### orbit-button.css
```css
/* OrbitButton: change these colors to match your brand. */
@property --gu-orbit {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
.gu-orbit {
--body: #0e0e10; /* solid button body */
--text: #f3eee3;
--ghost-text: #0e0e10;
--rim: rgb(14 14 16 / 0.18); /* resting border */
--comet: #ff5a1f; /* the light */
--tail: #d7ff3a;
--speed: 3.2s;
--focus: #2b35ff;
position: relative;
isolation: isolate;
display: inline-grid;
place-items: center;
min-height: 54px;
padding: 0 28px;
border: 0;
border-radius: 999px;
background: var(--body);
color: var(--text);
font: inherit;
font-family: system-ui, sans-serif;
font-weight: 700;
cursor: pointer;
transition:
transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
box-shadow 0.4s;
}
.gu-orbit[data-theme="dark"] {
--body: #f3eee3;
--text: #0e0e10;
--ghost-text: #f3eee3;
--rim: rgb(243 238 227 / 0.2);
--focus: #d7ff3a;
}
.gu-orbit[data-variant="ghost"] {
background: transparent;
color: var(--ghost-text);
}
/* The moving border: conic gradient + a mask that keeps only a 1.5px ring */
.gu-orbit::before {
content: "";
position: absolute;
inset: -1.5px;
z-index: -1;
padding: 1.5px;
border-radius: inherit;
background: conic-gradient(
from var(--gu-orbit),
var(--rim) 0 70%,
var(--tail) 82%,
var(--comet) 92%,
var(--rim) 100%
);
-webkit-mask:
linear-gradient(#000 0 0) content-box exclude,
linear-gradient(#000 0 0);
mask:
linear-gradient(#000 0 0) content-box exclude,
linear-gradient(#000 0 0);
animation: gu-orbit-spin var(--speed) linear infinite;
}
/* A soft blurred copy of the comet for the glow */
.gu-orbit::after {
content: "";
position: absolute;
inset: -6px;
z-index: -2;
border-radius: inherit;
background: conic-gradient(
from var(--gu-orbit),
transparent 0 78%,
var(--comet) 92%,
transparent 100%
);
filter: blur(10px);
opacity: 0;
animation: gu-orbit-spin var(--speed) linear infinite;
transition: opacity 0.4s;
}
@keyframes gu-orbit-spin {
to {
--gu-orbit: 360deg;
}
}
.gu-orbit:hover,
.gu-orbit:active {
--speed: 1.4s;
transform: translateY(-1px);
}
.gu-orbit:hover::after,
.gu-orbit:active::after {
opacity: 0.8;
}
.gu-orbit:focus-visible {
outline: 2px solid var(--focus);
outline-offset: 4px;
}
.gu-orbit__label {
position: relative;
}
@media (prefers-reduced-motion: reduce) {
.gu-orbit::before,
.gu-orbit::after {
animation: none;
--gu-orbit: 300deg;
}
.gu-orbit {
transition: none;
}
}
```
You might also want
Next piece: Password strength meterMagnetic button
Components, beginner
Smart tooltips
Components, intermediate
Spotlight cards
Components, beginner