asafefe.dev

Bell Icon

New

Rings on hover. The body swings from the top and the clapper follows a beat behind.

motion@soultel/use-icon-trigger
hover me

Installation

$ pnpm dlx shadcn@latest add @soultel/icon-bell

No namespace set up? npx shadcn@latest add https://asafefe.dev/r/icon-bell.json works too.

Manual installation
  1. 1. Install the dependencies.
    terminal1 lines
    npm install motion
  2. 2. Copy the source from the Code tab into components/icon-bell.tsx.

Usage

example.tsx10 lines
import { BellIcon } from "@/components/icon-bell"

export function Notifications({ unread }: { unread: number }) {
  // Rings when the count goes from zero to something.
  return (
    <button aria-label={`${unread} notifications`}>
      <BellIcon animate={unread > 0} />
    </button>
  )
}

Props

PropTypeDefaultDescription
sizenumber24Width and height in px.
strokeWidthnumber2Stroke width on the 24 by 24 grid.
animate"hover" | "always" | boolean"hover""hover" plays when the nearest button or link (or the icon) is hovered, focused or tapped. "always" loops. A boolean plays each time it turns true, so a parent can drive it.
labelstring-Accessible name. Without one the icon is aria-hidden.
classNamestring-Classes for the svg. Color comes from currentColor.