Inline edit
A saved text value becomes an editor in place with explicit Save and Cancel actions.
npx @swipeui/cli add inline-editWhen to use it
- Renaming things in place, such as a playlist, a project or a profile name.
- Settings rows where a value can be edited without leaving the screen.
- Quick fixes to a saved value with clear Save and Cancel buttons.
When not to use it
- Forms with many fields. Use Text fields with one Save button.
- Editing that needs validation across fields.
- Values that should save on every keystroke.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add inline-edit- Adds
components/swipeui/ui/inline-edit.tsxand 16 shared helpers. - Installs react-native-reanimated, clsx, tailwind-merge, react-native-worklets, uniwind, expo-haptics, class-variance-authority, react-native-svg. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { InlineEdit } from '@/components/swipeui/ui/inline-edit';
<InlineEdit label="Project name" defaultValue="New project" onValueChange={rename} />;Examples
Use the variant and appearance controls in the live specimen to compare the documented states. The application owns validation, operation results and persistence.
API reference
InlineEditProps
| Prop | Type | Default | Description |
|---|---|---|---|
label? | | — | Visible label, or inherit an enclosing Field. |
helper? | | — | Instructions under the field; an error or success message replaces it. |
error? | | — | Validation message: a destructive ring, an alert glyph, one shake and an error haptic. |
success? | | — | Confirmation under the field, such as "Username available", in the success colour. |
status? | | |
|
required? | | | Required; "Required" is spoken, and |
requiredIndicator? | | | How a required label is marked: a muted asterisk, the word, or nothing. |
optionalIndicator? | | | Show a muted "Optional" after the label. |
disabled? | | | Disable editing and accessory actions. |
disabledStyle? | | |
|
appearance? | | | The surface: |
size? | | | Height: |
shape? | | |
|
labelPlacement? | | |
|
focusRing? | | | The focus indicator: a primary ring with a soft halo, the ring alone, or none. |
messageMorph? | | | How a changed message arrives: rises in, letter by letter, or at once. |
reserveMessageSpace? | | | Keep one line of room under the field so forms don't move as messages appear. |
displayValue? | | — | Decorative rendering for an unfocused value; the native text remains the accessible/editable source. |
prefix? | | — | Decorative prefix or an accessible accessory, drawn first. |
suffix? | | — | Accessible trailing accessory, drawn last. |
leadingIcon? | | — | A leading icon: a node, or a function given the state colour and size. It turns primary while focused. |
trailingIcon? | | — | A trailing icon: a node, or a function given the state colour and size. |
clearable? | | | 1.x switch: |
clearButton? | | | When a "Clear text" button shows. |
undoClear? | | | After clearing, the button becomes "Undo clear" for a moment. Phones have no ⌘Z. |
undoClearWindow? | | | How long undo stays, in milliseconds. |
counter? | | | A rolling character counter under the field, using |
tintCaret? | | | Caret and selection in the primary colour. |
iconTint? | | | The leading icon turns primary while focused ( |
shakeOnError? | | | Shake once for each new error. Reduce Motion keeps it still. |
messages? | | | Built-in strings, for translation. Built-in strings. |
nextRef? | | — | Ref focused when Return is pressed; otherwise a single-line field dismisses. |
haptics? | | | All feedback, or each part: |
motion? | | | Ring, label and message motion. |
className? | | — | Classes on the outer field. |
controlClassName? | | — | Classes on the field surface. |
inputClassName? | | — | Classes on the editable text. |
style? | | — | Outer field style. |
inputStyle? | | — | Native editable text style. |
value? | | — | Controlled saved text. |
defaultValue? | | | Initial saved text. |
onValueChange? | | — | Reports only a saved edit; Cancel leaves the saved value alone. |
onSave? | | — | Saves the edit. May return a promise: the check spins until it settles, and a rejection keeps you editing with an error. |
onSaveComplete? | | — | Called after a save succeeds, even when the value is unchanged. |
onCancelEdit? | | — | Called after the user discards the current draft. |
minSavingTime? | | | The least time the check spins, so a fast save still reads as saving (content timing). |
emptyLabel? | | | Read-state label when empty. |
Native view/input props not listed here pass through where the exported TypeScript type allows them.
Inline edit settings
| Prop | Does | Default |
|---|---|---|
| onSave | Saves the edit; a promise spins the check, a rejection keeps editing | none |
| minSavingTime | Least time the check spins (ms) | 450 |
| emptyLabel | Read text when there's no value | Add a value |
| messages | Save, Cancel, the edit name and the failure | English |
Composition and behavior
- A read-only value that becomes a Text field with Save and Cancel.
- value and onValueChange hold the saved text; drafts stay local.
- emptyLabel sets the prompt when empty.
Behavior and gestures
- Tap the value to switch to an editor with the keyboard up.
- Save keeps your change; Cancel throws it away and restores the saved text.
- Nothing is reported until Save, so half-finished edits never leak out.
- An empty value shows "Add a value" as a prompt.
Accessibility
- The read state is a button like "Edit Name: Ana", so people know what they'll change.
- Save and Cancel are separate named buttons.
- Focus moves into the editor when it opens.
Motion
- Uses the
pressmotion role, so it follows your app's feel. Passmotionto tune this one instance. - The tick and cross use the press motion role. The host can react to save and cancel with completion callbacks.
Performance
- The editor mounts only while editing.
Notes for AI
- Handle persistence in onValueChange; it only fires on Save.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.