Trace

Border or icon path that draws itself.

Stroke paths draw on in a quiet sweep. Use it on an SVG mark, or wrap a surface so the outline traces itself.

Icon

Color
1200ms
2
tsx
"use client"import { useState } from "react"import { Trace } from "@/components/motion/trace"import { Button } from "@/components/ui/button"export function Example() {  const [play, setPlay] = useState(0)  return (    <div className="flex flex-col items-center gap-6">      <Trace        play={play}        duration={1200}        strokeWidth={2}        color="#71717a"      >        <svg viewBox="0 0 64 64" className="size-20" fill="none">          <path d="M12 44V20c0-2.2 1.8-4 4-4h16c6.6 0 12 5.4 12 12s-5.4 12-12 12H20" />          <path d="M20 28h12" />          <circle cx="44" cy="44" r="6" />        </svg>      </Trace>      <Button variant="outline" onClick={() => setPlay((n) => n + 1)}>        Trace      </Button>    </div>  )}

Border

Token ready

The outline draws itself around the surface.

Color
1200ms
1.5
12px
tsx
"use client"import { useState } from "react"import { TraceBorder } from "@/components/motion/trace"import { Button } from "@/components/ui/button"export function Example() {  const [play, setPlay] = useState(0)  return (    <div className="flex flex-col items-center gap-6">      <TraceBorder        play={play}        duration={1200}        strokeWidth={1.5}        color="#71717a"        radius={12}        className="w-full max-w-sm"      >        <div className="px-5 py-5">          <h3 className="text-sm font-medium tracking-wide">Token ready</h3>          <p className="mt-1 text-xs tracking-wide text-muted-foreground">            The outline draws itself around the surface.          </p>        </div>      </TraceBorder>      <Button variant="outline" onClick={() => setPlay((n) => n + 1)}>        Trace      </Button>    </div>  )}

Installation

npx @arctis-sh/@arctis-sh/ui@latest add trace

Usage

import { useState } from "react"import { Trace, TraceBorder } from "@/components/motion/trace"import { Button } from "@/components/ui/button"
const [play, setPlay] = useState(0)<>  <Trace play={play} duration={1200}>    <svg viewBox="0 0 64 64" className="size-20" fill="none">      <path d="M12 44V20c0-2.2 1.8-4 4-4h16c6.6 0 12 5.4 12 12s-5.4 12-12 12H20" />      <path d="M20 28h12" />      <circle cx="44" cy="44" r="6" />    </svg>  </Trace>  <Button onClick={() => setPlay((n) => n + 1)}>Trace</Button></>
<TraceBorder play={play} radius={12} className="w-full max-w-sm">  <div className="px-5 py-5">Token ready</div></TraceBorder>

API Reference

Trace

PropTypeDefault
durationnumber1200
delaynumber0
playnumber0
strokeWidthnumber2
colorstringcurrentColor
classNamestring—
childrenReactNode—

Wrap an SVG. Trace animates path, circle, ellipse, line, polyline, polygon, and rect nodes. Duration and delay are in milliseconds.

TraceBorder

PropTypeDefault
durationnumber1200
delaynumber0
playnumber0
strokeWidthnumber1.5
colorstringcurrentColor
radiusnumber12
classNamestring—
childrenReactNode—

Draws a rounded outline around the wrapped surface. Bump play to replay.