Skip to content

Story Ring Avatars with Gradient Border

Pure CSS story avatars with Instagram-style gradient rings, close friends and live variants, and a seen state that turns the ring grey on click.

Also known as: instagram stories avatars, story circles, gradient ring avatar, story highlights row

Story Ring Avatars with Gradient Border live demo

Open in new tab

Pure CSS code (HTML, CSS, JS)

A row of story avatars in the style of social apps, built with pure CSS and a little vanilla JavaScript. Each round photo sits inside a gradient ring that signals a new story, a green ring for close friends, a red ring with a Live badge, and a thin grey ring once the story has been seen. Use it above a feed or in a messaging sidebar.

How it works

The root section.sra-stories holds a header with a .sra-count badge, the scrollable ul.sra-list and a .sra-footer with a legend, size samples and a reset button. Every story is a button.sra-story that contains a .sra-ring, an img.sra-avatar and a .sra-name. The ring is not a border: .sra-ring has padding equal to --sra-ring-width, and its ::before pseudo element fills the circle behind the photo with var(--sra-ring-bg, var(--sra-gradient)). A solid photo border (--sra-gap) creates the white gap between ring and face. On hover or keyboard focus the pseudo element rotates, so the conic gradient appears to spin around the avatar.

Modifiers only change --sra-ring-bg: .sra-story--close uses --sra-close, .sra-story--live uses --sra-live, and .is-seen switches to --sra-seen and a 2px ring. .sra-story--own shows a thin grey ring with a blue .sra-add plus badge.

The script remembers each story's initial state, adds .is-seen when a story is clicked, updates the hidden .sra-state text and recounts unseen stories into .sra-count-num. The .sra-reset button restores the starting state. Without JavaScript the rings and states still render from the markup.

Customization

  • --sra-gradient on .sra-stories: the ring for new stories; swap the conic gradient for your brand colors.
  • --sra-close, --sra-live and --sra-seen: ring colors for close friends, live and seen stories.
  • --sra-size: the avatar diameter (68px on phones, 72px from 640px); the classes .sra-size-sm, .sra-size-md and .sra-size-lg show how to override it per avatar.
  • --sra-ring-width and --sra-gap: thickness of the ring and of the white gap around the photo.
  • --sra-spin: duration of one rotation of the hover animation, e.g. 1.2s for a faster spin.
  • Add is-seen to any .sra-story in the markup to start it as viewed, and set its .sra-state text to ", seen".
  • Replace the comment in the click handler of script.js with code that opens your own story viewer.

Use cases

  • Social feeds: a row of story avatars sits above the feed, with rings for new and seen stories
  • Messaging sidebars: close friends and live rings show who has something new
  • Community sites: the unseen counter and seen state show which stories were already opened
  • Creator profiles: a gradient-ringed avatar with a plus badge invites users to add their own story

Accessibility

Every story is a native button, so it is reachable with Tab and activated with Enter or Space. The visible username is part of the button label, and a visually hidden .sra-sr span adds the state ("new story", "close friends", "live now" or "seen"), so color is never the only cue. Photos use an empty alt because the name already labels the button. The unseen counter sits in an aria-live="polite" region. Focus shows a violet outline (--sra-focus), and with prefers-reduced-motion: reduce the spinning ring and press effect are disabled.

Usage notes

The portraits come from Unsplash; replace them with your users' own profile images. The script scopes everything to each .sra-stories root, so several rows can share a page.

Story Ring Avatars with Gradient Border at a glance

Framework
Pure CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
None
Layout
Responsive, works on mobile
Category
Avatars
License
Free for personal and commercial use

Questions about this template

Can I use the Story Ring Avatars with Gradient Border code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

There is nothing to install. Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

No dependencies. Pure HTML, CSS and JavaScript.

Story Ring Avatars with Gradient Border – free Pure CSS avatar template
Story Ring Avatars with Gradient Border · free Pure CSS avatar template

More Avatars

Avatar Sizes and Shapes with Photos – free Tailwind CSS avatar template

Avatar Sizes and Shapes with Photos

Tailwind CSS avatar set with photos in six sizes, circle and rounded-square shapes, status dots, stacked groups and initials.

Avatars with Status Indicator – free Bootstrap 5 avatar template

Avatars with Status Indicator

Bootstrap 5 avatars in five sizes with online, away, busy and offline status dots, initials fallback for missing photos and a status picker.

Avatar Group – free Tailwind CSS avatar template

Avatar Group

Overlapping Tailwind CSS avatar stack in three sizes with initials, status dots, name tooltips and a +N counter that reveals hidden people.