Open this example in the interactive library
Live preview
Source code
// components/ExpandableTextEditor.tsx
import { useState } from "react";
export default function ExpandableTextEditor({
label = "Project notes",
}: { label?: string } = {}) {
const [large, set] = useState(false);
return (
<div>
<label>
{label}
<textarea rows={large ? 12 : 3} />
</label>
<button aria-pressed={large} onClick={() => set(!large)}>
Large editor
</button>
</div>
);
}
