Inline Editing
How inline text editing works in InlineCMS.
Inline editing is the core feature of InlineCMS. Any HTML element can become editable by adding the inline-cms attribute.
Basic usage
Section titled “Basic usage”Add the attribute to any element and it gains an edit affordance — the rendered output is unchanged for visitors.
<h1 inline-cms>Welcome to our site</h1><p inline-cms>We build great things.</p>Welcome to our site
We build great things.
The Vite plugin transforms these at build time into InlineCMS wrapper components with stable fingerprint keys. The inline-cms attribute never ships to visitors — it’s compiled away, leaving the exact markup you wrote:
<p inline-cms>
We build great things.
</p><p>
We build great things.
</p>To a visitor the page reads as plain HTML. To a logged-in editor the same element becomes a click-to-edit target — without the content shifting. Edit mode is purely additive: InlineCMS paints decoration around and behind the element, so the layout stays exactly where the visitor sees it (true WYSIWYG):
We build great things.
The inline-cms props
Section titled “The inline-cms props”| Prop | Required | Purpose |
|---|---|---|
inline-cms | Yes | Opts this element into CMS editing |
inline-cms-key | No | Stable key override (auto-generated by Vite plugin) |
inline-cms-label | No | Label shown in the edit UI |
inline-cms-type | No | Override the inferred field type |
inline-cms-group | No | Group related fields in the edit UI |
Field type inference
Section titled “Field type inference”InlineCMS infers the field type from the HTML tag:
You can override the inferred type:
<div inline-cms inline-cms-type="text">Plain text only</div>Editing flow
Section titled “Editing flow”- Editor clicks Editor login in the toolbar
- After authentication, clicks Edit page
- Editable elements show a dashed outline on hover
- Click an element to start editing — it becomes
contentEditable - Type to edit. Changes are tracked locally.
- Click Save draft to persist without publishing
- Click Publish to make changes live
Named components (explicit API)
Section titled “Named components (explicit API)”If you prefer named components over the prop API:
import { InlineH1, InlineP, InlineImg } from '@inlinecms/react'
function Hero() { return ( <section> <InlineH1 inline-cms-key="hero-title">Welcome</InlineH1> <InlineP>We build great things.</InlineP> <InlineImg src="/hero.jpg" /> </section> )}withCMS HOC
Section titled “withCMS HOC”Wrap existing components you don’t want to modify:
import { withCMS } from '@inlinecms/react'import { HeroSection } from './HeroSection'
const CMSHero = withCMS(HeroSection, { componentId: 'hero-section', fields: [ { key: 'title', selector: 'h1', type: 'text' }, { key: 'subtitle', selector: 'p', type: 'text' }, { key: 'image', selector: 'img', type: 'image' }, ],})