@molecule/app-inline-edit-svelte
Feature · inline-edit · App (browser) · v1.1.3 · Apache-2.0
Click-to-edit text + textarea + select with Save/Cancel
npm install @molecule/app-inline-edit-svelteHow it works
@molecule/app-inline-edit-svelte is a ready-made inline-edit feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
<script lang="ts">
import { InlineEdit } from '@molecule/app-inline-edit-svelte'
let title = $state('Acme renewal')
</script>
<InlineEdit
value={title}
onSubmit={async (next) => {
title = next
}}
placeholder="Enter deal title"
/>Works with: @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte
Reference
Svelte click-to-edit inline field.
Exports InlineEdit — the Svelte counterpart of @molecule/app-inline-edit-react
with the same props and the same DOM: the value rendered as text, with a
click (or Tab + Enter) swapping in an <Input> or <Textarea> plus
Save/Cancel buttons. Enter submits (Cmd/Ctrl+Enter for the textarea
variant), Escape cancels.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
<script lang="ts">
import { InlineEdit } from '@molecule/app-inline-edit-svelte'
let title = $state('Acme renewal')
</script>
<InlineEdit
value={title}
onSubmit={async (next) => {
title = next
}}
placeholder="Enter deal title"
/>
Type
feature
Installation
npm install @molecule/app-inline-edit-svelte @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte
API
Interfaces
InlineEditProps
Props accepted by the InlineEdit component.
interface InlineEditProps {
/** Current value. */
value: string
/** Called when the user commits a new value. Return a Promise to block the UI while saving. */
onSubmit: (next: string) => void | Promise<void>
/** Render mode for the editor. */
variant?: 'input' | 'textarea'
/** Renderer for the read state — a snippet receiving the value; defaults to plain text. */
renderRead?: Snippet<[string]>
/**
* Placeholder when value is empty. Also becomes the editor field's
* accessible label while editing; without it the field falls back to the
* translated `inlineEdit.aria.edit` default.
*/
placeholder?: string
/** Extra classes. */
className?: string
}
Constants
InlineEdit
const InlineEdit: LegacyComponentType
Injection Notes
Requirements
Peer dependencies:
@molecule/app-svelte^3.5.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-svelte^1.1.0svelte^5.0.0
Runtime Dependencies
-
@molecule/app-svelte -
@molecule/app-ui -
@molecule/app-ui-svelte -
svelte -
Requires a bonded ClassMap (
getClassMap()throws otherwise) and an@molecule/app-sveltei18n provider above it (useTranslation()throws without it); button labels come from the@molecule/app-locales-inline-editcompanion bond. -
Return a Promise from
onSubmitto disable the buttons while saving. IfonSubmitREJECTS, the editor stays open with the draft intact but the error is not displayed — catch and surface errors inside youronSubmit(toast, form error, etc.). -
The draft re-syncs from
valuewhenever the prop changes, including mid-edit — avoid mutatingvaluewhile the user is typing.
Translations
Translation strings are provided by @molecule/app-locales-inline-edit.