Sphere Button
Round planetary call to action button lit by a radial highlight and crescent inset shadows, in teal, blue and coral. A void variant opens a dark center on hover, and labels use the display typeface.
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
import { SphereButton } from "@/components/sphere-button/sphere-button"
// Every word on the page. Change copy here, not in the markup.
const COPY = {
cta: "Explore",
enter: "Enter",
} as const
export default function SphereButtonDemo() {
return (
<div className="grid w-full flex-wrap place-items-center gap-10 p-6">
<SphereButton>{COPY.cta}</SphereButton>
<SphereButton variant="void" size="lg">
{COPY.enter}
</SphereButton>
</div>
)
}
Installation
pnpm dlx shadcn@latest add @01orbital/sphere-buttonnpx shadcn@latest add @01orbital/sphere-buttonyarn dlx shadcn@latest add @01orbital/sphere-buttonbunx --bun shadcn@latest add @01orbital/sphere-buttonUsage
import { SphereButton } from "@/components/sphere-button/sphere-button"
// Every word on the page. Change copy here, not in the markup.
const COPY = {
cta: "Explore",
enter: "Enter",
} as const
export default function SphereButtonDemo() {
return (
<div className="grid w-full flex-wrap place-items-center gap-10 p-6">
<SphereButton>{COPY.cta}</SphereButton>
<SphereButton variant="void" size="lg">
{COPY.enter}
</SphereButton>
</div>
)
}This example installs with everything it uses:
pnpm dlx shadcn@latest add @01orbital/sphere-button-demonpx shadcn@latest add @01orbital/sphere-button-demoyarn dlx shadcn@latest add @01orbital/sphere-button-demobunx --bun shadcn@latest add @01orbital/sphere-button-demoExamples
Newsletter Readersphere-button-newsletter-reader
Example of the Sphere Button in coral on a newsletter issue card, where pressing it opens the letter in a dialog reader.
"use client"
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Grain } from "@/components/texture/grain"
import { Button } from "@/components/ui/button"
import {
Card,
CardContent,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
label: "Small Hours newsletter issue",
brand: "Small Hours",
issue: "No. 042 / Nov 3",
title: "The baker",
aside: "on the night bus.",
body: "A 5-minute letter about the people who keep a city awake.",
cta: "Read 042",
footnote: "A letter from Nicole Mann. Every Tuesday, before dawn.",
letterTitle: "The baker on the night bus",
close: "Close letter",
} as const
const PARAGRAPHS = [
"At 3:17 am, the number 6 belongs to six people. A nurse with a paperback. Two cleaners sharing a bag of oranges. The driver, me, and a baker carrying her shoes.",
"“The flour gets everywhere,” Nicole says, pointing at the pair in her lap. She changes at the bakery door. The shoes for the bus are blue. The shoes for the oven were blue once.",
"By seven, her first loaves will be cooling beside the window on Chapel Street. People will stop for coffee on their way to work. Most will never see the number 6, or the woman who gets off it while the streetlights are still on.",
"I bought a loaf on my way home. She had drawn a small sun in the flour.",
] as const
/** A coral Sphere Button on a newsletter issue card that opens the letter in a dialog reader. */
export default function SphereButtonNewsletterReader() {
return (
<Card
aria-label={COPY.label}
className="relative isolate w-full max-w-lg rounded-none bg-[oklch(0.94_0.035_65)] text-[oklch(0.3_0.045_35)] shadow-none ring-0 [--card-spacing:--spacing(7)] [--font-display:var(--font-hanken-grotesk)] [--ring:oklch(0.43_0.1_35)]"
>
<Grain variant="paper" opacity={0.18} />
<CardHeader className="relative">
<div className="flex items-center justify-between gap-4 border-b border-[oklch(0.72_0.055_60)] pb-4 text-xs">
<Eyebrow variant="caps" render={<span className="text-current" />}>
{COPY.brand}
</Eyebrow>
<span>{COPY.issue}</span>
</div>
</CardHeader>
<CardContent className="relative flex flex-wrap items-end justify-between gap-7">
<div className="max-w-56">
<CardTitle className="font-display text-4xl leading-tight font-normal tracking-tight">
{COPY.title}
<br />
{COPY.aside}
</CardTitle>
<p className="mt-4 text-sm leading-6">{COPY.body}</p>
</div>
<SphereButton
variant="coral"
size="sm"
className="font-sans text-sm font-medium"
aria-haspopup="dialog"
aria-controls="small-hours-reader"
onClick={() => {
const reader = document.getElementById("small-hours-reader")
if (reader instanceof HTMLDialogElement) reader.showModal()
}}
>
{COPY.cta}
</SphereButton>
</CardContent>
<CardFooter className="relative text-xs text-[oklch(0.47_0.04_35)]">
{COPY.footnote}
</CardFooter>
<dialog
id="small-hours-reader"
aria-labelledby="small-hours-title"
className="fixed inset-0 m-auto max-h-[85dvh] w-[calc(100%_-_2rem)] max-w-lg overflow-auto rounded-xl bg-[oklch(0.96_0.02_75)] p-7 text-[oklch(0.3_0.045_35)] backdrop:bg-[oklch(0.15_0.02_35/0.7)]"
>
<h4 id="small-hours-title" className="text-2xl font-semibold">
{COPY.letterTitle}
</h4>
<div className="mt-5 space-y-4 text-base leading-7">
{PARAGRAPHS.map((paragraph) => (
<p key={paragraph}>{paragraph}</p>
))}
</div>
<form method="dialog" className="mt-6">
<Button
type="submit"
variant="link"
className="h-auto min-h-11 px-0 font-normal text-inherit underline"
>
{COPY.close}
</Button>
</form>
</dialog>
</Card>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const eyebrowVariants = cva("text-eyebrow", {
variants: {
/**
* `default` is a 14px/20px label. `icon` adds a row with a 16px icon
* and a 12px gap; put the icon first and give it `aria-hidden`.
* `mono` and `caps` are 12px/20px uppercase labels with 0.12em
* tracking, in the mono and inherited faces respectively.
*/
variant: {
default: "text-sm/5 font-medium text-eyebrow",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium tracking-[0.12em] uppercase",
caps: "text-xs/5 font-medium tracking-[0.12em] uppercase",
},
},
defaultVariants: { variant: "default" },
})
/**
* A short label above a heading, rendered as a `<p>` at weight 500.
* The default is 14px/20px in the kit's eyebrow color. The surrounding
* layout controls the space to the heading. Use `className` to customize
* the typography or color, and `render` to change the element.
*/
function Eyebrow({
className,
variant = "default",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import { cn } from "cn"
// Paper grain: an SVG turbulence filter as a data URI.
const PAPER_GRAIN = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='1.4' numOctaves='1' seed='2' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='4' intercept='1'/%3E%3CfeFuncG type='linear' slope='4' intercept='1'/%3E%3CfeFuncB type='linear' slope='4' intercept='1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Sandpaper grain: an SVG turbulence filter as a data URI.
const SANDPAPER_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='2.2' numOctaves='2' seed='5' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncG type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncB type='linear' slope='2.5' intercept='0.8'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Single noise: an SVG turbulence filter as a data URI.
const SINGLE_NOISE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Square grain: an SVG turbulence filter as a data URI.
const SQUARE_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20100%20100%22%3E%3Cfilter%20id=%22n%22%20color-interpolation-filters=%22sRGB%22%3E%3CfeTurbulence%20type=%22turbulence%22%20baseFrequency=%222.1%22%20numOctaves=%223%22%20seed=%2211%22%20stitchTiles=%22stitch%22%20result=%22n%22/%3E%3CfeComponentTransfer%20result=%22g%22%3E%3CfeFuncR%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncG%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncB%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix%20type=%22saturate%22%20values=%220%22%20in=%22g%22/%3E%3C/filter%3E%3Crect%20width=%22100%%22%20height=%22100%%22%20filter=%22url(%23n)%22/%3E%3C/svg%3E")`
type Intensity = "fine" | "default" | "rich"
// One scale for every texture; `default` is the unscaled value.
const INTENSITY_MULT: Record<Intensity, number> = {
fine: 0.6,
default: 1,
rich: 1.45,
}
const alpha = (base: number, mult: number) => (base * mult).toFixed(4)
// Four grain treatments; each paints a single texture layer.
// Full-bleed art layer — drop inside a `relative` parent; sits behind content.
/** The texture treatment painted by `Grain`. */
type GrainVariant =
// Stylized paper-look variants — heavier filter chain than plain noise.
"paper" | "sandpaper" | "square" | "single"
type Layer = {
src: string
size: string
opacity: number
blend: "overlay" | "soft-light"
}
const BLEND_CLASS: Record<Layer["blend"], string> = {
overlay: "mix-blend-overlay",
"soft-light": "mix-blend-soft-light",
}
const VARIANT_TEXTURES: Record<GrainVariant, Layer> = {
paper: {
src: PAPER_GRAIN,
size: "250px",
opacity: 0.25,
blend: "overlay",
},
sandpaper: {
src: SANDPAPER_GRAIN,
size: "200px",
opacity: 0.25,
blend: "overlay",
},
square: {
src: SQUARE_GRAIN,
size: "200px",
opacity: 0.8,
blend: "soft-light",
},
single: { src: SINGLE_NOISE, size: "200px", opacity: 0.3, blend: "overlay" },
}
/**
* A decorative grain layer that fills a positioned parent without blocking
* clicks. Choose a texture and adjust its strength with `intensity` or
* `opacity`. `className` and other div props land on the outer layer.
*/
function Grain({
variant = "single",
intensity = "default",
opacity,
isolated = false,
className,
...props
}: React.ComponentProps<"div"> & {
/** The grain treatment: `single` (default), `paper`, `sandpaper` or `square`. */
variant?: GrainVariant
/** Multiplies the texture's opacity: `fine` 0.6×, `default` 1×, `rich` 1.45×. */
intensity?: Intensity
/** The texture opacity, from 0 to 1. Takes precedence over `intensity`. */
opacity?: number
/**
* Adds paint containment when true. This creates a stacking context, so
* the texture stops blending with scene layers outside this element.
*/
isolated?: boolean
}) {
const layer = VARIANT_TEXTURES[variant]
const m =
opacity != null ? opacity / layer.opacity : INTENSITY_MULT[intensity]
return (
<div
data-slot="grain"
data-variant={variant}
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0",
isolated && "contain-[paint]",
className
)}
{...props}
>
<div
className={cn("absolute inset-0", BLEND_CLASS[layer.blend])}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: layer.opacity * m,
}}
/>
</div>
)
}
export { Grain }
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-newsletter-readernpx shadcn@latest add @01orbital/sphere-button-newsletter-readeryarn dlx shadcn@latest add @01orbital/sphere-button-newsletter-readerbunx --bun shadcn@latest add @01orbital/sphere-button-newsletter-readerRover Puzzlesphere-button-rover-puzzle
Example of the Sphere Button in its void variant on a game title card that starts, and later restarts, a two-choice rover puzzle.
"use client"
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Grain } from "@/components/texture/grain"
import { Button } from "@/components/ui/button"
import {
Card,
CardContent,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
label: "Pocket Planet playable trail puzzle",
eyebrow: "Pocket Planet / A tiny browser game",
title: "Last light",
aside: "on Cinder.",
body: "Your rover has one battery cell left. Find the route back to base.",
start: "Start",
restart: "Restart",
legend:
"Base is east. The sun is setting west. Which route keeps you charging?",
cta: "Check route",
prompt: "Choose your route, then check it.",
success:
"Home, with 12% to spare. The ridge kept your solar panel in the light.",
failure:
"The crater falls into shadow. No charge left. Try the route that still gets sunlight.",
} as const
const ROUTES = [
{ value: "crater", label: "Through the deep crater" },
{ value: "ridge", label: "Along the exposed ridge" },
] as const
/** A void Sphere Button on a game title card that starts, and later restarts, a two-choice rover puzzle. */
export default function SphereButtonRoverPuzzle() {
return (
<Card
aria-label={COPY.label}
className="relative isolate w-full max-w-sm rounded-3xl bg-[oklch(0.18_0.035_35)] text-center text-[oklch(0.94_0.03_75)] shadow-none ring-0 [--card-spacing:--spacing(7)] [--font-display:var(--font-hanken-grotesk)] [--ring:oklch(0.83_0.1_65)]"
>
<Grain variant="square" opacity={0.12} />
<CardHeader className="relative gap-4">
<Eyebrow
variant="caps"
className="text-current text-[oklch(0.79_0.06_60)]"
>
{COPY.eyebrow}
</Eyebrow>
<CardTitle className="font-display text-4xl font-normal tracking-tight">
{COPY.title}
<br />
{COPY.aside}
</CardTitle>
<p className="mx-auto max-w-64 text-sm leading-6 text-[oklch(0.82_0.035_65)]">
{COPY.body}
</p>
</CardHeader>
<CardContent className="relative flex flex-col items-center gap-7">
<SphereButton
variant="void"
size="md"
texture
className="font-sans font-medium"
aria-controls="cinder-puzzle"
onClick={(event) => {
const puzzle = document.getElementById("cinder-puzzle")
if (!puzzle) return
puzzle.hidden = false
puzzle.querySelector<HTMLElement>("legend")?.focus()
const label =
event.currentTarget.querySelector("[data-start-label]")
if (label) label.textContent = COPY.restart
puzzle.querySelector<HTMLFormElement>("form")?.reset()
const output = puzzle.querySelector("output")
if (output) output.textContent = COPY.prompt
}}
>
<span data-start-label>{COPY.start}</span>
</SphereButton>
<div
id="cinder-puzzle"
hidden
className="w-full border-t border-[oklch(0.47_0.05_40)] pt-6 text-left"
>
<form
onSubmit={(event) => {
event.preventDefault()
const data = new FormData(event.currentTarget)
const result = event.currentTarget.querySelector("output")
if (result)
result.textContent =
data.get("cinder-route") === "ridge"
? COPY.success
: COPY.failure
}}
>
<fieldset>
<legend
tabIndex={-1}
className="text-sm font-semibold focus-visible:outline-2 focus-visible:outline-offset-4"
>
{COPY.legend}
</legend>
{ROUTES.map((route, index) => (
<label
key={route.value}
className={
index === 0
? "mt-4 flex cursor-pointer items-center gap-3 py-2 text-sm"
: "flex cursor-pointer items-center gap-3 py-2 text-sm"
}
>
<input
type="radio"
name="cinder-route"
value={route.value}
required
className="size-4 accent-[oklch(0.7_0.12_45)]"
/>
{route.label}
</label>
))}
</fieldset>
<Button
type="submit"
variant="outline"
className="mt-4 h-auto min-h-11 border-[oklch(0.65_0.08_55)] bg-transparent px-5 font-normal hover:bg-[oklch(0.32_0.05_40)] hover:text-inherit dark:bg-transparent dark:hover:bg-[oklch(0.32_0.05_40)]"
>
{COPY.cta}
</Button>
<output
aria-live="polite"
className="mt-4 block text-sm leading-6 text-[oklch(0.85_0.04_65)]"
>
{COPY.prompt}
</output>
</form>
</div>
</CardContent>
</Card>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const eyebrowVariants = cva("text-eyebrow", {
variants: {
/**
* `default` is a 14px/20px label. `icon` adds a row with a 16px icon
* and a 12px gap; put the icon first and give it `aria-hidden`.
* `mono` and `caps` are 12px/20px uppercase labels with 0.12em
* tracking, in the mono and inherited faces respectively.
*/
variant: {
default: "text-sm/5 font-medium text-eyebrow",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium tracking-[0.12em] uppercase",
caps: "text-xs/5 font-medium tracking-[0.12em] uppercase",
},
},
defaultVariants: { variant: "default" },
})
/**
* A short label above a heading, rendered as a `<p>` at weight 500.
* The default is 14px/20px in the kit's eyebrow color. The surrounding
* layout controls the space to the heading. Use `className` to customize
* the typography or color, and `render` to change the element.
*/
function Eyebrow({
className,
variant = "default",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import { cn } from "cn"
// Paper grain: an SVG turbulence filter as a data URI.
const PAPER_GRAIN = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='1.4' numOctaves='1' seed='2' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='4' intercept='1'/%3E%3CfeFuncG type='linear' slope='4' intercept='1'/%3E%3CfeFuncB type='linear' slope='4' intercept='1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Sandpaper grain: an SVG turbulence filter as a data URI.
const SANDPAPER_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='2.2' numOctaves='2' seed='5' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncG type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncB type='linear' slope='2.5' intercept='0.8'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Single noise: an SVG turbulence filter as a data URI.
const SINGLE_NOISE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Square grain: an SVG turbulence filter as a data URI.
const SQUARE_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20100%20100%22%3E%3Cfilter%20id=%22n%22%20color-interpolation-filters=%22sRGB%22%3E%3CfeTurbulence%20type=%22turbulence%22%20baseFrequency=%222.1%22%20numOctaves=%223%22%20seed=%2211%22%20stitchTiles=%22stitch%22%20result=%22n%22/%3E%3CfeComponentTransfer%20result=%22g%22%3E%3CfeFuncR%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncG%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncB%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix%20type=%22saturate%22%20values=%220%22%20in=%22g%22/%3E%3C/filter%3E%3Crect%20width=%22100%%22%20height=%22100%%22%20filter=%22url(%23n)%22/%3E%3C/svg%3E")`
type Intensity = "fine" | "default" | "rich"
// One scale for every texture; `default` is the unscaled value.
const INTENSITY_MULT: Record<Intensity, number> = {
fine: 0.6,
default: 1,
rich: 1.45,
}
const alpha = (base: number, mult: number) => (base * mult).toFixed(4)
// Four grain treatments; each paints a single texture layer.
// Full-bleed art layer — drop inside a `relative` parent; sits behind content.
/** The texture treatment painted by `Grain`. */
type GrainVariant =
// Stylized paper-look variants — heavier filter chain than plain noise.
"paper" | "sandpaper" | "square" | "single"
type Layer = {
src: string
size: string
opacity: number
blend: "overlay" | "soft-light"
}
const BLEND_CLASS: Record<Layer["blend"], string> = {
overlay: "mix-blend-overlay",
"soft-light": "mix-blend-soft-light",
}
const VARIANT_TEXTURES: Record<GrainVariant, Layer> = {
paper: {
src: PAPER_GRAIN,
size: "250px",
opacity: 0.25,
blend: "overlay",
},
sandpaper: {
src: SANDPAPER_GRAIN,
size: "200px",
opacity: 0.25,
blend: "overlay",
},
square: {
src: SQUARE_GRAIN,
size: "200px",
opacity: 0.8,
blend: "soft-light",
},
single: { src: SINGLE_NOISE, size: "200px", opacity: 0.3, blend: "overlay" },
}
/**
* A decorative grain layer that fills a positioned parent without blocking
* clicks. Choose a texture and adjust its strength with `intensity` or
* `opacity`. `className` and other div props land on the outer layer.
*/
function Grain({
variant = "single",
intensity = "default",
opacity,
isolated = false,
className,
...props
}: React.ComponentProps<"div"> & {
/** The grain treatment: `single` (default), `paper`, `sandpaper` or `square`. */
variant?: GrainVariant
/** Multiplies the texture's opacity: `fine` 0.6×, `default` 1×, `rich` 1.45×. */
intensity?: Intensity
/** The texture opacity, from 0 to 1. Takes precedence over `intensity`. */
opacity?: number
/**
* Adds paint containment when true. This creates a stacking context, so
* the texture stops blending with scene layers outside this element.
*/
isolated?: boolean
}) {
const layer = VARIANT_TEXTURES[variant]
const m =
opacity != null ? opacity / layer.opacity : INTENSITY_MULT[intensity]
return (
<div
data-slot="grain"
data-variant={variant}
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0",
isolated && "contain-[paint]",
className
)}
{...props}
>
<div
className={cn("absolute inset-0", BLEND_CLASS[layer.blend])}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: layer.opacity * m,
}}
/>
</div>
)
}
export { Grain }
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-rover-puzzlenpx shadcn@latest add @01orbital/sphere-button-rover-puzzleyarn dlx shadcn@latest add @01orbital/sphere-button-rover-puzzlebunx --bun shadcn@latest add @01orbital/sphere-button-rover-puzzleStart Smallsphere-button-start-small
Example of the Sphere Button at a small size: a teal planetary button on a pale canvas with an offset caption and a popover note.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Linen } from "@/components/texture/linen"
// The copy: change text here, not in the markup.
const COPY = {
cta: "Begin",
title: "Make room to focus.",
body: "One task. Twenty minutes. A quieter place to start.",
noteTitle: "Your focus session is ready.",
note: "Choose a single task before you begin. Click outside to return to the preview.",
} as const
/** A small teal planetary button on pale canvas with an offset caption and a popover note. */
export default function SphereButtonStartSmall() {
return (
<div className="w-full bg-background text-foreground">
<div className="relative flex min-h-76 w-full flex-wrap items-center justify-center gap-8 overflow-hidden rounded-3xl bg-[oklch(0.94_0.025_170)] p-8 text-[oklch(0.25_0.04_175)]">
<Linen
intensity="rich"
className="[--linen-color:oklch(0.3_0.04_175)]"
/>
<SphereButton
variant="default"
size="sm"
className="relative font-display"
popoverTarget="start-small-note"
>
{COPY.cta}
</SphereButton>
<div className="relative max-w-44">
<h3 className="text-xl font-medium">{COPY.title}</h3>
<p className="mt-2 text-sm/6">{COPY.body}</p>
</div>
<div
id="start-small-note"
popover="auto"
className="m-auto max-w-xs rounded-2xl border border-border bg-background p-7 text-foreground shadow-xl"
>
<p className="font-medium">{COPY.noteTitle}</p>
<p className="mt-2 text-sm/6">{COPY.note}</p>
</div>
</div>
</div>
)
}
import { cn } from "cn"
type Intensity = "fine" | "default" | "rich"
// One scale for every texture; `default` is the unscaled value.
const INTENSITY_MULT: Record<Intensity, number> = {
fine: 0.6,
default: 1,
rich: 1.45,
}
const alpha = (base: number, mult: number) => (base * mult).toFixed(4)
// Two-direction weave — 1px threads at 0°+90°. 5px and 6px are the thread
// PERIODS, not gaps, and they are coprime, so the weave repeats every 30px.
/** Full-bleed art layer — drop inside a `relative` parent; sits behind content. */
function Linen({
intensity = "default",
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Thread alpha multiplier. Ink is white; set --linen-color on a light ground.
*/
intensity?: Intensity
}) {
const m = INTENSITY_MULT[intensity]
return (
<div
className={cn("pointer-events-none absolute inset-0", className)}
aria-hidden="true"
data-slot="linen"
{...props}
>
<div
className="absolute inset-0"
style={{
backgroundImage: `repeating-linear-gradient(90deg in srgb, transparent 0px, transparent 2px, oklch(from var(--linen-color, oklch(1 0 0)) l c h / ${alpha(0.05, m)}) 2px, oklch(from var(--linen-color, oklch(1 0 0)) l c h / ${alpha(0.02, m)}) 3px, transparent 3px, transparent 6px), repeating-linear-gradient(0deg in srgb, transparent 0px, transparent 2px, oklch(from var(--linen-color, oklch(1 0 0)) l c h / ${alpha(0.06, m)}) 2px, oklch(from var(--linen-color, oklch(1 0 0)) l c h / ${alpha(0.02, m)}) 3px, transparent 3px, transparent 5px)`,
}}
/>
</div>
)
}
export { Linen }
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-start-smallnpx shadcn@latest add @01orbital/sphere-button-start-smallyarn dlx shadcn@latest add @01orbital/sphere-button-start-smallbunx --bun shadcn@latest add @01orbital/sphere-button-start-smallInto The Voidsphere-button-into-the-void
Example of the Sphere Button: a large coral void button with woven paint, centered on plum-black grain, with a popover note.
The source comes with full access.
One payment of $149 opens the source right here and lets the CLI install every paid component, with lifetime updates.
pnpm dlx shadcn@latest add @01orbital/sphere-button-into-the-voidnpx shadcn@latest add @01orbital/sphere-button-into-the-voidyarn dlx shadcn@latest add @01orbital/sphere-button-into-the-voidbunx --bun shadcn@latest add @01orbital/sphere-button-into-the-voidAmbersphere-button-amber
Sphere Button example: bright gold spheres with dark pill labels on an ink ground, a solid one that lifts beside a void one that opens on hover. Use it to pick a warm call to action on dark.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Badge } from "@/components/ui/badge"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
title: "Amber",
body: "Bright gold with an ink label, keeping the face clear and saturated.",
solid: {
ariaLabel: "Explore Amber solid",
label: "Explore",
caption: "Solid / lift",
},
void: {
ariaLabel: "Enter Amber void",
label: "Enter",
caption: "Void / open",
},
} as const
/** Bright gold Sphere Buttons with dark pill labels on an ink ground, a solid sphere that lifts beside a void sphere that opens. */
export default function SphereButtonAmber() {
return (
<Card className="dark relative isolate w-full max-w-[608px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[480px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="gap-2">
<CardTitle className="text-[17px]/[26px] font-medium tracking-[-0.02em]">
{COPY.title}
</CardTitle>
<CardDescription className="text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex justify-center gap-10 pt-1 max-[600px]:gap-6 max-[600px]:pt-0">
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="default"
size="md"
aria-label={COPY.solid.ariaLabel}
className="[filter:hue-rotate(250deg)_saturate(4)_contrast(1.05)] max-[600px]:size-24 max-[600px]:text-sm"
>
<Badge className="h-auto max-w-full bg-[oklch(0.13_0_0)] px-3 py-1.5 text-[length:inherit] leading-normal font-normal whitespace-normal text-[oklch(0.985_0.003_90)] [text-shadow:none]">
{COPY.solid.label}
</Badge>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.solid.caption}
</figcaption>
</figure>
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="void"
size="md"
aria-label={COPY.void.ariaLabel}
className="[filter:hue-rotate(52deg)_saturate(4)_contrast(1.05)] max-[600px]:size-24 max-[600px]:text-sm"
>
<Badge className="h-auto max-w-full bg-[oklch(0.13_0_0)] px-3 py-1.5 text-[length:inherit] leading-normal font-normal whitespace-normal text-[oklch(0.985_0.003_90)] [text-shadow:none]">
{COPY.void.label}
</Badge>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.void.caption}
</figcaption>
</figure>
</CardContent>
</Card>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-ambernpx shadcn@latest add @01orbital/sphere-button-amberyarn dlx shadcn@latest add @01orbital/sphere-button-amberbunx --bun shadcn@latest add @01orbital/sphere-button-amberApp Downloadsphere-button-app-download
Sphere Button App Download: an example of sphere-button.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Subheading } from "@/components/subheading/subheading"
// The copy: change text here, not in the markup.
const COPY = {
title: "Take your notes anywhere.",
body: "Quill syncs across your phone, tablet and laptop, even offline.",
cta: "Get the app",
note: "Free for iOS and Android.",
} as const
/** A blue Sphere Button link for an app download, centered in a mobile app promo. */
export default function SphereButtonAppDownload() {
return (
<section className="flex w-full max-w-md flex-col items-center rounded-3xl border border-border bg-card p-10 text-center text-card-foreground">
<Subheading render={<h3 />} className="text-balance">
{COPY.title}
</Subheading>
<p className="mt-3 text-sm/6 text-muted-foreground">{COPY.body}</p>
<SphereButton
variant="blue"
className="mt-8"
render={<a href="#download" />}
>
{COPY.cta}
</SphereButton>
<p className="mt-6 text-xs text-muted-foreground">{COPY.note}</p>
</section>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const subheadingVariants = cva(
"font-display font-[450] tracking-[-0.05em] text-pretty sm:tracking-[-0.06em]",
{
variants: {
/**
* `default` inherits the surrounding display face. `serif` uses
* the kit's serif role, without changing the surrounding font.
*/
variant: {
default: "",
serif: "[--font-display:var(--font-serif)]",
},
/**
* `md` (the default): 32px/40px, capped at 40px/44px from `sm`.
* `lg`: 32px/40px, 40px/48px from `sm`, 48px/56px from `lg`.
* `xl`: 32px/40px, 48px/56px from `sm`, 56px/56px from `lg`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 sm:text-5xl/14 lg:text-[3.5rem]/14",
},
},
defaultVariants: { variant: "default", size: "md" },
}
)
/**
* The section heading in the display font, which follows `font-sans`
* unless a block switches that role. Rendered as an `<h2>` at weight 450.
* The default `size="md"` steps
* from 32px/40px to 40px/44px at `sm` and stays there. Choose `size="lg"`
* for 32px/40px, 40px/48px at `sm` and 48px/56px at `lg`, or `size="xl"`
* for 32px/40px, 48px/56px at `sm` and 56px/56px at `lg`.
* `variant="serif"` uses the kit's serif role; the default keeps the
* surrounding display face. Both variants support all three sizes.
* Pass `render` to use another heading level. A page's headline is `Heading`.
*/
function Subheading({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof subheadingVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "subheading", variant, size },
props: mergeProps<"h2">(
{
className: cn(subheadingVariants({ variant, size }), className),
},
props
),
})
}
export { Subheading, subheadingVariants }
pnpm dlx shadcn@latest add @01orbital/sphere-button-app-downloadnpx shadcn@latest add @01orbital/sphere-button-app-downloadyarn dlx shadcn@latest add @01orbital/sphere-button-app-downloadbunx --bun shadcn@latest add @01orbital/sphere-button-app-downloadCheckout Paysphere-button-checkout-pay
Sphere Button Checkout Pay: an example of sphere-button.
"use client"
import { useEffect, useState } from "react"
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Subheading } from "@/components/subheading/subheading"
// The copy: change text here, not in the markup.
const COPY = {
title: "Order summary",
cta: "Pay now",
paying: "Paying…",
paid: "Payment received",
note: "You will be charged once. Receipts go to your email.",
} as const
const LINES = [
{ label: "Ceramic pour-over set", price: "$64.00" },
{ label: "Delivery", price: "$6.00" },
{ label: "Total", price: "$70.00" },
] as const
/** A coral Sphere Button as the pay action under a checkout order summary. */
export default function SphereButtonCheckoutPay() {
const [phase, setPhase] = useState<"idle" | "paying" | "paid">("idle")
// Your payment call goes here; this one succeeds after a moment.
useEffect(() => {
if (phase !== "paying") return
const timer = setTimeout(() => setPhase("paid"), 1400)
return () => clearTimeout(timer)
}, [phase])
return (
<form
className="flex w-full max-w-sm flex-col items-center rounded-3xl border border-border bg-card p-7 text-card-foreground"
onSubmit={(event) => {
event.preventDefault()
if (phase === "idle") setPhase("paying")
}}
>
<Subheading render={<h3 />} className="self-start">
{COPY.title}
</Subheading>
<dl className="mt-4 w-full space-y-2 text-sm">
{LINES.map((line) => (
<div key={line.label} className="flex justify-between gap-4">
<dt className="text-muted-foreground">{line.label}</dt>
<dd className="font-medium tabular-nums">{line.price}</dd>
</div>
))}
</dl>
<SphereButton
type="submit"
variant="coral"
className="mt-8"
disabled={phase !== "idle"}
>
{phase === "paying" ? COPY.paying : COPY.cta}
</SphereButton>
<p role="status" aria-live="polite" className="mt-4 text-sm font-medium">
{phase === "paid" && COPY.paid}
</p>
<p className="mt-6 text-center text-xs/5 text-muted-foreground">
{COPY.note}
</p>
</form>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const subheadingVariants = cva(
"font-display font-[450] tracking-[-0.05em] text-pretty sm:tracking-[-0.06em]",
{
variants: {
/**
* `default` inherits the surrounding display face. `serif` uses
* the kit's serif role, without changing the surrounding font.
*/
variant: {
default: "",
serif: "[--font-display:var(--font-serif)]",
},
/**
* `md` (the default): 32px/40px, capped at 40px/44px from `sm`.
* `lg`: 32px/40px, 40px/48px from `sm`, 48px/56px from `lg`.
* `xl`: 32px/40px, 48px/56px from `sm`, 56px/56px from `lg`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 sm:text-5xl/14 lg:text-[3.5rem]/14",
},
},
defaultVariants: { variant: "default", size: "md" },
}
)
/**
* The section heading in the display font, which follows `font-sans`
* unless a block switches that role. Rendered as an `<h2>` at weight 450.
* The default `size="md"` steps
* from 32px/40px to 40px/44px at `sm` and stays there. Choose `size="lg"`
* for 32px/40px, 40px/48px at `sm` and 48px/56px at `lg`, or `size="xl"`
* for 32px/40px, 48px/56px at `sm` and 56px/56px at `lg`.
* `variant="serif"` uses the kit's serif role; the default keeps the
* surrounding display face. Both variants support all three sizes.
* Pass `render` to use another heading level. A page's headline is `Heading`.
*/
function Subheading({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof subheadingVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "subheading", variant, size },
props: mergeProps<"h2">(
{
className: cn(subheadingVariants({ variant, size }), className),
},
props
),
})
}
export { Subheading, subheadingVariants }
pnpm dlx shadcn@latest add @01orbital/sphere-button-checkout-paynpx shadcn@latest add @01orbital/sphere-button-checkout-payyarn dlx shadcn@latest add @01orbital/sphere-button-checkout-paybunx --bun shadcn@latest add @01orbital/sphere-button-checkout-payCloud Dancer Rosesphere-button-cloud-dancer-rose
Sphere Button Cloud Dancer Rose: an example of sphere-button.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Badge } from "@/components/ui/badge"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
title: "Cloud Dancer / Rose",
body: "Native Cloud Dancer pearl with the checked track’s rose shading.",
solid: {
ariaLabel: "Explore Cloud Dancer / Rose solid",
label: "Explore",
caption: "Solid / lift",
},
void: {
ariaLabel: "Enter Cloud Dancer / Rose void",
label: "Enter",
caption: "Void / open",
},
} as const
/** Two pearl Sphere Buttons with soft rose shading on warm paper, one that lifts on hover and one that opens a dark center. */
export default function SphereButtonCloudDancerRose() {
return (
<Card className="relative isolate w-full max-w-[608px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[480px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="gap-2">
<CardTitle className="text-[17px]/[26px] font-medium tracking-[-0.02em]">
{COPY.title}
</CardTitle>
<CardDescription className="text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex justify-center gap-10 pt-1 max-[600px]:gap-6 max-[600px]:pt-0">
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="default"
size="md"
aria-label={COPY.solid.ariaLabel}
className="bg-[radial-gradient(circle_at_35%_35%,#ffffff_0%,oklch(0.995_0.002_90)_40%,oklch(0.915_0.006_85)_100%)] text-[oklch(0.22_0.008_60)] shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06)] [text-shadow:none] not-disabled:hover:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06),0_6px_16px_rgb(196_112_112_/_0.16)] not-disabled:focus-visible:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06),0_6px_16px_rgb(196_112_112_/_0.16)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.solid.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.solid.caption}
</figcaption>
</figure>
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="void"
size="md"
aria-label={COPY.void.ariaLabel}
className="max-[600px]:size-24 max-[600px]:text-sm [&>[data-slot=sphere-button-paint]]:bg-[radial-gradient(circle_at_35%_35%,#ffffff_0%,oklch(0.995_0.002_90)_40%,oklch(0.915_0.006_85)_100%)] [&>[data-slot=sphere-button-paint]]:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06)]"
>
<Badge className="h-auto max-w-full bg-[oklch(0.13_0_0)] px-3 py-1.5 text-[length:inherit] leading-normal font-normal whitespace-normal text-[oklch(0.985_0.003_90)] [text-shadow:none]">
{COPY.void.label}
</Badge>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.void.caption}
</figcaption>
</figure>
</CardContent>
</Card>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-cloud-dancer-rosenpx shadcn@latest add @01orbital/sphere-button-cloud-dancer-roseyarn dlx shadcn@latest add @01orbital/sphere-button-cloud-dancer-rosebunx --bun shadcn@latest add @01orbital/sphere-button-cloud-dancer-roseCobaltsphere-button-cobalt
Sphere Button Cobalt: an example of sphere-button.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
title: "Cobalt",
body: "Two native paints brought into one saturated blue family.",
solid: {
ariaLabel: "Explore Cobalt solid",
label: "Explore",
caption: "Solid / lift",
},
void: {
ariaLabel: "Enter Cobalt void",
label: "Enter",
caption: "Void / open",
},
} as const
/** Two saturated cobalt blue Sphere Buttons on paper, a solid one that lifts on hover and a void one that opens from the center. */
export default function SphereButtonCobalt() {
return (
<Card className="relative isolate w-full max-w-[608px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[480px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="gap-2">
<CardTitle className="text-[17px]/[26px] font-medium tracking-[-0.02em]">
{COPY.title}
</CardTitle>
<CardDescription className="text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex justify-center gap-10 pt-1 max-[600px]:gap-6 max-[600px]:pt-0">
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="default"
size="md"
aria-label={COPY.solid.ariaLabel}
className="[filter:hue-rotate(57deg)_saturate(1.8)_contrast(1.08)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.solid.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.solid.caption}
</figcaption>
</figure>
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="void"
size="md"
aria-label={COPY.void.ariaLabel}
className="[filter:hue-rotate(220deg)_saturate(1.8)_contrast(1.08)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.void.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.void.caption}
</figcaption>
</figure>
</CardContent>
</Card>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-cobaltnpx shadcn@latest add @01orbital/sphere-button-cobaltyarn dlx shadcn@latest add @01orbital/sphere-button-cobaltbunx --bun shadcn@latest add @01orbital/sphere-button-cobaltCollection Choicesphere-button-collection-choice
Sphere Button Collection Choice: an example of sphere-button.
"use client"
import { useState } from "react"
import { SphereButton } from "@/components/sphere-button/sphere-button"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
eyebrow: "03 / Selection",
title: "Choose a collection",
body: "A solid sphere marks the current choice.",
groupLabel: "Choose a collection",
day: "Day",
night: "Night",
selected: "collection selected.",
} as const
/** Two small pearl Sphere Buttons that work as a Day and Night switch, the chosen one solid and the other void, with a status line. */
export default function SphereButtonCollectionChoice() {
const [choice, setChoice] = useState<"day" | "night">("day")
return (
<Card className="relative isolate w-full max-w-[400px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[480px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="min-w-0 gap-0">
<p className="text-[13px]/[22px] font-medium">{COPY.eyebrow}</p>
<CardTitle className="mt-3 font-display text-[23px]/[30px] font-normal tracking-[-0.035em]">
{COPY.title}
</CardTitle>
<CardDescription className="mt-2.5 text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent
role="group"
aria-label={COPY.groupLabel}
className="flex min-h-[190px] min-w-0 flex-1 flex-wrap items-center justify-center gap-5 max-[400px]:gap-4"
>
<SphereButton
variant={choice === "day" ? "default" : "void"}
size="sm"
aria-pressed={choice === "day"}
onClick={() => setChoice("day")}
className={
choice === "day"
? "bg-[radial-gradient(circle_at_35%_35%,#ffffff_0%,oklch(0.995_0.002_90)_40%,oklch(0.915_0.006_85)_100%)] text-[oklch(0.22_0.008_60)] shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06)] [text-shadow:none] not-disabled:hover:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06),0_6px_16px_rgb(196_112_112_/_0.16)] not-disabled:focus-visible:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06),0_6px_16px_rgb(196_112_112_/_0.16)]"
: "[&>[data-slot=sphere-button-paint]]:bg-[radial-gradient(circle_at_35%_35%,#ffffff_0%,oklch(0.995_0.002_90)_40%,oklch(0.915_0.006_85)_100%)] [&>[data-slot=sphere-button-paint]]:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06)]"
}
>
<span
className={
choice === "day"
? "inline-block max-w-full leading-normal"
: "inline-block max-w-full rounded-full bg-[oklch(0.13_0_0)] px-3 py-1.5 leading-normal text-[oklch(0.985_0.003_90)] [text-shadow:none]"
}
>
{COPY.day}
</span>
</SphereButton>
<SphereButton
variant={choice === "night" ? "default" : "void"}
size="sm"
aria-pressed={choice === "night"}
onClick={() => setChoice("night")}
className={
choice === "night"
? "bg-[radial-gradient(circle_at_35%_35%,#ffffff_0%,oklch(0.995_0.002_90)_40%,oklch(0.915_0.006_85)_100%)] text-[oklch(0.22_0.008_60)] shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06)] [text-shadow:none] not-disabled:hover:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06),0_6px_16px_rgb(196_112_112_/_0.16)] not-disabled:focus-visible:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06),0_6px_16px_rgb(196_112_112_/_0.16)]"
: "[&>[data-slot=sphere-button-paint]]:bg-[radial-gradient(circle_at_35%_35%,#ffffff_0%,oklch(0.995_0.002_90)_40%,oklch(0.915_0.006_85)_100%)] [&>[data-slot=sphere-button-paint]]:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06)]"
}
>
<span
className={
choice === "night"
? "inline-block max-w-full leading-normal"
: "inline-block max-w-full rounded-full bg-[oklch(0.13_0_0)] px-3 py-1.5 leading-normal text-[oklch(0.985_0.003_90)] [text-shadow:none]"
}
>
{COPY.night}
</span>
</SphereButton>
</CardContent>
<CardFooter
role="status"
className="justify-center text-center text-[13px]/6 text-muted-foreground"
>
{choice === "day" ? COPY.day : COPY.night} {COPY.selected}
</CardFooter>
</Card>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-collection-choicenpx shadcn@latest add @01orbital/sphere-button-collection-choiceyarn dlx shadcn@latest add @01orbital/sphere-button-collection-choicebunx --bun shadcn@latest add @01orbital/sphere-button-collection-choiceDetail Disclosuresphere-button-detail-disclosure
Sphere Button Detail Disclosure: an example of sphere-button.
"use client"
import { useId, useState } from "react"
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Badge } from "@/components/ui/badge"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
eyebrow: "02 / Disclosure",
title: "A detail, close at hand",
body: "Open a little more room with a void sphere.",
open: "Open",
close: "Close",
panelTitle: "Room for a small idea.",
panelBody:
"Keep the page quiet until you need the next detail. A little space can hold enough.",
statusOpen: "The extra detail is open.",
statusClosed: "The extra detail is tucked away.",
} as const
/** A pearl void Sphere Button that opens and closes a small panel of extra detail, with a status line that follows its state. */
export default function SphereButtonDetailDisclosure() {
const [open, setOpen] = useState(false)
const panelId = useId()
return (
<Card className="relative isolate w-full max-w-[400px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[380px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="min-w-0 gap-0">
<p className="text-[13px]/[22px] font-medium">{COPY.eyebrow}</p>
<CardTitle className="mt-3 font-display text-[23px]/[30px] font-normal tracking-[-0.035em]">
{COPY.title}
</CardTitle>
<CardDescription className="mt-2.5 text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex min-h-[190px] min-w-0 flex-1 flex-wrap items-center justify-center gap-5">
<SphereButton
variant="void"
size="md"
aria-expanded={open}
aria-controls={panelId}
onClick={() => setOpen((value) => !value)}
className="[&>[data-slot=sphere-button-paint]]:bg-[radial-gradient(circle_at_35%_35%,#ffffff_0%,oklch(0.995_0.002_90)_40%,oklch(0.915_0.006_85)_100%)] [&>[data-slot=sphere-button-paint]]:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06)]"
>
<Badge className="h-auto max-w-full bg-[oklch(0.13_0_0)] px-3 py-1.5 text-[length:inherit] leading-normal font-normal whitespace-normal text-[oklch(0.985_0.003_90)] [text-shadow:none]">
{open ? COPY.close : COPY.open}
</Badge>
</SphereButton>
</CardContent>
<CardContent id={panelId} hidden={!open} className="min-w-0">
<Card className="min-w-0 rounded-2xl border border-border text-card-foreground shadow-none ring-0">
<CardHeader className="gap-3">
<CardTitle className="font-display text-[19px]/[27px] font-normal tracking-[-0.025em]">
{COPY.panelTitle}
</CardTitle>
<CardDescription className="text-xs/[22px]">
{COPY.panelBody}
</CardDescription>
</CardHeader>
</Card>
</CardContent>
<CardFooter className="justify-center text-center text-[13px]/6 text-muted-foreground">
{open ? COPY.statusOpen : COPY.statusClosed}
</CardFooter>
</Card>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-detail-disclosurenpx shadcn@latest add @01orbital/sphere-button-detail-disclosureyarn dlx shadcn@latest add @01orbital/sphere-button-detail-disclosurebunx --bun shadcn@latest add @01orbital/sphere-button-detail-disclosureEmpty Statesphere-button-empty-state
Sphere Button Empty State: an example of sphere-button.
"use client"
import { useState } from "react"
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Subheading } from "@/components/subheading/subheading"
// The copy: change text here, not in the markup.
const COPY = {
title: "No projects yet",
body: "Projects keep your files, tasks and teammates in one place.",
cta: "Create one",
projectName: "First project",
projectNote: "Just created, no tasks yet",
} as const
/** A small teal Sphere Button as the single action in an empty projects list. */
export default function SphereButtonEmptyState() {
const [created, setCreated] = useState(false)
if (created) {
return (
<section className="flex w-full max-w-lg flex-col rounded-3xl border border-border p-6 text-foreground">
<ul>
<li className="flex flex-col gap-0.5">
<span className="text-sm font-medium">{COPY.projectName}</span>
<span className="text-sm/6 text-muted-foreground">
{COPY.projectNote}
</span>
</li>
</ul>
</section>
)
}
return (
<section className="flex w-full max-w-lg flex-col items-center rounded-3xl border border-dashed border-border p-12 text-center text-foreground">
<Subheading render={<h3 />}>{COPY.title}</Subheading>
<p className="mt-2 max-w-xs text-sm/6 text-muted-foreground">
{COPY.body}
</p>
<SphereButton size="sm" className="mt-8" onClick={() => setCreated(true)}>
{COPY.cta}
</SphereButton>
</section>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const subheadingVariants = cva(
"font-display font-[450] tracking-[-0.05em] text-pretty sm:tracking-[-0.06em]",
{
variants: {
/**
* `default` inherits the surrounding display face. `serif` uses
* the kit's serif role, without changing the surrounding font.
*/
variant: {
default: "",
serif: "[--font-display:var(--font-serif)]",
},
/**
* `md` (the default): 32px/40px, capped at 40px/44px from `sm`.
* `lg`: 32px/40px, 40px/48px from `sm`, 48px/56px from `lg`.
* `xl`: 32px/40px, 48px/56px from `sm`, 56px/56px from `lg`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 sm:text-5xl/14 lg:text-[3.5rem]/14",
},
},
defaultVariants: { variant: "default", size: "md" },
}
)
/**
* The section heading in the display font, which follows `font-sans`
* unless a block switches that role. Rendered as an `<h2>` at weight 450.
* The default `size="md"` steps
* from 32px/40px to 40px/44px at `sm` and stays there. Choose `size="lg"`
* for 32px/40px, 40px/48px at `sm` and 48px/56px at `lg`, or `size="xl"`
* for 32px/40px, 48px/56px at `sm` and 56px/56px at `lg`.
* `variant="serif"` uses the kit's serif role; the default keeps the
* surrounding display face. Both variants support all three sizes.
* Pass `render` to use another heading level. A page's headline is `Heading`.
*/
function Subheading({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof subheadingVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "subheading", variant, size },
props: mergeProps<"h2">(
{
className: cn(subheadingVariants({ variant, size }), className),
},
props
),
})
}
export { Subheading, subheadingVariants }
pnpm dlx shadcn@latest add @01orbital/sphere-button-empty-statenpx shadcn@latest add @01orbital/sphere-button-empty-stateyarn dlx shadcn@latest add @01orbital/sphere-button-empty-statebunx --bun shadcn@latest add @01orbital/sphere-button-empty-stateEvent Rsvpsphere-button-event-rsvp
Sphere Button Event Rsvp: an example of sphere-button.
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Subheading } from "@/components/subheading/subheading"
// The copy: change text here, not in the markup.
const COPY = {
date: "Sat, Nov 22",
title: "Autumn Supper Club",
where: "The Glasshouse, 14 Alder Street",
time: "6:30 pm to 10:00 pm",
spots: "12 seats left",
cta: "RSVP",
} as const
/** A void Sphere Button link as the RSVP on an event invitation card. */
export default function SphereButtonEventRsvp() {
return (
<article className="flex w-full max-w-xl flex-wrap items-center justify-between gap-8 rounded-3xl border border-border bg-card p-8 text-card-foreground">
<div>
<Eyebrow>{COPY.date}</Eyebrow>
<Subheading render={<h3 />} className="mt-2">
{COPY.title}
</Subheading>
<p className="mt-3 text-sm">{COPY.where}</p>
<p className="text-sm text-muted-foreground">{COPY.time}</p>
<p className="mt-4 text-xs text-muted-foreground">{COPY.spots}</p>
</div>
<SphereButton variant="void" render={<a href="#rsvp" />}>
{COPY.cta}
</SphereButton>
</article>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const eyebrowVariants = cva("text-eyebrow", {
variants: {
/**
* `default` is a 14px/20px label. `icon` adds a row with a 16px icon
* and a 12px gap; put the icon first and give it `aria-hidden`.
* `mono` and `caps` are 12px/20px uppercase labels with 0.12em
* tracking, in the mono and inherited faces respectively.
*/
variant: {
default: "text-sm/5 font-medium text-eyebrow",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium tracking-[0.12em] uppercase",
caps: "text-xs/5 font-medium tracking-[0.12em] uppercase",
},
},
defaultVariants: { variant: "default" },
})
/**
* A short label above a heading, rendered as a `<p>` at weight 500.
* The default is 14px/20px in the kit's eyebrow color. The surrounding
* layout controls the space to the heading. Use `className` to customize
* the typography or color, and `render` to change the element.
*/
function Eyebrow({
className,
variant = "default",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const subheadingVariants = cva(
"font-display font-[450] tracking-[-0.05em] text-pretty sm:tracking-[-0.06em]",
{
variants: {
/**
* `default` inherits the surrounding display face. `serif` uses
* the kit's serif role, without changing the surrounding font.
*/
variant: {
default: "",
serif: "[--font-display:var(--font-serif)]",
},
/**
* `md` (the default): 32px/40px, capped at 40px/44px from `sm`.
* `lg`: 32px/40px, 40px/48px from `sm`, 48px/56px from `lg`.
* `xl`: 32px/40px, 48px/56px from `sm`, 56px/56px from `lg`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 sm:text-5xl/14 lg:text-[3.5rem]/14",
},
},
defaultVariants: { variant: "default", size: "md" },
}
)
/**
* The section heading in the display font, which follows `font-sans`
* unless a block switches that role. Rendered as an `<h2>` at weight 450.
* The default `size="md"` steps
* from 32px/40px to 40px/44px at `sm` and stays there. Choose `size="lg"`
* for 32px/40px, 40px/48px at `sm` and 48px/56px at `lg`, or `size="xl"`
* for 32px/40px, 48px/56px at `sm` and 56px/56px at `lg`.
* `variant="serif"` uses the kit's serif role; the default keeps the
* surrounding display face. Both variants support all three sizes.
* Pass `render` to use another heading level. A page's headline is `Heading`.
*/
function Subheading({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof subheadingVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "subheading", variant, size },
props: mergeProps<"h2">(
{
className: cn(subheadingVariants({ variant, size }), className),
},
props
),
})
}
export { Subheading, subheadingVariants }
pnpm dlx shadcn@latest add @01orbital/sphere-button-event-rsvpnpx shadcn@latest add @01orbital/sphere-button-event-rsvpyarn dlx shadcn@latest add @01orbital/sphere-button-event-rsvpbunx --bun shadcn@latest add @01orbital/sphere-button-event-rsvpGlaciersphere-button-glacier
Sphere Button Glacier: an example of sphere-button.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
title: "Glacier",
body: "Cold cyan-blue faces with a deeper center beneath the white label.",
solid: {
ariaLabel: "Explore Glacier solid",
label: "Explore",
caption: "Solid / lift",
},
void: {
ariaLabel: "Enter Glacier void",
label: "Enter",
caption: "Void / open",
},
} as const
/** Cold cyan-blue Sphere Buttons on a deep blue surface, with a lifting solid sphere beside a void sphere that opens on hover. */
export default function SphereButtonGlacier() {
return (
<div className="dark flex w-full justify-center">
<Card className="theme-blue relative isolate w-full max-w-[608px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[480px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="gap-2">
<CardTitle className="text-[17px]/[26px] font-medium tracking-[-0.02em]">
{COPY.title}
</CardTitle>
<CardDescription className="text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex justify-center gap-10 pt-1 max-[600px]:gap-6 max-[600px]:pt-0">
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="default"
size="md"
aria-label={COPY.solid.ariaLabel}
className="[filter:hue-rotate(17deg)_saturate(1.8)_contrast(1.08)_brightness(0.9)_contrast(1.3)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.solid.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.solid.caption}
</figcaption>
</figure>
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="void"
size="md"
aria-label={COPY.void.ariaLabel}
className="[filter:hue-rotate(180deg)_saturate(1.8)_contrast(1.08)_brightness(0.9)_contrast(1.3)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.void.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.void.caption}
</figcaption>
</figure>
</CardContent>
</Card>
</div>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-glaciernpx shadcn@latest add @01orbital/sphere-button-glacieryarn dlx shadcn@latest add @01orbital/sphere-button-glacierbunx --bun shadcn@latest add @01orbital/sphere-button-glacierLight Noirsphere-button-light-noir
Sphere Button Light Noir: an example of sphere-button.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
title: "Light noir",
body: "Near-black faces on paper, keeping the native highlights and shadows.",
solid: {
ariaLabel: "Explore Light noir solid",
label: "Explore",
caption: "Solid / lift",
},
void: {
ariaLabel: "Enter Light noir void",
label: "Enter",
caption: "Void / open",
},
} as const
/** Near-black Sphere Buttons on a white page that keep the native highlights, with a solid sphere that lifts and a void sphere that opens. */
export default function SphereButtonLightNoir() {
return (
<Card className="relative isolate w-full max-w-[608px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[480px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="gap-2">
<CardTitle className="text-[17px]/[26px] font-medium tracking-[-0.02em]">
{COPY.title}
</CardTitle>
<CardDescription className="text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex justify-center gap-10 pt-1 max-[600px]:gap-6 max-[600px]:pt-0">
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="default"
size="md"
aria-label={COPY.solid.ariaLabel}
className="[filter:grayscale(1)_contrast(1.9)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.solid.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.solid.caption}
</figcaption>
</figure>
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="void"
size="md"
aria-label={COPY.void.ariaLabel}
className="[filter:grayscale(1)_contrast(1.9)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.void.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.void.caption}
</figcaption>
</figure>
</CardContent>
</Card>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-light-noirnpx shadcn@latest add @01orbital/sphere-button-light-noiryarn dlx shadcn@latest add @01orbital/sphere-button-light-noirbunx --bun shadcn@latest add @01orbital/sphere-button-light-noirMintsphere-button-mint
Sphere Button example: mint green spheres on an ink ground, one solid and lifting, one void and opening, both in the same clean green family. Use it to pick a green call to action on dark.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
title: "Mint",
body: "Clean green and teal light, without a yellow or olive shift.",
solid: {
ariaLabel: "Explore Mint solid",
label: "Explore",
caption: "Solid / lift",
},
void: {
ariaLabel: "Enter Mint void",
label: "Enter",
caption: "Void / open",
},
} as const
/** Mint green Sphere Buttons on an ink ground, one solid and lifting, one void and opening, both in the same clean green family. */
export default function SphereButtonMint() {
return (
<Card className="dark relative isolate w-full max-w-[608px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[480px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="gap-2">
<CardTitle className="text-[17px]/[26px] font-medium tracking-[-0.02em]">
{COPY.title}
</CardTitle>
<CardDescription className="text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex justify-center gap-10 pt-1 max-[600px]:gap-6 max-[600px]:pt-0">
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="default"
size="md"
aria-label={COPY.solid.ariaLabel}
className="[filter:hue-rotate(354deg)_saturate(1.8)_contrast(1.14)_brightness(0.88)_contrast(1.35)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.solid.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.solid.caption}
</figcaption>
</figure>
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="void"
size="md"
aria-label={COPY.void.ariaLabel}
className="[filter:hue-rotate(156deg)_saturate(1.8)_contrast(1.14)_brightness(0.88)_contrast(1.35)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.void.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.void.caption}
</figcaption>
</figure>
</CardContent>
</Card>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-mintnpx shadcn@latest add @01orbital/sphere-button-mintyarn dlx shadcn@latest add @01orbital/sphere-button-mintbunx --bun shadcn@latest add @01orbital/sphere-button-mintMonotone Graphitesphere-button-monotone-graphite
Sphere Button Monotone Graphite: an example of sphere-button.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
title: "Monotone / Graphite",
body: "Neutral graphite faces, softer and lighter than the noir treatment.",
solid: {
ariaLabel: "Explore Monotone / Graphite solid",
label: "Explore",
caption: "Solid / lift",
},
void: {
ariaLabel: "Enter Monotone / Graphite void",
label: "Enter",
caption: "Void / open",
},
} as const
/** A pair of graphite gray Sphere Buttons on paper, softer than the noir pair, with the solid one lifting and the void one opening on hover. */
export default function SphereButtonMonotoneGraphite() {
return (
<Card className="relative isolate w-full max-w-[608px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[480px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="gap-2">
<CardTitle className="text-[17px]/[26px] font-medium tracking-[-0.02em]">
{COPY.title}
</CardTitle>
<CardDescription className="text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex justify-center gap-10 pt-1 max-[600px]:gap-6 max-[600px]:pt-0">
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="default"
size="md"
aria-label={COPY.solid.ariaLabel}
className="[filter:grayscale(1)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.solid.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.solid.caption}
</figcaption>
</figure>
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="void"
size="md"
aria-label={COPY.void.ariaLabel}
className="[filter:grayscale(1)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.void.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.void.caption}
</figcaption>
</figure>
</CardContent>
</Card>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-monotone-graphitenpx shadcn@latest add @01orbital/sphere-button-monotone-graphiteyarn dlx shadcn@latest add @01orbital/sphere-button-monotone-graphitebunx --bun shadcn@latest add @01orbital/sphere-button-monotone-graphiteMonotone Silversphere-button-monotone-silver
Sphere Button Monotone Silver: an example of sphere-button.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Badge } from "@/components/ui/badge"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
title: "Monotone / Silver",
body: "Cloud Dancer’s pearl material in grayscale, set against an ink ground.",
solid: {
ariaLabel: "Explore Monotone / Silver solid",
label: "Explore",
caption: "Solid / lift",
},
void: {
ariaLabel: "Enter Monotone / Silver void",
label: "Enter",
caption: "Void / open",
},
} as const
/** Silver pearl Sphere Buttons in grayscale on an ink ground, where the solid sphere lifts and the void sphere opens its dark center. */
export default function SphereButtonMonotoneSilver() {
return (
<Card className="dark relative isolate w-full max-w-[608px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[480px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="gap-2">
<CardTitle className="text-[17px]/[26px] font-medium tracking-[-0.02em]">
{COPY.title}
</CardTitle>
<CardDescription className="text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex justify-center gap-10 pt-1 max-[600px]:gap-6 max-[600px]:pt-0">
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="default"
size="md"
aria-label={COPY.solid.ariaLabel}
className="bg-[radial-gradient(circle_at_35%_35%,#ffffff_0%,oklch(0.995_0.002_90)_40%,oklch(0.915_0.006_85)_100%)] text-[oklch(0.22_0.008_60)] shadow-[inset_-2px_-3px_5px_rgb(140_140_140_/_0.28),inset_-1px_-1px_3px_rgb(140_140_140_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(140_140_140_/_0.1),0_1.5px_4px_rgb(140_140_140_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06)] [filter:grayscale(1)] [text-shadow:none] not-disabled:hover:shadow-[inset_-2px_-3px_5px_rgb(140_140_140_/_0.28),inset_-1px_-1px_3px_rgb(140_140_140_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(140_140_140_/_0.1),0_1.5px_4px_rgb(140_140_140_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06),0_6px_16px_rgb(140_140_140_/_0.16)] not-disabled:focus-visible:shadow-[inset_-2px_-3px_5px_rgb(140_140_140_/_0.28),inset_-1px_-1px_3px_rgb(140_140_140_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(140_140_140_/_0.1),0_1.5px_4px_rgb(140_140_140_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06),0_6px_16px_rgb(140_140_140_/_0.16)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.solid.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.solid.caption}
</figcaption>
</figure>
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="void"
size="md"
aria-label={COPY.void.ariaLabel}
className="[filter:grayscale(1)] max-[600px]:size-24 max-[600px]:text-sm [&>[data-slot=sphere-button-paint]]:bg-[radial-gradient(circle_at_35%_35%,#ffffff_0%,oklch(0.995_0.002_90)_40%,oklch(0.915_0.006_85)_100%)] [&>[data-slot=sphere-button-paint]]:shadow-[inset_-2px_-3px_5px_rgb(140_140_140_/_0.28),inset_-1px_-1px_3px_rgb(140_140_140_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(140_140_140_/_0.1),0_1.5px_4px_rgb(140_140_140_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06)]"
>
<Badge className="h-auto max-w-full bg-[oklch(0.13_0_0)] px-3 py-1.5 text-[length:inherit] leading-normal font-normal whitespace-normal text-[oklch(0.985_0.003_90)] [text-shadow:none]">
{COPY.void.label}
</Badge>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.void.caption}
</figcaption>
</figure>
</CardContent>
</Card>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-monotone-silvernpx shadcn@latest add @01orbital/sphere-button-monotone-silveryarn dlx shadcn@latest add @01orbital/sphere-button-monotone-silverbunx --bun shadcn@latest add @01orbital/sphere-button-monotone-silverOnboarding Startsphere-button-onboarding-start
Sphere Button Onboarding Start: an example of sphere-button.
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Subheading } from "@/components/subheading/subheading"
// The copy: change text here, not in the markup.
const COPY = {
step: "Step 1 of 3",
title: "Welcome to Harbor",
body: "Three quick steps and your workspace is ready: name it, invite your team, connect your first tool.",
cta: "Start",
skip: "Skip for now",
} as const
/** A large teal Sphere Button starting a three-step onboarding welcome screen. */
export default function SphereButtonOnboardingStart() {
return (
<section className="flex w-full max-w-lg flex-col items-center rounded-3xl bg-muted p-10 text-center text-foreground">
<Eyebrow>{COPY.step}</Eyebrow>
<Subheading render={<h3 />} className="mt-3">
{COPY.title}
</Subheading>
<p className="mt-3 max-w-sm text-sm/6 text-muted-foreground">
{COPY.body}
</p>
<SphereButton size="lg" className="mt-8" render={<a href="#step-1" />}>
{COPY.cta}
</SphereButton>
<a
href="#home"
className="mt-6 text-sm text-muted-foreground underline underline-offset-4"
>
{COPY.skip}
</a>
</section>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const eyebrowVariants = cva("text-eyebrow", {
variants: {
/**
* `default` is a 14px/20px label. `icon` adds a row with a 16px icon
* and a 12px gap; put the icon first and give it `aria-hidden`.
* `mono` and `caps` are 12px/20px uppercase labels with 0.12em
* tracking, in the mono and inherited faces respectively.
*/
variant: {
default: "text-sm/5 font-medium text-eyebrow",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium tracking-[0.12em] uppercase",
caps: "text-xs/5 font-medium tracking-[0.12em] uppercase",
},
},
defaultVariants: { variant: "default" },
})
/**
* A short label above a heading, rendered as a `<p>` at weight 500.
* The default is 14px/20px in the kit's eyebrow color. The surrounding
* layout controls the space to the heading. Use `className` to customize
* the typography or color, and `render` to change the element.
*/
function Eyebrow({
className,
variant = "default",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const subheadingVariants = cva(
"font-display font-[450] tracking-[-0.05em] text-pretty sm:tracking-[-0.06em]",
{
variants: {
/**
* `default` inherits the surrounding display face. `serif` uses
* the kit's serif role, without changing the surrounding font.
*/
variant: {
default: "",
serif: "[--font-display:var(--font-serif)]",
},
/**
* `md` (the default): 32px/40px, capped at 40px/44px from `sm`.
* `lg`: 32px/40px, 40px/48px from `sm`, 48px/56px from `lg`.
* `xl`: 32px/40px, 48px/56px from `sm`, 56px/56px from `lg`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 sm:text-5xl/14 lg:text-[3.5rem]/14",
},
},
defaultVariants: { variant: "default", size: "md" },
}
)
/**
* The section heading in the display font, which follows `font-sans`
* unless a block switches that role. Rendered as an `<h2>` at weight 450.
* The default `size="md"` steps
* from 32px/40px to 40px/44px at `sm` and stays there. Choose `size="lg"`
* for 32px/40px, 40px/48px at `sm` and 48px/56px at `lg`, or `size="xl"`
* for 32px/40px, 48px/56px at `sm` and 56px/56px at `lg`.
* `variant="serif"` uses the kit's serif role; the default keeps the
* surrounding display face. Both variants support all three sizes.
* Pass `render` to use another heading level. A page's headline is `Heading`.
*/
function Subheading({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof subheadingVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "subheading", variant, size },
props: mergeProps<"h2">(
{
className: cn(subheadingVariants({ variant, size }), className),
},
props
),
})
}
export { Subheading, subheadingVariants }
pnpm dlx shadcn@latest add @01orbital/sphere-button-onboarding-startnpx shadcn@latest add @01orbital/sphere-button-onboarding-startyarn dlx shadcn@latest add @01orbital/sphere-button-onboarding-startbunx --bun shadcn@latest add @01orbital/sphere-button-onboarding-startOriginal Pairsphere-button-original-pair
Sphere Button Original Pair: an example of sphere-button.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
title: "Original pair",
body: "The native pair: a teal solid and coral void, intentionally different colors.",
solid: {
ariaLabel: "Explore Original pair solid",
label: "Explore",
caption: "Solid / lift",
},
void: {
ariaLabel: "Enter Original pair void",
label: "Enter",
caption: "Void / open",
},
} as const
/** The stock Sphere Button pair on an ink ground, a teal solid and a coral void, side by side with their native hover effects. */
export default function SphereButtonOriginalPair() {
return (
<Card className="dark relative isolate w-full max-w-[608px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[480px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="gap-2">
<CardTitle className="text-[17px]/[26px] font-medium tracking-[-0.02em]">
{COPY.title}
</CardTitle>
<CardDescription className="text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex justify-center gap-10 pt-1 max-[600px]:gap-6 max-[600px]:pt-0">
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="default"
size="md"
aria-label={COPY.solid.ariaLabel}
className="max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.solid.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.solid.caption}
</figcaption>
</figure>
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="void"
size="md"
aria-label={COPY.void.ariaLabel}
className="max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.void.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.void.caption}
</figcaption>
</figure>
</CardContent>
</Card>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-original-pairnpx shadcn@latest add @01orbital/sphere-button-original-pairyarn dlx shadcn@latest add @01orbital/sphere-button-original-pairbunx --bun shadcn@latest add @01orbital/sphere-button-original-pairPricing Linksphere-button-pricing-link
Sphere Button Pricing Link: an example of sphere-button.
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Subheading } from "@/components/subheading/subheading"
// The copy: change text here, not in the markup.
const COPY = {
eyebrow: "Plans",
title: "Find the plan that fits your team.",
body: "Compare Starter, Team and Studio side by side. Switch or cancel any month.",
cta: "See pricing",
} as const
/** A teal Sphere Button rendered as a link beside a short pricing pitch. */
export default function SphereButtonPricingLink() {
return (
<section className="flex w-full max-w-2xl flex-wrap items-center justify-between gap-8 rounded-3xl border border-border bg-card p-8 text-card-foreground">
<div className="max-w-sm">
<Eyebrow>{COPY.eyebrow}</Eyebrow>
<Subheading render={<h3 />} className="mt-2">
{COPY.title}
</Subheading>
<p className="mt-3 text-sm/6 text-muted-foreground">{COPY.body}</p>
</div>
<SphereButton render={<a href="#pricing" />}>{COPY.cta}</SphereButton>
</section>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const eyebrowVariants = cva("text-eyebrow", {
variants: {
/**
* `default` is a 14px/20px label. `icon` adds a row with a 16px icon
* and a 12px gap; put the icon first and give it `aria-hidden`.
* `mono` and `caps` are 12px/20px uppercase labels with 0.12em
* tracking, in the mono and inherited faces respectively.
*/
variant: {
default: "text-sm/5 font-medium text-eyebrow",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium tracking-[0.12em] uppercase",
caps: "text-xs/5 font-medium tracking-[0.12em] uppercase",
},
},
defaultVariants: { variant: "default" },
})
/**
* A short label above a heading, rendered as a `<p>` at weight 500.
* The default is 14px/20px in the kit's eyebrow color. The surrounding
* layout controls the space to the heading. Use `className` to customize
* the typography or color, and `render` to change the element.
*/
function Eyebrow({
className,
variant = "default",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const subheadingVariants = cva(
"font-display font-[450] tracking-[-0.05em] text-pretty sm:tracking-[-0.06em]",
{
variants: {
/**
* `default` inherits the surrounding display face. `serif` uses
* the kit's serif role, without changing the surrounding font.
*/
variant: {
default: "",
serif: "[--font-display:var(--font-serif)]",
},
/**
* `md` (the default): 32px/40px, capped at 40px/44px from `sm`.
* `lg`: 32px/40px, 40px/48px from `sm`, 48px/56px from `lg`.
* `xl`: 32px/40px, 48px/56px from `sm`, 56px/56px from `lg`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 sm:text-5xl/14 lg:text-[3.5rem]/14",
},
},
defaultVariants: { variant: "default", size: "md" },
}
)
/**
* The section heading in the display font, which follows `font-sans`
* unless a block switches that role. Rendered as an `<h2>` at weight 450.
* The default `size="md"` steps
* from 32px/40px to 40px/44px at `sm` and stays there. Choose `size="lg"`
* for 32px/40px, 40px/48px at `sm` and 48px/56px at `lg`, or `size="xl"`
* for 32px/40px, 48px/56px at `sm` and 56px/56px at `lg`.
* `variant="serif"` uses the kit's serif role; the default keeps the
* surrounding display face. Both variants support all three sizes.
* Pass `render` to use another heading level. A page's headline is `Heading`.
*/
function Subheading({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof subheadingVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "subheading", variant, size },
props: mergeProps<"h2">(
{
className: cn(subheadingVariants({ variant, size }), className),
},
props
),
})
}
export { Subheading, subheadingVariants }
pnpm dlx shadcn@latest add @01orbital/sphere-button-pricing-linknpx shadcn@latest add @01orbital/sphere-button-pricing-linkyarn dlx shadcn@latest add @01orbital/sphere-button-pricing-linkbunx --bun shadcn@latest add @01orbital/sphere-button-pricing-linkSmall Invitationsphere-button-small-invitation
Sphere Button Small Invitation: an example of sphere-button.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
eyebrow: "01 / Navigation",
title: "A small invitation",
body: "One sphere, with somewhere useful to go.",
label: "Free kit",
footnote: "Explore the free collection.",
} as const
/** A Sphere Button link in pearl on warm paper, set in a card with a label, a short headline and a one-line note below. */
export default function SphereButtonSmallInvitation() {
return (
<Card className="relative isolate w-full max-w-[400px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[380px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="min-w-0 gap-0">
<p className="text-[13px]/[22px] font-medium">{COPY.eyebrow}</p>
<CardTitle className="mt-3 font-display text-[23px]/[30px] font-normal tracking-[-0.035em]">
{COPY.title}
</CardTitle>
<CardDescription className="mt-2.5 text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex min-h-[190px] min-w-0 flex-1 flex-wrap items-center justify-center gap-5">
<SphereButton
variant="default"
size="md"
render={<a href="#" />}
className="bg-[radial-gradient(circle_at_35%_35%,#ffffff_0%,oklch(0.995_0.002_90)_40%,oklch(0.915_0.006_85)_100%)] text-[oklch(0.22_0.008_60)] shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06)] [text-shadow:none] not-disabled:hover:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06),0_6px_16px_rgb(196_112_112_/_0.16)] not-disabled:focus-visible:shadow-[inset_-2px_-3px_5px_rgb(196_112_112_/_0.28),inset_-1px_-1px_3px_rgb(196_112_112_/_0.15),inset_1.5px_2px_3px_rgb(255_255_255_/_0.85),inset_1px_1px_2px_rgb(255_255_255_/_0.6),inset_-3px_-3px_6px_rgb(90_144_144_/_0.1),0_1.5px_4px_rgb(196_112_112_/_0.18),0_1px_2px_rgb(0_0_0_/_0.06),0_6px_16px_rgb(196_112_112_/_0.16)]"
>
<span className="inline-block max-w-full leading-normal">
{COPY.label}
</span>
</SphereButton>
</CardContent>
<CardFooter className="justify-center text-center text-[13px]/6 text-muted-foreground">
{COPY.footnote}
</CardFooter>
</Card>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-small-invitationnpx shadcn@latest add @01orbital/sphere-button-small-invitationyarn dlx shadcn@latest add @01orbital/sphere-button-small-invitationbunx --bun shadcn@latest add @01orbital/sphere-button-small-invitationUpgrade Cardsphere-button-upgrade-card
Sphere Button Upgrade Card: an example of sphere-button.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Subheading } from "@/components/subheading/subheading"
// The copy: change text here, not in the markup.
const COPY = {
title: "You have used 9 of 10 free projects.",
body: "Upgrade to Pro for unlimited projects, version history and priority support.",
cta: "Upgrade",
price: "$12 per month, cancel anytime.",
} as const
/** A coral Sphere Button link on an in-app upgrade prompt for a usage limit. */
export default function SphereButtonUpgradeCard() {
return (
<aside className="flex w-full max-w-xl flex-wrap items-center justify-between gap-8 rounded-3xl border border-border bg-card p-8 text-card-foreground">
<div className="max-w-xs">
<Subheading render={<h3 />}>{COPY.title}</Subheading>
<p className="mt-2 text-sm/6 text-muted-foreground">{COPY.body}</p>
<p className="mt-4 text-xs text-muted-foreground">{COPY.price}</p>
</div>
<SphereButton variant="coral" size="sm" render={<a href="#upgrade" />}>
{COPY.cta}
</SphereButton>
</aside>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const subheadingVariants = cva(
"font-display font-[450] tracking-[-0.05em] text-pretty sm:tracking-[-0.06em]",
{
variants: {
/**
* `default` inherits the surrounding display face. `serif` uses
* the kit's serif role, without changing the surrounding font.
*/
variant: {
default: "",
serif: "[--font-display:var(--font-serif)]",
},
/**
* `md` (the default): 32px/40px, capped at 40px/44px from `sm`.
* `lg`: 32px/40px, 40px/48px from `sm`, 48px/56px from `lg`.
* `xl`: 32px/40px, 48px/56px from `sm`, 56px/56px from `lg`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 sm:text-5xl/14 lg:text-[3.5rem]/14",
},
},
defaultVariants: { variant: "default", size: "md" },
}
)
/**
* The section heading in the display font, which follows `font-sans`
* unless a block switches that role. Rendered as an `<h2>` at weight 450.
* The default `size="md"` steps
* from 32px/40px to 40px/44px at `sm` and stays there. Choose `size="lg"`
* for 32px/40px, 40px/48px at `sm` and 48px/56px at `lg`, or `size="xl"`
* for 32px/40px, 48px/56px at `sm` and 56px/56px at `lg`.
* `variant="serif"` uses the kit's serif role; the default keeps the
* surrounding display face. Both variants support all three sizes.
* Pass `render` to use another heading level. A page's headline is `Heading`.
*/
function Subheading({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof subheadingVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "subheading", variant, size },
props: mergeProps<"h2">(
{
className: cn(subheadingVariants({ variant, size }), className),
},
props
),
})
}
export { Subheading, subheadingVariants }
pnpm dlx shadcn@latest add @01orbital/sphere-button-upgrade-cardnpx shadcn@latest add @01orbital/sphere-button-upgrade-cardyarn dlx shadcn@latest add @01orbital/sphere-button-upgrade-cardbunx --bun shadcn@latest add @01orbital/sphere-button-upgrade-cardVioletsphere-button-violet
Sphere Button Violet: an example of sphere-button.
import { SphereButton } from "@/components/sphere-button/sphere-button"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
title: "Violet",
body: "Violet and purple light, with both faces in the same hue family.",
solid: {
ariaLabel: "Explore Violet solid",
label: "Explore",
caption: "Solid / lift",
},
void: {
ariaLabel: "Enter Violet void",
label: "Enter",
caption: "Void / open",
},
} as const
/** Violet Sphere Buttons on a plum surface, pairing a solid sphere that lifts with a void sphere that opens its dark center on hover. */
export default function SphereButtonViolet() {
return (
<div className="dark flex w-full justify-center">
<Card className="theme-plum relative isolate w-full max-w-[608px] min-w-0 rounded-[20px] border border-border bg-background font-sans text-foreground shadow-none ring-0 [--card-spacing:--spacing(8)] max-[480px]:[--card-spacing:--spacing(5.5)]">
<CardHeader className="gap-2">
<CardTitle className="text-[17px]/[26px] font-medium tracking-[-0.02em]">
{COPY.title}
</CardTitle>
<CardDescription className="text-xs/[22px] text-muted-foreground">
{COPY.body}
</CardDescription>
</CardHeader>
<CardContent className="flex justify-center gap-10 pt-1 max-[600px]:gap-6 max-[600px]:pt-0">
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="default"
size="md"
aria-label={COPY.solid.ariaLabel}
className="[filter:hue-rotate(110deg)_saturate(1.8)_contrast(1.08)_brightness(0.95)_contrast(1.12)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.solid.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.solid.caption}
</figcaption>
</figure>
<figure className="grid min-w-0 justify-items-center gap-6 p-2.5 max-[480px]:p-1">
<SphereButton
variant="void"
size="md"
aria-label={COPY.void.ariaLabel}
className="[filter:hue-rotate(272deg)_saturate(1.8)_contrast(1.08)_brightness(0.95)_contrast(1.12)] max-[600px]:size-24 max-[600px]:text-sm"
>
<span className="inline-block max-w-full leading-normal">
{COPY.void.label}
</span>
</SphereButton>
<figcaption className="text-[11px]/5 text-muted-foreground">
{COPY.void.caption}
</figcaption>
</figure>
</CardContent>
</Card>
</div>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-violetnpx shadcn@latest add @01orbital/sphere-button-violetyarn dlx shadcn@latest add @01orbital/sphere-button-violetbunx --bun shadcn@latest add @01orbital/sphere-button-violetVoidsphere-button-void
Example of the Sphere Button in its void variant at the large size: a textured coral sphere whose dark center opens on hover or focus.
import { SphereButton } from "@/components/sphere-button/sphere-button"
// The copy: change text here, not in the markup.
const COPY = { cta: "Enter" } as const
/**
* Sphere Button in its void variant at the large size: a textured coral
* sphere whose dark center opens on hover or focus.
*/
export default function SphereButtonVoid() {
return (
<SphereButton variant="void" size="lg">
{COPY.cta}
</SphereButton>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
pnpm dlx shadcn@latest add @01orbital/sphere-button-voidnpx shadcn@latest add @01orbital/sphere-button-voidyarn dlx shadcn@latest add @01orbital/sphere-button-voidbunx --bun shadcn@latest add @01orbital/sphere-button-voidWaitlist Joinsphere-button-waitlist-join
Sphere Button Waitlist Join: an example of sphere-button.
"use client"
import { useState } from "react"
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Subheading } from "@/components/subheading/subheading"
import { Input } from "@/components/ui/input"
// The copy: change text here, not in the markup.
const COPY = {
title: "Join the waitlist",
body: "Early access opens in January. We will write once, when your spot is ready.",
label: "Email address",
placeholder: "you@studio.com",
cta: "Join",
done: "You are on the list. See you in January.",
} as const
/** A blue Sphere Button submitting an email field, swapping to a thank-you line once sent. */
export default function SphereButtonWaitlistJoin() {
const [sent, setSent] = useState(false)
return (
<section className="w-full max-w-xl rounded-3xl border border-border bg-card p-8 text-card-foreground">
<Subheading render={<h3 />}>{COPY.title}</Subheading>
<p className="mt-2 text-sm/6 text-muted-foreground">{COPY.body}</p>
{sent ? (
<p className="mt-6 text-sm font-medium" role="status">
{COPY.done}
</p>
) : (
<form
className="mt-6 flex flex-wrap items-center gap-6"
onSubmit={(event) => {
event.preventDefault()
setSent(true)
}}
>
<Input
type="email"
required
aria-label={COPY.label}
placeholder={COPY.placeholder}
className="min-w-48 flex-1"
/>
<SphereButton type="submit" variant="blue" size="sm">
{COPY.cta}
</SphereButton>
</form>
)}
</section>
)
}
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const subheadingVariants = cva(
"font-display font-[450] tracking-[-0.05em] text-pretty sm:tracking-[-0.06em]",
{
variants: {
/**
* `default` inherits the surrounding display face. `serif` uses
* the kit's serif role, without changing the surrounding font.
*/
variant: {
default: "",
serif: "[--font-display:var(--font-serif)]",
},
/**
* `md` (the default): 32px/40px, capped at 40px/44px from `sm`.
* `lg`: 32px/40px, 40px/48px from `sm`, 48px/56px from `lg`.
* `xl`: 32px/40px, 48px/56px from `sm`, 56px/56px from `lg`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 sm:text-5xl/14 lg:text-[3.5rem]/14",
},
},
defaultVariants: { variant: "default", size: "md" },
}
)
/**
* The section heading in the display font, which follows `font-sans`
* unless a block switches that role. Rendered as an `<h2>` at weight 450.
* The default `size="md"` steps
* from 32px/40px to 40px/44px at `sm` and stays there. Choose `size="lg"`
* for 32px/40px, 40px/48px at `sm` and 48px/56px at `lg`, or `size="xl"`
* for 32px/40px, 48px/56px at `sm` and 56px/56px at `lg`.
* `variant="serif"` uses the kit's serif role; the default keeps the
* surrounding display face. Both variants support all three sizes.
* Pass `render` to use another heading level. A page's headline is `Heading`.
*/
function Subheading({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof subheadingVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "subheading", variant, size },
props: mergeProps<"h2">(
{
className: cn(subheadingVariants({ variant, size }), className),
},
props
),
})
}
export { Subheading, subheadingVariants }
pnpm dlx shadcn@latest add @01orbital/sphere-button-waitlist-joinnpx shadcn@latest add @01orbital/sphere-button-waitlist-joinyarn dlx shadcn@latest add @01orbital/sphere-button-waitlist-joinbunx --bun shadcn@latest add @01orbital/sphere-button-waitlist-joinWebinar Registersphere-button-webinar-register
Sphere Button Webinar Register: an example of sphere-button.
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { SphereButton } from "@/components/sphere-button/sphere-button"
import { Subheading } from "@/components/subheading/subheading"
// The copy: change text here, not in the markup.
const COPY = {
eyebrow: "Live webinar",
title: "Designing onboarding that sticks",
when: "Thursday, Dec 4 at 11:00 am PT",
host: "Hosted by Maya Okafor, Head of Product at Lumen",
cta: "Save my seat",
} as const
/** A teal Sphere Button link as the register action in a webinar promo band. */
export default function SphereButtonWebinarRegister() {
return (
<section className="flex w-full max-w-3xl flex-wrap items-center gap-8 rounded-3xl bg-muted p-8 text-foreground">
<SphereButton size="lg" render={<a href="#register" />}>
{COPY.cta}
</SphereButton>
<div className="min-w-56 flex-1">
<Eyebrow>{COPY.eyebrow}</Eyebrow>
<Subheading render={<h3 />} className="mt-2">
{COPY.title}
</Subheading>
<p className="mt-3 text-sm font-medium">{COPY.when}</p>
<p className="mt-1 text-sm text-muted-foreground">{COPY.host}</p>
</div>
</section>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const eyebrowVariants = cva("text-eyebrow", {
variants: {
/**
* `default` is a 14px/20px label. `icon` adds a row with a 16px icon
* and a 12px gap; put the icon first and give it `aria-hidden`.
* `mono` and `caps` are 12px/20px uppercase labels with 0.12em
* tracking, in the mono and inherited faces respectively.
*/
variant: {
default: "text-sm/5 font-medium text-eyebrow",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium tracking-[0.12em] uppercase",
caps: "text-xs/5 font-medium tracking-[0.12em] uppercase",
},
},
defaultVariants: { variant: "default" },
})
/**
* A short label above a heading, rendered as a `<p>` at weight 500.
* The default is 14px/20px in the kit's eyebrow color. The surrounding
* layout controls the space to the heading. Use `className` to customize
* the typography or color, and `render` to change the element.
*/
function Eyebrow({
className,
variant = "default",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import type * as React from "react"
import { isValidElement } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// A planetary button: highlight at 30/30 and crescent inset shadows paint the
// light. Solid variants lift on hover; void opens a dark center instead.
const canvasTexture = `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
const sphereButton = cva(
[
"relative inline-flex aspect-square max-w-full shrink-0 items-center justify-center rounded-full border-0",
// Light ink (scene-foreground, L 0.985) clears 4.5:1 under the whole label
// on every variant and size; keep the stops this dark or the label fails.
"cursor-pointer font-display text-scene-foreground select-none [text-shadow:0_1px_3px_oklch(0_0_0/0.3)]",
"disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring",
],
{
variants: {
/**
* The paint. `default` (the default) is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, unless reduced
* motion is on. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center.
*/
variant: {
default: [
"bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.56_0.09_180)_0%,oklch(0.46_0.08_180)_50%,oklch(0.44_0.06_185)_100%)]",
"shadow-[inset_6px_6px_15px_oklch(1_0_0/0.25),inset_-3px_-3px_10px_oklch(0_0_0/0.15),4px_8px_20px_oklch(0_0_0/0.25)]",
"not-disabled:hover:shadow-[inset_8px_8px_20px_oklch(1_0_0/0.3),inset_-4px_-4px_15px_oklch(0_0_0/0.2),8px_12px_30px_oklch(0_0_0/0.3)]",
],
blue: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.56_0.05_215)_0%,oklch(0.47_0.06_220)_45%,oklch(0.44_0.04_220)_100%)]",
"shadow-[inset_4px_4px_12px_oklch(1_0_0/0.25),inset_-2px_-4px_8px_oklch(0.4_0.05_255),3px_6px_15px_oklch(0_0_0/0.2)]",
"not-disabled:hover:shadow-[inset_6px_6px_18px_oklch(1_0_0/0.35),inset_-3px_-6px_12px_oklch(0.4_0.05_255),6px_10px_25px_oklch(0_0_0/0.25)]",
],
coral: [
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15),0_8px_30px_oklch(0_0_0/0.4)]",
"not-disabled:hover:shadow-[inset_8px_8px_24px_oklch(1_0_0/0.28),inset_-4px_-4px_18px_oklch(0_0_0/0.2),0_10px_36px_oklch(0_0_0/0.45)]",
],
void: "group/void-sphere overflow-hidden shadow-[0_8px_30px_oklch(0_0_0/0.4)]",
},
/**
* The diameter and label size: `sm` 96px with 14px text, `md` (the
* default) 128px with 16px text, `lg` 160px with 18px text.
*/
size: {
sm: "size-24 text-sm",
md: "size-32 text-base",
lg: "size-40 text-lg",
},
},
compoundVariants: [
{
variant: ["default", "blue", "coral"],
class:
"transition-[scale,box-shadow] duration-300 ease-[ease] motion-safe:not-disabled:hover:scale-105 motion-safe:focus-visible:scale-105",
},
],
defaultVariants: {
variant: "default",
size: "md",
},
}
)
/**
* A round call-to-action button painted as a lit planet, with its label in
* the display face. It renders a `<button>` with `type="button"` unless you pass
* another type. Pass `render` to use another element, such as a link:
* `<SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>`.
* A link keeps its own semantics and focus, and gets the same hover and
* keyboard-focus effects.
*
* `variant` sets the paint: `default` is teal, then `blue` and `coral`.
* These three grow by 5% on hover and keyboard focus, and their shadow
* deepens on hover. `void` rests as coral, and on hover or keyboard focus a
* dark circle opens from its center. `size` sets the diameter: `sm` 96px,
* `md` 128px (the default) or `lg` 160px. The label is always light,
* whatever the theme. With reduced motion on, nothing grows and the void
* opens at once.
*/
function SphereButton({
className,
variant,
size,
type,
texture = true,
children,
render,
style,
...props
}: useRender.ComponentProps<"button"> &
VariantProps<typeof sphereButton> & {
/**
* On `void` only: lays a fractal-noise canvas weave over the coral paint
* at 12% opacity. On by default.
*/
texture?: boolean
}) {
const look = variant
const content = (
<>
{look === "void" ? (
<>
{/* The paint goes once the void opens, or its rim shows as a hairline. */}
<span
data-slot="sphere-button-paint"
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-full",
"bg-[radial-gradient(ellipse_at_35%_35%,oklch(0.57_0.08_35)_0%,oklch(0.49_0.1_30)_35%,oklch(0.44_0.11_30)_60%,oklch(0.41_0.11_30)_100%)]",
"shadow-[inset_6px_6px_20px_oklch(1_0_0/0.2),inset_-4px_-4px_15px_oklch(0_0_0/0.15)]",
"transition-opacity duration-0 group-not-disabled/void-sphere:group-hover/void-sphere:opacity-0 group-focus-visible/void-sphere:opacity-0",
"motion-safe:group-not-disabled/void-sphere:group-hover/void-sphere:delay-500 motion-safe:group-focus-visible/void-sphere:delay-500"
)}
>
{texture && (
<span
data-slot="sphere-button-texture"
aria-hidden="true"
className="absolute inset-0 rounded-full opacity-12 mix-blend-multiply"
style={{ backgroundImage: canvasTexture }}
/>
)}
</span>
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,oklch(0.13_0_0)_0%,oklch(0.2_0_0)_100%)]",
"[clip-path:circle(0%_at_50%_50%)] group-not-disabled/void-sphere:group-hover/void-sphere:[clip-path:circle(65%_at_50%_50%)] group-focus-visible/void-sphere:[clip-path:circle(65%_at_50%_50%)]",
"motion-safe:transition-[clip-path] motion-safe:duration-500 motion-safe:ease-in-out"
)}
/>
<span className="relative">{children}</span>
</>
) : (
children
)}
</>
)
return useRender({
defaultTagName: "button",
render,
props: mergeProps<"button">(
{
// An explicit type always wins. Otherwise a button (the default, or a
// rendered <button>) gets type="button" so it never submits a form by
// accident; a rendered link takes no type.
type:
type ??
(!render || (isValidElement(render) && render.type === "button")
? "button"
: undefined),
className: cn(sphereButton({ variant: look, size }), className),
children: content,
// After the consumer's style, so neither a class nor a style can
// split the sphere's width from its height.
style: {
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
},
},
props
),
// Written as data-slot and data-variant on the rendered element.
state: { slot: "sphere-button", variant: look ?? "default" },
})
}
export { SphereButton }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const subheadingVariants = cva(
"font-display font-[450] tracking-[-0.05em] text-pretty sm:tracking-[-0.06em]",
{
variants: {
/**
* `default` inherits the surrounding display face. `serif` uses
* the kit's serif role, without changing the surrounding font.
*/
variant: {
default: "",
serif: "[--font-display:var(--font-serif)]",
},
/**
* `md` (the default): 32px/40px, capped at 40px/44px from `sm`.
* `lg`: 32px/40px, 40px/48px from `sm`, 48px/56px from `lg`.
* `xl`: 32px/40px, 48px/56px from `sm`, 56px/56px from `lg`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 sm:text-5xl/14 lg:text-[3.5rem]/14",
},
},
defaultVariants: { variant: "default", size: "md" },
}
)
/**
* The section heading in the display font, which follows `font-sans`
* unless a block switches that role. Rendered as an `<h2>` at weight 450.
* The default `size="md"` steps
* from 32px/40px to 40px/44px at `sm` and stays there. Choose `size="lg"`
* for 32px/40px, 40px/48px at `sm` and 48px/56px at `lg`, or `size="xl"`
* for 32px/40px, 48px/56px at `sm` and 56px/56px at `lg`.
* `variant="serif"` uses the kit's serif role; the default keeps the
* surrounding display face. Both variants support all three sizes.
* Pass `render` to use another heading level. A page's headline is `Heading`.
*/
function Subheading({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof subheadingVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "subheading", variant, size },
props: mergeProps<"h2">(
{
className: cn(subheadingVariants({ variant, size }), className),
},
props
),
})
}
export { Subheading, subheadingVariants }
pnpm dlx shadcn@latest add @01orbital/sphere-button-webinar-registernpx shadcn@latest add @01orbital/sphere-button-webinar-registeryarn dlx shadcn@latest add @01orbital/sphere-button-webinar-registerbunx --bun shadcn@latest add @01orbital/sphere-button-webinar-registerAPI reference
A round call-to-action button painted as a lit planet, with its label in the display face. It renders a <button> with type="button" unless you pass another type. Pass render to use another element, such as a link: <SphereButton render={<a href="/pricing" />}>See pricing</SphereButton>. A link keeps its own semantics and focus, and gets the same hover and keyboard-focus effects.
variant sets the paint: default is teal, then blue and coral. These three grow by 5% on hover and keyboard focus, and their shadow deepens on hover. void rests as coral, and on hover or keyboard focus a dark circle opens from its center. size sets the diameter: sm 96px, md 128px (the default) or lg 160px. The label is always light, whatever the theme. With reduced motion on, nothing grows and the void opens at once.
Prop
Type
It also accepts the props of the Base UI part it wraps, and the HTML attributes of the element it renders.
Dependencies
npm: @base-ui/react, class-variance-authority, cn. The CLI installs them for you.
Last updated on