Q3 product roadmap
Click any value to edit. Enter saves, Esc cancels.
Installation
$ pnpm dlx shadcn@latest add @synccn/editable-textFirst time in this project? Connect synccn with one command.
Usage
import { EditableText } from "@/components/ui/editable-text";<EditableText defaultValue="Q3 roadmap" />API reference
Generated from the component's TypeScript types, so it always matches the code.
EditableText
Text that turns into a field when clicked. Enter saves, Escape cancels, and clicking away saves. Empty values are rejected.
- value
stringControlled value.
- defaultValue
stringDefault
""Initial value when uncontrolled.
- onValueChange
(value: string) => voidCalled with the saved value.
- as
React.ElementTypeDefault
"span"Element used to display the text.
- placeholder
stringDefault
"Click to edit"Shown when empty.
- validate
(value: string) => string | undefinedReturn an error message to block saving.
- inputClassName
stringExtra classes for the input.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for Check, Pencil, X
Keyboard
- EnterorF2Start editing
- EnterSave
- EscCancel
Accessibility
- Clicking away also saves. Empty or invalid values are rejected and the old value is kept.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: button
- ARIA attributes: aria-invalid, aria-label
- Keys handled: Enter, Escape
- Shows a visible focus ring for keyboard users