Pluck String

Interactive SVG Divider for React

A divider that catches on the pointer as it crosses, bends with it, then slips free and twangs back on a bouncy spring.

  • Divider
  • Interaction
  • SVG

Uses clsx, tailwind-merge

Open in ChatGPTOpen in Claude
pull24px
stiffness900
damping9
strokeWidth1.0px
fadefalse
<PluckString />

The demo follows as you drag.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Pluck String: A divider that catches on the pointer as it crosses, bends with it, then slips free and twangs back on a bouncy spring.

1. Install it:
   npx shadcn@latest add @keyframeui/pluck-string-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/pluck-string-demo.json instead.)
   It adds the demo, components/pluck-string-demo.tsx, and the component, components/ui/pluck-string.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <PluckString> on its own.

3. These props set its feel. Change them before you change the file:
   - pull (default 24): How far the string stretches with the pointer before it slips free, in pixels. It gives less toward the pinned ends.
   - stiffness (default 900): Spring stiffness of the twang. Higher is a faster, higher-pitched wobble.
   - damping (default 9): Spring damping of the twang. Lower values ring for longer.
   - strokeWidth (default 1): Stroke width of the string, in pixels.
   - fade (default false): Fade the string out toward both ends.

4. Don't change, in components/ui/pluck-string.tsx:
   - One rAF loop writes the paths' `d` and the highlight's opacity straight to the DOM, and stops once the string settles; neither the pointer nor the swing re-renders anything.
   - The string catches only when the pointer crosses the line, and slips free past the limit (smaller toward the pinned ends) or on leaving, flung at the pointer's speed but capped so the swing never passes the limit.
   - The springs integrate in fixed substeps (semi-implicit Euler); the stiff `hold` spring diverges at frame-sized steps.
   - Reduced motion keeps the line straight; only the highlight responds.
   - The SVG is a 1px-tall viewBox stretched with `preserveAspectRatio="none"` and a `non-scaling-stroke`, and the fade gradient is `userSpaceOnUse`, since a bounding-box gradient disappears on a flat line.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/pluck-string.md

Installation

Add the component on its own with the CLI, or copy the file in by hand.

The CLI writes components/ui/pluck-string.tsx and installs clsx and tailwind-merge. It needs the @keyframeui registry in components.json; add it once per project.

npx shadcn@latest add @keyframeui/pluck-string

Examples

Finished sections built with Pluck String. Each one installs whole, with the component included.

Strum

Six strings tuned like a guitar: thicker strings are softer and ring longer. Sweep down across all of them.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Pluck String: A divider that catches on the pointer as it crosses, bends with it, then slips free and twangs back on a bouncy spring.
This demo, Strum: Six strings tuned like a guitar: thicker strings are softer and ring longer. Sweep down across all of them.

1. Install it:
   npx shadcn@latest add @keyframeui/pluck-string-strum-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/pluck-string-strum-demo.json instead.)
   It adds the demo, components/pluck-string-strum-demo.tsx, and the component, components/ui/pluck-string.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <PluckString> on its own.

3. These props set its feel. Change them before you change the file:
   - pull (default 24): How far the string stretches with the pointer before it slips free, in pixels. It gives less toward the pinned ends.
   - stiffness (default 900): Spring stiffness of the twang. Higher is a faster, higher-pitched wobble.
   - damping (default 9): Spring damping of the twang. Lower values ring for longer.
   - strokeWidth (default 1): Stroke width of the string, in pixels.
   - fade (default false): Fade the string out toward both ends.

4. Don't change, in components/ui/pluck-string.tsx:
   - One rAF loop writes the paths' `d` and the highlight's opacity straight to the DOM, and stops once the string settles; neither the pointer nor the swing re-renders anything.
   - The string catches only when the pointer crosses the line, and slips free past the limit (smaller toward the pinned ends) or on leaving, flung at the pointer's speed but capped so the swing never passes the limit.
   - The springs integrate in fixed substeps (semi-implicit Euler); the stiff `hold` spring diverges at frame-sized steps.
   - Reduced motion keeps the line straight; only the highlight responds.
   - The SVG is a 1px-tall viewBox stretched with `preserveAspectRatio="none"` and a `non-scaling-stroke`, and the fade gradient is `userSpaceOnUse`, since a bounding-box gradient disappears on a flat line.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/pluck-string.md

Changelog

Faded strings between release notes, with a softer highlight.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Pluck String: A divider that catches on the pointer as it crosses, bends with it, then slips free and twangs back on a bouncy spring.
This demo, Changelog: Faded strings between release notes, with a softer highlight.

1. Install it:
   npx shadcn@latest add @keyframeui/pluck-string-changelog-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/pluck-string-changelog-demo.json instead.)
   It adds the demo, components/pluck-string-changelog-demo.tsx, and the component, components/ui/pluck-string.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <PluckString> on its own.

3. These props set its feel. Change them before you change the file:
   - pull (default 24): How far the string stretches with the pointer before it slips free, in pixels. It gives less toward the pinned ends.
   - stiffness (default 900): Spring stiffness of the twang. Higher is a faster, higher-pitched wobble.
   - damping (default 9): Spring damping of the twang. Lower values ring for longer.
   - strokeWidth (default 1): Stroke width of the string, in pixels.
   - fade (default false): Fade the string out toward both ends.

4. Don't change, in components/ui/pluck-string.tsx:
   - One rAF loop writes the paths' `d` and the highlight's opacity straight to the DOM, and stops once the string settles; neither the pointer nor the swing re-renders anything.
   - The string catches only when the pointer crosses the line, and slips free past the limit (smaller toward the pinned ends) or on leaving, flung at the pointer's speed but capped so the swing never passes the limit.
   - The springs integrate in fixed substeps (semi-implicit Euler); the stiff `hold` spring diverges at frame-sized steps.
   - Reduced motion keeps the line straight; only the highlight responds.
   - The SVG is a 1px-tall viewBox stretched with `preserveAspectRatio="none"` and a `non-scaling-stroke`, and the fade gradient is `userSpaceOnUse`, since a bounding-box gradient disappears on a flat line.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/pluck-string.md

Props

pull

TypenumberDefault24

How far the string stretches with the pointer before it slips free, in pixels. It gives less toward the pinned ends.

stiffness

TypenumberDefault900

Spring stiffness of the twang. Higher is a faster, higher-pitched wobble.

damping

TypenumberDefault9

Spring damping of the twang. Lower values ring for longer.

strokeWidth

TypenumberDefault1

Stroke width of the string, in pixels.

fade

TypebooleanDefaultfalse

Fade the string out toward both ends.

highlightClassName

Typestring

Classes for the highlight that lights up the string as it swings. Set its color with text-* (defaults to text-foreground).

className

Typestring

Extra classes for the root. Its height (default h-14) is the grab zone and the spacing around the line; set the string color with text-* (defaults to text-border).