Skip to content
Textlab
1
Browse

ComponentsDraw

Strike-through

Cross out a word and write the new one.

This meeting could have been an 👍 (replaces email)

Installation

$ npx shadcn@latest add @textlab/strike-through

Needs @textlab in your components.json. Setup takes a minute.

Usage

usage.tsx
import { StrikeThrough } from "@/components/textlab/strike-through/strike-through";

<p>Meetings that could have been an <StrikeThrough text="email" variant="replace" replacement="👍" /></p>

Variants

replacelinescribble

Props

PropTypeDefaultDescription
text*string–The copy.
variant"replace" | "line" | "scribble""line"Cross out and write a correction, a single line, or a scratch-out.
replacementstring–The correction written above, for replace.
colorstringvar(--tl-accent)Pen color.
thicknessnumber3Stroke width in px.
asElementType"span"Rendered element.
trigger"mount" | "inView" | "hover" | "manual""inView"What starts the animation. manual follows `active`.
activebooleanfalseDrives trigger="manual".
oncebooleantrueIn view: play once instead of on every entry.
delaynumber0Seconds before the first part moves.
durationnumber0.5Seconds each part takes.
reducedMotion"user" | "always" | "never""user"user follows the OS setting; always shows the still version.
classNamestring–Merged onto the root.

When to use it

Reach for it

  • Witty headlines that correct themselves.
  • Pricing before and after, changelog wording.

Skip it

  • Legal or factual corrections; use <del> and <ins> styled plainly.
  • More than one per line.

Accessibility and motion

Accessibility

  • Screen readers hear the meaning: the replacement and what it replaces, or that the word is struck out.
  • The pen line and correction are decorative.

Motion

  • The old word dims just after the pen passes, the correction arrives last.
Reduced motion. Shown already struck, with the correction in place.

Performance

  • One path and one small text element.