Open this example in the interactive library
Live preview
Source code
// components/LiveTextPreview.tsx
import { useState } from "react";
export default function LiveTextPreview({
label = "Project notes",
limit = 120,
}: { label?: string; limit?: number } = {}) {
const [text, set] = useState("");
return (
<section>
<label>
{label}
<textarea
maxLength={limit}
value={text}
onChange={(e) => set(e.target.value)}
/>
</label>
<blockquote>{text || "Your preview appears here."}</blockquote>
</section>
);
}
