shadcn.io is an independent project built on shadcn/ui
On this page9 sections
Inside one area, an animated cursor hides the system pointer and draws its own: a dot that sits exactly on the pointer, and if you want one, a label, a ring or a glow that eases after it. Use it where the pointer is part of the effect, on a hero, a portfolio piece or a drawing surface, and keep it away from the forms and tables people work in.
To show where other people are pointing, place a Cursor at their position instead.
Installation
Anatomy

Usage
<script lang="ts">
import {
AnimatedCursor, Cursor, CursorFollow,
} from "@/components/ui/animated-cursor";
</script>
With no children, Cursor draws a dot in the primary color. CursorFollow shows whatever you put inside it.
<AnimatedCursor class="flex h-64 items-center justify-center rounded-xl border">
<p>Hover over this area</p>
<Cursor />
<CursorFollow>
<span class="rounded-full bg-primary px-2.5 py-1 text-primary-foreground text-xs">
Following
</span>
</CursorFollow>
</AnimatedCursor>
Accessibility
Both parts carry aria-hidden and ignore the pointer, so screen readers skip them and every click lands on the content underneath. Keyboard focus and focus rings are untouched. The area does take away the system cursor, including one someone has enlarged in their system settings, so it keeps that cursor for people who prefer reduced motion or use forced colors, and touch input never starts the effect. Limit the area to the one section that needs it.
Demos
Interactive
A card about a quarterly report, with Reply, Archive and Star buttons and a link, and a dot on the pointer with a ring that follows it through a 250ms transition. Over any of those controls the area sets data-interactive, and classes under group-data-interactive/animated-cursor: shrink the dot away while the ring grows and fills. Use it when the area holds controls and the cursor should mark what can be clicked.
Label
A mock editor layout of blank panels, where the pointer becomes an arrow icon and a name tag reading Ava follows it. Cursor centers its children on the pointer, so the icon is shifted by half its size to put its tip on the hotspot. CursorFollow keeps the tag at the default bottom-end, 14 pixels away through sideOffset. Pick it for a walkthrough of a shared editor.
Align
Four areas, each with a label at a different align: top, end, bottom and start, 10 pixels from the pointer. start and end follow the reading direction, so on a right-to-left page end sits to the pointer's left. Near an edge the label is clipped by the area rather than widening the page, so choose the side that keeps it in view.
Trail
A card titled Slow light, where a blurred glow drifts after the dot and settles where the pointer stops. The glow is a CursorFollow set to center, with --cursor-follow-duration at 900ms for a loose trail. Both text lines are raised with z-30, above the glow, so it never washes out what people read.
FAQ
Does Animated Cursor hide the cursor on the whole page?
No, only inside the AnimatedCursor area, and only while a mouse or a pen is over it. The area sets data-active when the pointer comes in and clears it when the pointer leaves, and the system cursor is hidden only while that attribute is there.
On a touch screen, for people who prefer reduced motion and in forced colors mode, the system cursor stays and the custom parts never show. Wrap the one section that should have the effect, not the layout of the whole page.
What is the difference between Cursor and CursorFollow?
Cursor sits on the pointer, centered on it, with no lag. CursorFollow trails behind: every move starts a new ease-out transition from wherever it is, so it catches up and settles a moment after the pointer stops, and align sets which side of the pointer it settles on.
Use Cursor for the dot or arrow that marks the hotspot and CursorFollow for a name tag, a ring or a glow. The Label demo pairs an arrow with a tag.
How do I change the Animated Cursor over buttons and links in Svelte?
Style the data-interactive state. The area sets it while the pointer is over a link with an href, an enabled button or form field, a label, a summary, or an element whose role is a control, such as button, checkbox, tab or menuitem. A class under the group-data-interactive/animated-cursor: variant, on either part, applies only then.
With no class of yours, Cursor grows to one and a half times its size. To make another element count, such as a card that opens on click, give it data-cursor="interactive". The Interactive demo shrinks the dot and fills the ring this way.
How do I change the size or color of the Animated Cursor dot?
Add the classes to Cursor, such as size-2 and bg-foreground. With no children, it draws a 16 pixel dot through size-4, rounded-full and bg-primary, and your classes are merged after those, so a size or a color of yours replaces the default one. The Interactive demo turns the dot small and dark this way.
To draw something other than a dot, give Cursor a child, an icon or a styled span, and the dot's classes are left off, as in the Label demo.
How do I make the CursorFollow trail looser or tighter?
Set --cursor-follow-duration on CursorFollow, through a class such as [--cursor-follow-duration:900ms] for a slow drift or a shorter time for a tight one. Left unset, it is 400ms. The Trail demo uses 900ms and the Interactive demo 250ms.
sideOffset sets the gap between the pointer and the follower's nearest edge, 16 pixels by default, and align picks the side. Cursor has no trail to tune, since it moves with the pointer.
Can I put a form or text fields inside an Animated Cursor area?
Clicks and typing work as usual, because the parts ignore the pointer. While the area is active, though, it hides the system cursor on every element inside it, the text cursor over a field included, so people lose the cue that a field takes text.
Fields count as interactive, so Cursor grows over them, but that is the same cue a button gets. Keep forms, tables and long reading outside the area.
Is a custom cursor accessible?
On one decorative section, it costs little. The parts are hidden from assistive technology and never take a click, keyboard focus is untouched, and the system cursor comes back for people who prefer reduced motion or use forced colors.
What the component can't detect is a system cursor someone has enlarged or recolored in their settings. Inside the area it is hidden like any other, which is the main reason to keep the effect to a hero or a portfolio panel rather than a whole app.
Does Animated Cursor re-render on every pointer move?
No. A move writes two CSS variables, --animated-cursor-x and --animated-cursor-y, straight onto the area's element, and both parts read them in their translate.
State changes only when the pointer enters or leaves the area, or moves onto or off an interactive element, so the content inside stays still while the cursor moves. The motion itself is CSS: Cursor jumps to each new position, and CursorFollow gets there through a transition.
API Reference
AnimatedCursor
<div> data-slot="animated-cursor"
class?string
Merged with the part's classes.
data-active?string
Present after onPointerEnter.
data-interactive?string
Present after onPointerLeave.
Cursor
<div> data-slot="cursor-layer"
class?string
Merged with the part's classes.
CursorFollow
<div> data-slot="cursor-layer"
align?CursorAlign
Where it sits around the pointer. start and end follow the
reading direction.
- Default
"bottom-end"
sideOffset?number
The gap between the pointer and the follower's nearest edge, in pixels.
- Default
16
class?string
Merged with the part's classes.
data-align?string
Mirrors align.
--cursor-follow-sxstring--cursor-follow-systring












