calendar-date-range
An animated calendar-date-range icon for React that draws a calendar outline with two date-range lines and dots, playing a short motion when hovered or triggered through a ref. It is built on motion/react and renders an inline SVG that inherits currentColor.
shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @heroicons-animated in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { CalendarDateRangeIcon } from "@/components/ui/calendar-date-range";export function Example() { return <CalendarDateRangeIcon size={28} className="text-foreground" />;}- Showing a date range picker, booking period, or reporting window with a visual cue that responds to hover
- Adding a subtle, playful micro-interaction to a button, toolbar item, or filter chip that carries a date-range meaning
- Triggering the animation programmatically (for example when a filter becomes active) via the exposed ref handle
- Replacing a static calendar-range glyph in a dashboard or settings page where the icon should inherit the surrounding text color
Examples
Hover-driven icon inside a button
The icon animates on its own mouse enter and leave events. The size is set and the color is inherited via Tailwind text utilities.
import { CalendarDateRangeIcon } from "@/components/ui/calendar-date-range";export function DateRangeButton() { return ( <button type="button" className="inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm"> <CalendarDateRangeIcon size={20} className="text-blue-600" /> Select dates </button> );}Programmatic control through the ref handle
A parent button drives the animation with startAnimation and stopAnimation. Passing a ref switches the icon into controlled mode, so its own mouse handlers only forward events and no longer animate by themselves.
import { useRef } from "react";import { CalendarDateRangeIcon, type CalendarDateRangeIconHandle } from "@/components/ui/calendar-date-range";export function RangeFilter() { const iconRef = useRef<CalendarDateRangeIconHandle>(null); return ( <button type="button" onMouseEnter={() => iconRef.current?.startAnimation()} onMouseLeave={() => iconRef.current?.stopAnimation()} > <CalendarDateRangeIcon ref={iconRef} size={24} /> </button> );}Decorative icon next to a visible label
When the text label already describes the control, the icon is hidden from assistive technology with aria-hidden.
import { CalendarDateRangeIcon } from "@/components/ui/calendar-date-range";export function DateFilterLabel() { return ( <div className="flex items-center gap-2 text-sm font-medium"> <CalendarDateRangeIcon aria-hidden="true" size={20} /> <span>Select date range</span> </div> );}API reference
Accessibility
- The SVG has no title, role, or aria-label. When the icon conveys meaning on its own, wrap it in an element with role="img" and an aria-label such as "Date range", or pass aria-label directly on the wrapper.
- When the icon is decorative (a visible text label already explains the control), pass aria-hidden="true" so screen readers skip it.
- The animation is purely visual and conveys no information that is not also available in text, so it does not need an alternative. The component does not check prefers-reduced-motion; to honor that preference, skip calling startAnimation when the media query matches.
- Interactive wrappers such as buttons must provide their own accessible name, focus styles, and keyboard activation. The icon's mouse-only handlers do not respond to keyboard focus, so pair hover animations with onFocus and onBlur calls to startAnimation and stopAnimation when needed.
- Use currentColor-based colors with sufficient contrast against the background (WCAG 1.4.11 non-text contrast of at least 3:1) because the 1.5px stroke is thin.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "calendar-date-range" component (heroicons-animated/calendar-date-range) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/calendar-date-range2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: size, className, onMouseEnter, onMouseLeave, ref, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { CalendarDateRangeIcon } from "@/components/ui/calendar-date-range";export function Example() { return <CalendarDateRangeIcon size={28} className="text-foreground" />;}```Files & dependencies
- calendar-date-range.tsx