Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Inline Edit

Text that turns into a pre-filled field when clicked, for renaming titles and labels in place.

ComponentsInline Edit
inputinteractive
<arc-inline-edit>

Overview

Inline Edit shows its value as plain text, with no field chrome and only a faint pencil on hover or focus. Clicking it, or pressing Enter, Space or F2 while it's focused, swaps in a field with the current value selected, ready to type over. Enter or clicking away commits, and Escape throws the edit away. The display text inherits the surrounding typography and the field matches it, so the text doesn't change size or move when it swaps. In a heading it edits at heading size, and in a table cell at cell size. Use it for renames and titles, where a visible input box would make the page look like a form. While someone types, the draft streams out as `arc-input` events. `value`, and the value a surrounding form submits, change only on commit, which fires one `arc-change`. Committing an unchanged value fires nothing. Cancelling fires `arc-cancel` and restores the previous text. From script, `edit()` enters edit mode with the field focused and its text selected, for a "Rename" menu item or a freshly added row. `commit()` and `cancel()` leave edit mode the two ways the keyboard does and fire the same events. Call `commit()` when something outside the component ends the edit (a toolbar Save, a route change), and `cancel()` when a save fails and the old text should come back. `edit()` does nothing when the component is disabled, readonly or already editing, so you can call it without checking first.

Guidelines

Do

  • Always set `label`. It names both the display button ("Edit Track title") and the field
  • Listen for `arc-change` to save a rename
  • Use `multiline` for short notes that may wrap, and tell people that Cmd/Ctrl+Enter saves
  • Set a `placeholder` that fits the content, such as "Untitled track", so an empty value still looks clickable
  • Use `readonly` when a value is temporarily locked. The text stays in the reading order but can't be edited

Don't

  • Don't use it in a conventional form layout. A labeled Input tells people there's something to fill in, and Inline Edit hides that
  • Don't use it for values that need heavy validation or structured entry, such as emails, dates and numbers. Use Input, Date Picker or Number Input
  • Don't treat `arc-input` as a save signal. It carries the draft, which Escape can still throw away
  • Don't rely on the pencil to show that text is editable on touch screens. It appears on hover and focus, and touch has no hover

Features

  • Takes part in forms through ElementInternals, like Input: the committed value submits under `name`, and `form.reset()` restores the initial text
  • `required` makes an empty committed value invalid, shown as a faint error tint even in display state
  • `multiline` edits in a textarea, where Enter inserts a newline and Cmd/Ctrl+Enter commits

Preview

1 3:42
2 4:17
3 2:58

Usage

This component needs JavaScript. Use the Web Component or a framework wrapper.

<!-- A renameable track list: text until clicked, field until committed -->
<div style="display:flex; flex-direction:column; max-width:440px; gap:2px;">
  <arc-inline-edit value="Midnight Signal" label="Track 1 title" placeholder="Untitled track"></arc-inline-edit>
  <arc-inline-edit value="Glass Harbor" label="Track 2 title" placeholder="Untitled track"></arc-inline-edit>
  <arc-inline-edit label="Track 3 title" placeholder="Untitled track"></arc-inline-edit>
</div>

<script>
  document.querySelectorAll('arc-inline-edit').forEach((el) => {
    el.addEventListener('arc-change', (e) => {
      console.log('renamed to', e.detail.value);
    });
  });
</script>

<!-- Multiline notes: Enter newlines, Cmd/Ctrl+Enter commits -->
<arc-inline-edit multiline label="Session notes" placeholder="Add a note"></arc-inline-edit>

API

valuestring''
The committed text. Updated only when an edit commits (Enter or blur); keystrokes accumulate in an internal draft until then.
labelstring''
Accessible name for the control. The display state announces as "Edit {label}" and the edit field is labeled with it. Always provide one.
namestring''
The name attribute sent with form data on submission. The submitted value is the committed value, never an in-progress draft.
placeholderstring'Empty'
Text shown in muted italic when value is empty, and as the field placeholder while editing. Defaults to "Empty".
disabledbooleanfalse
Prevents activation and applies a muted treatment. The value is excluded from form submission while disabled.
multilinebooleanfalse
When true, editing uses a <textarea>: Enter inserts a newline and Cmd/Ctrl+Enter commits. Single-line commits on plain Enter.
requiredbooleanfalse
Marks the field as required. An empty committed value is invalid, including in display state, which shows a subtle error tint.
readonlybooleanfalse
Renders the display state only: the text remains focusable for reading order, but activation is inert and no pencil affordance appears.
formAssociatedbooleantrue
propertiesobject{ // flag(), unlike `disabled`. The exclusion in props.js is specifically // about form-associated *platform* semantics: a `disabled` content // attribute that is merely present makes the element actually disabled // per the HTML spec, and formDisabledCallback assigns the property back, // so no converter can win. Neither of these is platform-mapped: // `required` is enforced by _computeValidity() below and `readonly` by // each component's own interaction handlers, so the stock converter buys // nothing here and costs the usual bug: `required="false"` read as true, // blocking submission of a form the author meant to leave optional. // Finding #48's shape, across all 26 form controls at once. required: flag(false), readonly: flag(false), }
Lit merges static properties up the prototype chain, so every consumer gets these without declaring them. required participates in constraint validation below; readonly reflects for styling and is enforced by each component's interaction handlers (the mixin can't know which gestures mutate state).
autoValidatesbooleantrue
Components that run their own constraint-validation logic (pattern checks, range checks) opt out of the automatic required sync by overriding this to false, and own the whole validity flag set instead.
form
validity
validationMessage

Methods

focus(options?)options?: FocusOptions
Move focus to whichever element is currently the control: the field while editing, the display row otherwise. The host sets no delegatesFocus and everything focusable lives in the shadow root, so el.focus() used to do nothing at all, silently, which cost a consumer a "Rename" menu item that appeared dead. edit() is the way *into* editing and stays that way; this is only the obvious call landing where a caller expects it.
edit()
Enter edit mode: focus the field and select its text. No-op when disabled, readonly, or already editing.
commit()
Commit the current draft and leave edit mode. Fires arc-change only if the value changed.
cancel()
Discard the draft, keep the previous value, and leave edit mode. Fires arc-cancel.
checkValidity()boolean
Whether the control currently satisfies its constraints, per the native constraint-validation API. Fires invalid on the element when it does not, and reports nothing to the user.
reportValidity()boolean
As checkValidity(), but also shows the browser's validation message against the control when it fails.

Events

arc-changedetail:{ value: string }
Fired once on commit when the value actually changed, with the new value in detail.value.
arc-canceldetail:{ value: string }
Fired when an edit is canceled (Escape or cancel()), with the retained value in detail.value. No arc-change accompanies it.
arc-inputdetail:{ value: string }
Fired on each keystroke while editing, with the draft text in detail.value.

See also