Skip to contentKino
Skip to Content

Inline edit

Text that becomes a field in place to rename something, such as a title or a table cell, without moving. Quiet saves at once with a mark after the text; Actions keeps Save and Cancel in the field until the save is done.

npx shadcn add https://kinoui.com/r/inline-edit.json
Share on

Examples

Projects

AOAmara OkaforDue Dec 1224 issues · 9 done

Default

Give it a label and save in onValueChange. The text stays where it is as the field opens, and a promise shows a spinner after the text, then a tick.

NameSizeUpdated
2.4 MBNov 14
18.1 MBNov 12
1.2 GBNov 3
86 KBOct 28

Table cells

Pass value to own it, and validate to refuse a name: here, one another file already has.

Workspace

How your workspace shows to the people in it.
Name

Actions

The actions variant shows a pencil at rest and Save and Cancel in the field, which stays open until the save is done.

Controlled

Own editing to open the field from elsewhere, such as a Rename item in a menu.

Created just now by you

Placeholder

An empty value shows the placeholder, muted, in its place, and the field opens empty.

Installation

npx shadcn@latest add https://kinoui.com/r/inline-edit.json
Files
components/kino/label.tsxlib/reduce-motion.tslib/resize.tslib/settle.tscomponents/kino/field.tsxlib/refs.tscomponents/kino/input.tsxcomponents/kino/textarea.tsxlib/swap.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxcomponents/kino/input-group.tsxlib/announce.tsxlib/controllable.tslib/notice.tsxcomponents/kino/inline-edit.tsx
Packages
@base-ui/reactclass-variance-authority

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

Props

PropTypeDefaultDescription
variant'quiet''actions''quiet'quiet saves at once and shows how it went after the text. actions shows a pencil at rest and Save and Cancel in the field, which stays open until the save is done.
labelstringNoneWhat the value is, such as “Project name”: the field’s name, and part of the text’s description.
valuestringNoneThe saved value, when you own it. Leave it out to keep it here.
defaultValuestring''The value at first, when it is kept here.
onValueChange(value: string) => unknownNoneSaves a new value, trimmed. Return a promise to show the save running until it settles; a rejection or a throw shows failedLabel and keeps the old value. Set value only once it has saved.
validate(value: string) => string | null | undefinedNoneThe message for a value that can’t be saved, shown under the field as Enter or Save is pressed. A press elsewhere puts such a value back.
editingbooleanNoneWhether the field shows, when you own it, such as for a Rename item.
defaultEditingbooleanfalseWhether the field shows at first, when it is kept here.
onEditingChange(editing: boolean) => voidNoneCalled as the field opens and closes.
placeholderstringNoneShown, muted, in place of an empty value, and in the empty field.
editLabelstring`Edit ${label}`What pressing the text does, read after the text itself.
disabledbooleanfalseThe text can’t be pressed, and shows faded.
saveLabelstring'Save'The name of Actions’ Save button.
cancelLabelstring'Cancel'The name of Actions’ Cancel button.
savedLabelstring'Saved'What a screen reader hears once a save that took a moment has worked.
failedLabelstring'Couldn’t save. Edit it to try again.'What shows under the field when a save fails. Actions’ default is “Couldn’t save. Try again.”
classNamestringNoneFor layout: the field and its box take their parent’s width. A negative inline margin of --control-padding lines the text up with what is above and below it.

Data attributes

AttributeOnDescription
data-variantInlineEditquiet or actions.
data-editingThe box, [data-slot=inline-edit-box]Present while the field shows.
data-invalidInlineEditPresent while an error shows: a value validate refused, or a failed save.

CSS variables

VariableSet it onDefaultDescription
--swap-rollInlineEdit, or <body>0.75emHow far Quiet’s mark rolls as the spinner turns into the tick or the error.
--field-message-rollInlineEdit, or <body>0.5remHow far the error rolls in under the field.

Accessibility

  • At rest the text is a button named by the text itself, so a heading it sits in keeps its own name; its description says what pressing it does, and why a save failed.
  • A press, Enter, Space or F2 opens the field with focus in it and the whole text picked; Enter and Escape put focus back on the text, and a press elsewhere leaves it where it went.
  • Escape puts the text back from the field or from Save and Cancel, and stops there, so a dialog the edit sits in stays open.
  • A held Enter never opens and closes the field over and over, and Enter that picks a word in an input method editor never saves.
  • An invalid value marks the field invalid, links its message, and shows a mark and words, not a colour alone; the message is read out as it appears.
  • A polite status region says when a save that took a moment has worked; a failure is read out with its message.
  • Save and Cancel are named buttons, gone from the tab order and from screen readers at rest.