Components

Electric Card

A React card with an electric border effect: procedurally generated SVG lightning crackles around the edge on hover or keyboard focus. Built with Tailwind CSS and Motion, with tunable chaos, arc count, speed and color.

  • Procedural SVG lightning
  • Hover & focus-within
  • No re-renders
  • Any CSS color
  • prefers-reduced-motion

Edge functions

Run code close to your users with cold starts under 50ms.

Installation

$ npx shadcn@latest add https://duskui.com/r/electric-card.json

Usage

feature-card.tsx
import { ElectricCard } from "@/components/dusk/neon/electric-card"

export function FeatureCard() {
  return (
    <ElectricCard color="#22d3ee" className="max-w-sm">
      <h3 className="font-semibold">Realtime sync</h3>
      <p className="text-sm text-white/60">Changes land everywhere in milliseconds.</p>
    </ElectricCard>
  )
}

Examples

Always on

Set active to keep the card charged without hover — useful for live or highlighted states. The lightning follows any radius.

Live

1,284

requests per second

Calm to storm

chaos sets how far bolts jump off the border, arcs how many crawl around it and speed how fast they travel.

Calm

One arc, low chaos.

Storm

Three arcs, more chaos.

API Reference

Also accepts any <div> prop. Padding, width and background are regular classes.

PropTypeDefaultDescription
colorstringvar(--color-primary)Any CSS color for the lightning.
chaosnumber4How far bolts jump off the border, in px.
arcsnumber1Number of bright arcs crawling around the border.
intervalnumber110Milliseconds between new lightning shapes (min 60).
speednumber0.25Laps per second the arcs crawl.
activebooleanfalseKeep the effect on instead of only on hover / focus.
radiusnumber12Corner radius in px; the lightning follows it.

Accessibility

  • The lightning SVG is aria-hidden and pointer-events-none; the card's content keeps its own semantics.
  • The effect starts when keyboard focus moves into the card, not only on hover.
  • Bolts change shape but never blink on and off and the overall brightness stays constant, so there is no strobing.
  • With prefers-reduced-motion the card shows a single still frame of lightning instead of the crackle.
  • Paths are written directly to the DOM and the timer only runs while the card is active and on-screen.