Inline edit
Rename in place: the text becomes a field without moving.
npx shadcn@latest add @silicon-ui/inline-editInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/inline-editManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/inline-edit/inline-edit.tsx
- components/silicon-ui/inline-edit/inline-edit.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
value*The saved value. A new value from outside replaces the text while it is not being edited. | string | — |
onSave*Persists the new value. Return a promise to show the saving state, and reject it to roll back. | (next: string) => void | Promise<unknown> | — |
label*Accessible name, for example “Project name”. | string | — |
validateReturns a message when the draft cannot be saved. | (next: string) => string | null | undefined | — |
placeholderShown when the value is empty. | string | "" |
multilineWraps onto several lines and grows in height. Enter still saves; Shift+Enter adds a line break. | boolean | false |
variant`title` for names and headings, `body` for descriptions. | "title" | "body" | "title" |
asThe element that holds the text, so a title can stay a heading. | "span" | "p" | "h1" | "h2" | "h3" | "span" |
className | string | — |
Dependencies
- npm
- lucide-reactmotion
- Registry
- silicon-motion-tokens