Text & Effects
Elastic Divider
A divider line that bends toward the cursor like a string and wobbles back.
Profile
Move your cursor across the line below.
Notifications
It bends toward you and wobbles back when you let go.
Installation
npx shadcn@latest add https://relic-ui.vercel.app/r/elastic-divider.jsonOr straight from GitHub: npx shadcn@latest add relicui/relic-ui/elastic-divider
Manual installation
1. Install the dependencies:
npm install motion2. Copy this code into components/ui/elastic-divider.tsx:
"use client"
/**
* Relic UI · Elastic Divider
* https://relic-ui.vercel.app/docs/elastic-divider
*
* Copyright (c) 2026 Shubham Tambe
* Open source under the MIT License: https://relic-ui.vercel.app/license
*/
import { useRef } from "react"
import {
animate,
motion,
useMotionValue,
useReducedMotion,
useTransform,
} from "motion/react"
import { cn } from "@/lib/utils"
// The line is drawn in a fixed coordinate space and stretched to fit:
// LONG units along the line, SHORT units across it.
const LONG = 1000
const SHORT = 100
const MIDDLE = SHORT / 2
export interface ElasticDividerProps
extends Omit<React.ComponentProps<"div">, "ref"> {
/** Lie flat between stacked content, or stand up between side-by-side content. */
orientation?: "horizontal" | "vertical"
/** Maximum distance in pixels the line can be pulled. */
bend?: number
/** Line thickness in pixels. */
strokeWidth?: number
/** How tight the string is. Higher snaps back faster. */
stiffness?: number
/** How much the line wobbles on release. Lower is wobblier. */
damping?: number
/** Size of the area (in pixels) that reacts to the cursor, across the line. */
hitArea?: number
}
export function ElasticDivider({
orientation = "horizontal",
bend = 24,
strokeWidth = 1,
stiffness = 350,
damping = 7,
hitArea = 48,
className,
style,
onPointerMove,
onPointerLeave,
...props
}: ElasticDividerProps) {
const ref = useRef<HTMLDivElement>(null)
const reduceMotion = useReducedMotion()
const vertical = orientation === "vertical"
const pullAlong = useMotionValue(LONG / 2)
const pullAcross = useMotionValue(0)
// A quadratic curve passes halfway to its control point,
// so the control point sits at twice the pull for the line to meet the cursor.
const path = useTransform([pullAlong, pullAcross], ([along, across]: number[]) =>
vertical
? `M ${MIDDLE} 0 Q ${MIDDLE + across * 2} ${along} ${MIDDLE} ${LONG}`
: `M 0 ${MIDDLE} Q ${along} ${MIDDLE + across * 2} ${LONG} ${MIDDLE}`
)
const string = { type: "spring", stiffness, damping, mass: 0.6 } as const
function handlePointerMove(e: React.PointerEvent<HTMLDivElement>) {
onPointerMove?.(e)
const el = ref.current
if (reduceMotion || !el) return
const rect = el.getBoundingClientRect()
// Measure along the line and across it, whichever way it stands.
const length = vertical ? rect.height : rect.width
const thickness = vertical ? rect.width : rect.height
const along = vertical ? e.clientY - rect.top : e.clientX - rect.left
const across = vertical
? e.clientX - (rect.left + rect.width / 2)
: e.clientY - (rect.top + rect.height / 2)
const clamped = Math.max(-bend, Math.min(bend, across))
animate(pullAlong, (along / length) * LONG, {
type: "spring",
stiffness: 500,
damping: 40,
})
animate(pullAcross, (clamped / thickness) * SHORT, string)
}
function handlePointerLeave(e: React.PointerEvent<HTMLDivElement>) {
onPointerLeave?.(e)
// Let go: the spring snaps the line back with a wobble.
animate(pullAcross, 0, string)
}
return (
<div
ref={ref}
role="separator"
aria-orientation={orientation}
data-slot="elastic-divider"
className={cn(
"relative shrink-0 text-border",
vertical ? "h-full self-stretch touch-pan-x" : "w-full touch-pan-y",
className
)}
style={{ ...(vertical ? { width: hitArea } : { height: hitArea }), ...style }}
onPointerMove={handlePointerMove}
onPointerLeave={handlePointerLeave}
{...props}
>
<svg
aria-hidden
className="pointer-events-none absolute inset-0 size-full overflow-visible"
viewBox={vertical ? `0 0 ${SHORT} ${LONG}` : `0 0 ${LONG} ${SHORT}`}
preserveAspectRatio="none"
>
<motion.path
d={path}
fill="none"
stroke="currentColor"
strokeWidth={strokeWidth}
strokeLinecap="round"
vectorEffect="non-scaling-stroke"
/>
</svg>
</div>
)
}Usage
import { ElasticDivider } from "@/components/ui/elastic-divider"
export default function ElasticDividerDemo() {
return (
<div className="w-full max-w-md">
<div>
<p className="text-sm font-medium">Profile</p>
<p className="text-sm text-muted-foreground">
Move your cursor across the line below.
</p>
</div>
<ElasticDivider />
<div>
<p className="text-sm font-medium">Notifications</p>
<p className="text-sm text-muted-foreground">
It bends toward you and wobbles back when you let go.
</p>
</div>
</div>
)
}Customize
Try the options below, then copy the code.
Move your cursor across the line
<ElasticDivider />Props
| Prop | Type | Default |
|---|---|---|
bendMaximum distance in pixels the line can be pulled. | number | 24 |
stiffnessHow tight the string is. Higher snaps back faster. | number | 350 |
dampingHow much the line wobbles on release. Lower is wobblier. | number | 7 |
strokeWidthLine thickness in pixels. | number | 1 |
orientationLie flat between stacked content, or stand up between side-by-side content. | "horizontal" | "vertical" | "horizontal" |
hitAreaSize of the area, in pixels, that reacts to the cursor across the line. | number | 48 |
classNameThe line uses the text color, so set it with a class like "text-blue-500". | string | — |
...propsAll native div props. | React.ComponentProps<"div"> | — |
Accessibility
- Exposed to screen readers as a horizontal separator (role="separator").
- The line uses your theme's border color, so it matches light and dark mode.
- Page scrolling on touch devices isn't blocked.
- Animation turns off automatically for users who enable reduced motion in their system settings.