Updated
Story Ring
NewCustomize
Size64px
Color
Load time900ms
Installation
npx shadcn@latest add https://uibrik.com/r/story-ring.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/story-ring/story-ring.tsx"use client"; import { motion, useAnimationControls, useReducedMotion } from "motion/react"; import { useEffect, useId, useRef, useState } from "react"; import { cn } from "@/lib/utils"; const EASE_OUT: [number, number, number, number] = [0.23, 1, 0.32, 1]; export type StoryRingProps = { /** Avatar image. Without one, the initials show. */ src?: string; name: string; /** Stories in the ring: one arc each. */ count?: number; /** Controlled number of stories already seen. */ seen?: number; /** Stories seen on mount when uncontrolled. */ defaultSeen?: number; onSeenChange?: (seen: number) => void; /** * Called on press with the story to open (the first unseen one, or 0 once * all are seen). The ring spins until the returned promise settles. */ onOpen?: (index: number) => void | Promise<unknown>;
Adds the files to
components/uibrik/story-ring and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/story-ring.Usage
import { StoryRing } from "@/components/uibrik/story-ring/story-ring";<StoryRing name="…" size={64} color="#e1306c" loadTime={900} showName count={3} onOpen={(index) => {}} // src="…" // seen={0} // onSeenChange={(seen) => {}}/>Where to use Story Ring
Stories and status rows
One arc per story shows how many are left, and seen arcs drain to grey, so the row tells people where they left off.
Pairs with Avatar Stack
Unread updates on people
A coloured ring marks someone with something new without adding a badge or a count to the avatar.
Pairs with Presence Dot
Loading media from a profile
The ring itself becomes the spinner while the story fetches, so no separate loader covers the face.
Pairs with Social Avatar
Props
StoryRing- size
- Type number
- 64
- Avatar diameter.
- color
- Type string
- "#e1306c"
- Ring colour, drawn as a gradient of its own shades.
- colors
- Type string[]
- ["#feda75","#fa7e1e","#d62976","#962fbf","#4f5bd5"]
- Two or more colours for the ring's gradient.
- loadTime
- Type number
- 900
- How long the ring spins when onOpen returns no promise.
- showName
- Type boolean
- true
- Show the name under the avatar.
- namerequired
- Type string
- –
- Name under the avatar, and the initials when there's no photo.
- src
- Type string
- –
- Avatar image.
- count
- Type number
- 3
- Stories in the ring, one arc each.
- seen / onSeenChange
- Type number / (seen) => void
- –
- Controlled number of stories seen. defaultSeen for uncontrolled.
- onOpen
- Type (index) => void | Promise
- –
- Called on press with the story to open. The ring spins until the promise settles.
- className
- Type string
- –
- Classes for the wrapper.