Kinetic UI
Back to Introduction
Interactive

Pluckable String

An SVG line that acts like a physical guitar string. Dragging it builds tension, and releasing it triggers a highly underdamped vibration.

Quick Actions
CLI Installation
npx kinetic-ui-cli@latest add pluckable-string
Pluckable String

Pluckable String Physics

Drag your cursor across the lines below to pluck them like guitar strings.

Installation

npx kinetic-ui-cli@latest add pluckable-string

How It Works

The PluckableString is an incredibly satisfying micro-interaction. It uses framer-motion to track the relative Y coordinate of your mouse as it drags across a container. We map this Y coordinate directly into the control point of an SVG Quadratic Bezier Curve (Q). When the mouse leaves the container, the Y coordinate is snapped back to the center using a spring configuration with extremely low damping, causing the control point to rapidly oscillate and simulate a vibrating string.

Usage Guide

1. Import the Component

Import the component into your React or Next.js page:

import { PluckableString } from "@/components/creative/pluckable-string";

2. Implementation Example

Render the component and customize its behavior by passing props:

import { PluckableString } from "@/components/creative/pluckable-string";

export default function Example() {
  return (
    <div className="w-full flex items-center justify-center p-8">
      <PluckableString
        strokeWidth{10}
        strokeColor="example"
      />
    </div>
  );
}
Performance Notes
  • Uses CSS hardware acceleration via GPU transform-binds.
  • Damped interpolation minimizes paint-redraw flashes.
  • Tree-shakable import: only compiles elements requested.
Accessibility Notes
  • Full keyboard focus-ring navigation support (`Tab`/`Shift+Tab`).
  • ARIA roles mapped correctly for assistive screen readers.
  • Respects `prefers-reduced-motion` system toggles.