Arc Ring

Arc ring background graphic: a faint full ring with a bright stroke along part of it that fades toward its end, placed by its center and turning on its own when animated. Hidden from assistive tech; reduced motion holds it still.

Installation

npx shadcn@latest add @01orbital/arc-ring

Usage

import type { ComponentProps } from "react"

import { ArcLayer } from "@/components/glow/arc"
import { ArcRing } from "@/components/glow/arc-ring"
import { Grid } from "@/components/grid/grid"
import { DemoLabel } from "@/components/text/demo-label"

const COPY = {
  default: "Default: sweep 108, width 2.5, faint track",
  sweep: "sweep",
  width: "width",
  from: "from 200",
  color: "color amber, track amber at 20%",
  noTrack: "track transparent",
  animate: "animate: one turn every 26 s",
} as const

// The ring the examples start from, sized to show whole in a tile.
const BASE = { size: 220 } as const

const ITEMS: { label: string; props: ComponentProps<typeof ArcRing> }[] = [
  { label: COPY.default, props: {} },
  { label: `${COPY.sweep} 40`, props: { sweep: 40 } },
  { label: `${COPY.sweep} 240`, props: { sweep: 240 } },
  { label: `${COPY.width} 1`, props: { width: 1 } },
  { label: `${COPY.width} 6`, props: { width: 6 } },
  { label: COPY.from, props: { from: 200 } },
  {
    label: COPY.color,
    props: {
      color: "oklch(0.85 0.14 80)",
      track: "oklch(0.85 0.14 80 / 0.2)",
    },
  },
  { label: COPY.noTrack, props: { track: "transparent" } },
  { label: COPY.animate, props: { animate: true } },
]

/** Arc Ring as it ships, then with other sweeps, widths, a starting angle,
 * another color, no track, and turning. */
export default function ArcRingDemo() {
  return (
    <Grid cols={1} gap="sm" className="p-6 sm:grid-cols-2 lg:grid-cols-3">
      {ITEMS.map(({ label, props }) => (
        <div key={label} className="grid gap-2">
          <div className="dark relative isolate aspect-video overflow-hidden rounded-(--tile-radius) bg-background text-foreground">
            <ArcLayer>
              <ArcRing {...BASE} {...props} />
            </ArcLayer>
          </div>
          <DemoLabel>{label}</DemoLabel>
        </div>
      ))}
    </Grid>
  )
}

This example installs with everything it uses:

npx shadcn@latest add @01orbital/arc-ring-demo

API reference

A faint full ring with a bright stroke along part of it that fades toward its end, for the background behind a section. Place it like Arc: in an ArcLayer or another positioned parent, with left and top setting its center.

It is hidden from assistive tech and ignores the pointer. When animated it makes one full turn per duration; reduced motion holds it still.

Prop

Type

It also accepts the HTML attributes of the element it renders.

Dependencies

npm: cn. The CLI installs it for you.

Used in blocks

One block is built with Arc Ring.

Last updated on