Navigation

v2.1.0
Forms

Editable

A value read as text that becomes a field in place.

On this page

An editable is a value read as text that becomes a field in place: a title, a name, a cell. At rest it is plain text in the type of whatever holds it; under the pointer a faint well appears around it with a pencil at its end; pressed, the well becomes a focused field with the value selected. The preview and the field share one grid cell, one font, one padding and one corner, so the text does not move by a pixel when one replaces the other. The editable behavior switches the two and saves.

Editable

<div class="max-w(420) mx-auto">  <span class="block mb-xs text-xs fg-text-muted" id="doc-title-label">Title</span>  <h2 class="heading heading-xl">    <span class="editable">      <button type="button" class="editable-preview" id="doc-title-preview" aria-labelledby="doc-title-label doc-title-preview">        Quarterly report<svg class="icon editable-pencil" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <path d="M2.6556 12.4849L3.2844 10.1793A0.7 0.7 0 0 1 3.4647 9.8686L10.505 2.8283A0.7 0.7 0 0 1 11.495 2.8283L13.1717 4.505A0.7 0.7 0 0 1 13.1717 5.495L6.1314 12.5353A0.7 0.7 0 0 1 5.8207 12.7156L3.5151 13.3444A0.7 0.7 0 0 1 2.6556 12.4849Z" /><path d="M9.6667 3.6667L12.3333 6.3333" />        </svg>      </button>      <input class="editable-field" value="Quarterly report" aria-labelledby="doc-title-label" required maxlength="80" hidden>    </span>  </h2>  <span class="block mt-xs text-sm fg-text-muted">Last edited by Ada, 2 minutes ago</span></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'import PencilIcon from '@master/icons-react/native/16/soft/pencil'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="max-w(420) mx-auto">      <span className="block mb-xs text-xs fg-text-muted" id="doc-title-label">Title</span>      <h2 className="heading heading-xl">        <span className="editable">          <button type="button" className="editable-preview" id="doc-title-preview" aria-labelledby="doc-title-label doc-title-preview">            Quarterly report<PencilIcon className="icon editable-pencil" />          </button>          <input className="editable-field" defaultValue="Quarterly report" aria-labelledby="doc-title-label" required maxLength={80} hidden />        </span>      </h2>      <span className="block mt-xs text-sm fg-text-muted">Last edited by Ada, 2 minutes ago</span>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'  import PencilIcon from '@master/icons-svelte/native/16/soft/pencil'</script><div class="max-w(420) mx-auto" {@attach attach}>  <span class="block mb-xs text-xs fg-text-muted" id="doc-title-label">Title</span>  <h2 class="heading heading-xl">    <span class="editable">      <button type="button" class="editable-preview" id="doc-title-preview" aria-labelledby="doc-title-label doc-title-preview">        Quarterly report<PencilIcon class="icon editable-pencil" />      </button>      <input class="editable-field" value="Quarterly report" aria-labelledby="doc-title-label" required maxlength="80" hidden>    </span>  </h2>  <span class="block mt-xs text-sm fg-text-muted">Last edited by Ada, 2 minutes ago</span></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'import PencilIcon from '@master/icons-vue/native/16/soft/pencil'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="max-w(420) mx-auto">    <span class="block mb-xs text-xs fg-text-muted" id="doc-title-label">Title</span>    <h2 class="heading heading-xl">      <span class="editable">        <button type="button" class="editable-preview" id="doc-title-preview" aria-labelledby="doc-title-label doc-title-preview">          Quarterly report<PencilIcon class="icon editable-pencil" />        </button>        <input class="editable-field" value="Quarterly report" aria-labelledby="doc-title-label" required maxlength="80" hidden>      </span>    </h2>    <span class="block mt-xs text-sm fg-text-muted">Last edited by Ada, 2 minutes ago</span>  </div></template>
Press the title, type, then Enter to save or Escape to put it back.

#Where the text stands

The value lines up with the column it stands in: the root reaches out by --editable-padding-x on both sides, so the well grows around the text instead of pushing it in. The padding is in em, so a heading's well is as generous for its size as a cell's is for its own.

  • At rest the preview is plain text. It is a button, so it takes focus, and the pencil, an editable-pencil icon after its words, shows with the focus ring.
  • Under the pointer the inset tone and a half-pixel contour appear around the text, with the pencil after the last word. On a screen without a hovering pointer the pencil is always there, a little quieter: it is the only sign that the text can be changed.
  • Editing, the field is a well risen to the sheet with one ink contour and a halo, as a focused input is. Hidden, the preview still holds the cell open, so nothing below moves. Where the browser has field-sizing: content, the field grows past the preview as the value does; elsewhere its text scrolls inside the preview's width.
  • Pending. While the value is on its way, set aria-busy="true" on the root: the preview reads muted and takes no press.

#Several lines

A <textarea> as the field holds a value of several lines. Enter starts a line there, so Control or Command with Enter saves. While the value is empty the preview says the field's placeholder, in editable-placeholder.

Several lines

<div class="max-w(420) mx-auto text-sm fg-text-body">  <span class="block mb-xs text-xs fg-text-muted" id="doc-summary-label">Summary</span>  <div class="editable w-full">    <button type="button" class="editable-preview" id="doc-summary-preview" aria-labelledby="doc-summary-label doc-summary-preview">      <span class="editable-placeholder">Add a summary for the team</span><svg class="icon editable-pencil" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M2.6556 12.4849L3.2844 10.1793A0.7 0.7 0 0 1 3.4647 9.8686L10.505 2.8283A0.7 0.7 0 0 1 11.495 2.8283L13.1717 4.505A0.7 0.7 0 0 1 13.1717 5.495L6.1314 12.5353A0.7 0.7 0 0 1 5.8207 12.7156L3.5151 13.3444A0.7 0.7 0 0 1 2.6556 12.4849Z" /><path d="M9.6667 3.6667L12.3333 6.3333" />      </svg>    </button>    <textarea class="editable-field" aria-labelledby="doc-summary-label" placeholder="Add a summary for the team" rows="3" hidden></textarea>  </div></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'import PencilIcon from '@master/icons-react/native/16/soft/pencil'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="max-w(420) mx-auto text-sm fg-text-body">      <span className="block mb-xs text-xs fg-text-muted" id="doc-summary-label">Summary</span>      <div className="editable w-full">        <button type="button" className="editable-preview" id="doc-summary-preview" aria-labelledby="doc-summary-label doc-summary-preview">          <span className="editable-placeholder">Add a summary for the team</span><PencilIcon className="icon editable-pencil" />        </button>        <textarea className="editable-field" aria-labelledby="doc-summary-label" placeholder="Add a summary for the team" rows={3} hidden>{``}</textarea>      </div>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'  import PencilIcon from '@master/icons-svelte/native/16/soft/pencil'</script><div class="max-w(420) mx-auto text-sm fg-text-body" {@attach attach}>  <span class="block mb-xs text-xs fg-text-muted" id="doc-summary-label">Summary</span>  <div class="editable w-full">    <button type="button" class="editable-preview" id="doc-summary-preview" aria-labelledby="doc-summary-label doc-summary-preview">      <span class="editable-placeholder">Add a summary for the team</span><PencilIcon class="icon editable-pencil" />    </button>    <textarea class="editable-field" aria-labelledby="doc-summary-label" placeholder="Add a summary for the team" rows="3" hidden></textarea>  </div></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'import PencilIcon from '@master/icons-vue/native/16/soft/pencil'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="max-w(420) mx-auto text-sm fg-text-body">    <span class="block mb-xs text-xs fg-text-muted" id="doc-summary-label">Summary</span>    <div class="editable w-full">      <button type="button" class="editable-preview" id="doc-summary-preview" aria-labelledby="doc-summary-label doc-summary-preview">        <span class="editable-placeholder">Add a summary for the team</span><PencilIcon class="icon editable-pencil" />      </button>      <textarea class="editable-field" aria-labelledby="doc-summary-label" placeholder="Add a summary for the team" rows="3" hidden></textarea>    </div>  </div></template>

#The behavior

editable takes the root, the element with the editable class, and returns the function that detaches it.

app.js
import { editable } from '@master/ui/behaviors/editable.js'const title = editable(document.querySelector('.editable'))title.edit() // open the fieldtitle.value // the saved value
  • Opening. Pressing the preview hides it, shows the field with the saved value and selects its text.
  • Saving. Enter saves, and so does leaving the field. A value the field's own constraints refuse (required, maxlength, pattern) is not saved: Enter keeps the field open and lets the browser say why, and leaving puts the saved value back. Pass blur: 'cancel' to make leaving cancel.
  • Cancelling. Escape puts the saved value back.
  • Focus returns to the preview after Enter and Escape, never when the reader moved it elsewhere.
  • Events. Saving a different value writes it into the preview and dispatches input and change from the field. The function it returns has a value, the saved value, and edit(); setting the value writes the preview and the field and dispatches nothing.

Where the value goes after that is the page's. Set aria-busy="true" on the root while it is on its way. If the server refuses it, set the value back and say why next to it, or call edit() and mark the field aria-invalid="true", which draws the danger edge: what was typed is kept for the reader to correct.

Without the behavior the preview is a button that does nothing, and the value stays readable.

#Choosing it

An editable suits a value read far more often than it is changed, and changed one at a time where it stands. When several values are changed together and saved at once, a form of inputs with a Save button says more plainly what is saved and when.

#Keyboard

KeysAction
Enter, SpaceOn the preview, open the field with the value selected
EnterIn the field, save and return to the preview; in a textarea, Control or Command with Enter
EscapePut the saved value back and return to the preview
TabLeave the field, which saves the value, or puts it back when the field's constraints refuse it

While an input method composes, Enter and Escape belong to it.

#Accessibility

  • Name the value and its field with what it is. In the examples a visible label names the field, and the preview is named by the label and itself through aria-labelledby, so it is read as "Title, Quarterly report, button".
  • Keep the saved value readable without the script: it is the preview's text.
  • Say a save that fails next to the value, in words, not with the danger edge alone.

#React, Svelte and Vue

The editable component draws the first value into the first render and attaches the behavior, which writes the preview after that. The value that comes out is the saved one, never what is being typed. Copy it into the project with npx master-ui add editable; React, Svelte and Vue says how the components are built and used.

ui/editable.tsx
'use client'import { useId, useState, type ComponentProps } from 'react'import { editable } from '@master/ui/behaviors/editable.js'import { useBehavior } from './use-behavior'type Field = Omit<ComponentProps<'input'>, 'value' | 'defaultValue' | 'hidden'> & Omit<ComponentProps<'textarea'>, 'value' | 'defaultValue' | 'hidden'>export interface EditableProps extends Omit<Field, 'children'> {  /** The saved value. */  value?: string  defaultValue?: string  onValueChange?: (value: string) => void  /** What the value is, read with it by assistive technology: the field's name. */  label: string  /** A textarea, for a value of several lines. */  multiline?: boolean  /** The value is on its way: the preview waits. */  busy?: boolean  /** What leaving the field does. `'save'` by default. */  blur?: 'save' | 'cancel'}/** * An editable value. Every prop of a field goes to the field, so `required`, `maxLength` and `placeholder` * are its constraints and what the preview says while the value is empty. *//** The behavior finds its field as it attaches. One line and several are two elements, so it attaches again when `multiline` changes. */const fielded = (root: HTMLElement, options?: { blur?: 'save' | 'cancel', multiline?: boolean }) => editable(root, { blur: options?.blur })export function Editable({ value, defaultValue, onValueChange, label, multiline, busy, blur, disabled, className, ...field }: EditableProps) {  const id = useId()  // The first value is drawn into the first render; after that the behavior writes the preview and the field.  const [first] = useState(() => value ?? defaultValue ?? '')  const ref = useBehavior(fielded, { blur, multiline }, { value, defaultValue, onValueChange })  const shared = { className: 'editable-field', 'aria-label': label, disabled, hidden: true }  return (    <div className={className ? `editable ${className}` : 'editable'} ref={ref} aria-busy={busy || undefined}>      <button type="button" className="editable-preview" id={`${id}preview`} aria-labelledby={`${id}name ${id}preview`} disabled={disabled}>        {first || (field.placeholder ? <span className="editable-placeholder">{field.placeholder}</span> : null)}        <svg className="icon editable-pencil" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M2.6556 12.4849L3.2844 10.1793A0.7 0.7 0 0 1 3.4647 9.8686L10.505 2.8283A0.7 0.7 0 0 1 11.495 2.8283L13.1717 4.505A0.7 0.7 0 0 1 13.1717 5.495L6.1314 12.5353A0.7 0.7 0 0 1 5.8207 12.7156L3.5151 13.3444A0.7 0.7 0 0 1 2.6556 12.4849Z" /><path d="M9.6667 3.6667L12.3333 6.3333" /></svg>      </button>      <span id={`${id}name`} hidden>{label}</span>      {multiline        ? <textarea {...(field as ComponentProps<'textarea'>)} {...shared} defaultValue={first} />        : <input {...(field as ComponentProps<'input'>)} {...shared} defaultValue={first} />}    </div>  )}
ui/Editable.svelte
<script lang="ts" module>  import type { HTMLInputAttributes } from 'svelte/elements'  export interface EditableProps extends Omit<HTMLInputAttributes, 'value' | 'hidden' | 'children'> {    /** The saved value. Bind it, or leave it out. */    value?: string    onValueChange?: (value: string) => void    /** What the value is, read with it by assistive technology: the field's name. */    label: string    /** A textarea, for a value of several lines. */    multiline?: boolean    /** The value is on its way: the preview waits. */    busy?: boolean    /** What leaving the field does. `'save'` by default. */    blur?: 'save' | 'cancel'  }</script><script lang="ts">  import { untrack } from 'svelte'  import { editable } from '@master/ui/behaviors/editable.js'  import { behavior } from './behavior.svelte.js'  let { value = $bindable(), onValueChange, label, multiline, busy, blur, disabled, class: className, ...field }: EditableProps = $props()  const id = $props.id()  // The first value is drawn into the first render; after that the behavior writes the preview and the field.  const first = untrack(() => value) ?? ''  // The behavior finds its field as it attaches. One line and several are two elements, so it attaches again when `multiline` changes.  const fielded = (root: HTMLElement, options?: { blur?: 'save' | 'cancel', multiline?: boolean }) => editable(root, { blur: options?.blur })  const attach = behavior(fielded, () => ({ blur, multiline }), {    value: () => value,    change: (next) => { value = next; onValueChange?.(next) },  })</script><!--  @component  An editable value. Every other prop of a field goes to the field, so `required`, `maxlength` and  `placeholder` are its constraints and what the preview says while the value is empty.--><div class={['editable', className]} aria-busy={busy || undefined} {@attach attach}>  <button type="button" class="editable-preview" id="{id}preview" aria-labelledby="{id}name {id}preview" {disabled}>    {#if first}{first}{:else if field.placeholder}<span class="editable-placeholder">{field.placeholder}</span>{/if}<svg class="icon editable-pencil" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2.6556 12.4849L3.2844 10.1793A0.7 0.7 0 0 1 3.4647 9.8686L10.505 2.8283A0.7 0.7 0 0 1 11.495 2.8283L13.1717 4.505A0.7 0.7 0 0 1 13.1717 5.495L6.1314 12.5353A0.7 0.7 0 0 1 5.8207 12.7156L3.5151 13.3444A0.7 0.7 0 0 1 2.6556 12.4849Z" /><path d="M9.6667 3.6667L12.3333 6.3333" /></svg>  </button>  <span id="{id}name" hidden>{label}</span>  {#if multiline}    <textarea class="editable-field" aria-label={label} {disabled} hidden {...field as Record<string, unknown>} value={first}></textarea>  {:else}    <input class="editable-field" aria-label={label} {disabled} hidden {...field} value={first} />  {/if}</div>
ui/Editable.vue
<script setup lang="ts">import { useAttrs, useId, useTemplateRef } from 'vue'import { editable } from '@master/ui/behaviors/editable.js'import { useBehavior } from './use-behavior'defineOptions({ inheritAttrs: false })const { blur, multiline } = defineProps<{  /** What the value is, read with it by assistive technology: the field's name. */  label: string  /** A textarea, for a value of several lines. */  multiline?: boolean  /** The value is on its way: the preview waits. */  busy?: boolean  /** What leaving the field does. `'save'` by default. */  blur?: 'save' | 'cancel'  disabled?: boolean}>()/** The saved value: `v-model`. */const model = defineModel<string>()/* * An editable value. Every attribute but the class goes to the field, so `required`, `maxlength` and * `placeholder` are its constraints and what the preview says while the value is empty. */const id = useId()const attrs = useAttrs()const field = () => {  const { class: _, ...rest } = attrs  return rest}// The first value is drawn into the first render; after that the behavior writes the preview and the field.const first = model.value ?? ''const placeholder = attrs.placeholder as string | undefinedconst root = useTemplateRef<HTMLDivElement>('root')// The behavior finds its field as it attaches. One line and several are two elements, so it attaches again when `multiline` changes.const fielded = (element: HTMLElement, options?: { blur?: 'save' | 'cancel', multiline?: boolean }) => editable(element, { blur: options?.blur })useBehavior(root, fielded, () => ({ blur, multiline }), model)</script><template>  <div class="editable" :class="$attrs.class" :aria-busy="busy || undefined" ref="root">    <button type="button" class="editable-preview" :id="`${id}-preview`" :aria-labelledby="`${id}-name ${id}-preview`" :disabled="disabled">      <template v-if="first">{{ first }}</template>      <span v-else-if="placeholder" class="editable-placeholder">{{ placeholder }}</span>      <svg class="icon editable-pencil" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2.6556 12.4849L3.2844 10.1793A0.7 0.7 0 0 1 3.4647 9.8686L10.505 2.8283A0.7 0.7 0 0 1 11.495 2.8283L13.1717 4.505A0.7 0.7 0 0 1 13.1717 5.495L6.1314 12.5353A0.7 0.7 0 0 1 5.8207 12.7156L3.5151 13.3444A0.7 0.7 0 0 1 2.6556 12.4849Z" /><path d="M9.6667 3.6667L12.3333 6.3333" /></svg>    </button>    <span :id="`${id}-name`" hidden>{{ label }}</span>    <textarea v-if="multiline" class="editable-field" :aria-label="label" :disabled="disabled" hidden v-bind="field()" :value.attr="first" />    <input v-else class="editable-field" :aria-label="label" :disabled="disabled" hidden v-bind="field()" :value.attr="first">  </div></template>

#Classes

ClassDescription
editableThe value and its field, in one cell that the preview holds open; it reaches out by its padding so the text lines up with the column
editable-previewThe saved value, as a button: plain text at rest, a faint well with a pencil under the pointer. Hidden, it still holds the cell open
editable-pencilThe pencil after the words of the preview, an icon that shows under the pointer and with focus, and always where no pointer hovers
editable-fieldThe field that takes the preview's place, hidden at rest: a focused well in the same font, padding and corner
editable-placeholderInside the preview, what it says while the value is empty: the field's placeholder, in the muted ink

#Custom properties

PropertyDefaultDescription
--editable-padding-x.375emInline padding of the preview and the field, which the root bleeds into
--editable-padding-y.125emBlock padding of the preview and the field
--editable-radiusvar(--radius-control-sm)The corner of the well

#Source

@master/ui/components/editable.css
/* * Editable: a value read as text that becomes a field in place. * The preview and the field stand in one grid cell with the same font, padding and corner, so the text does * not move by a pixel when one replaces the other: the preview stays in the layout while it is hidden and * holds the cell open. At rest the value is plain text, set out from the column by the padding it bleeds * into; under the pointer a faint well appears around it with a pencil at its end, and while editing the * well is a focused field. Its type is whatever it stands in: a heading, a cell, a line of a form. * The editable behavior switches the two and saves; without it the preview is a button that does nothing. */@layer components.ui {  .editable {    --editable-padding-x: .375em;    --editable-padding-y: .125em;    --editable-radius: var(--radius-control-sm);    position: relative;    display: inline-grid;    grid-template: auto / minmax(0, auto);    max-width: calc(100% + var(--editable-padding-x) * 2);    /* The text lines up with the column; the well reaches out around it. */    margin-inline: calc(-1 * var(--editable-padding-x));    vertical-align: baseline;    /*     * While the value is on its way, the preview waits: it reads as pending and takes no press. The pointer     * passes through it to the root, so the root is what shows the progress cursor.     */    &[aria-busy="true"] {      cursor: progress;    }    &[aria-busy="true"] .editable-preview {      color: var(--color-text-muted);      pointer-events: none;      .editable-pencil {        opacity: 0;      }    }  }  /* What the preview and the field share, so that one sits exactly where the other was. */  .editable-preview,  .editable-field {    grid-area: 1 / 1;    box-sizing: border-box;    min-width: 0;    margin: 0;    padding: var(--editable-padding-y) var(--editable-padding-x);    border: 0;    border-radius: calc(var(--editable-radius) * var(--corner-scale));    corner-shape: var(--corner-shape);    font: inherit;    font-feature-settings: inherit;    letter-spacing: inherit;    text-align: start;    text-transform: inherit;  }  .editable-preview {    position: relative;    display: block;    background: transparent;    color: inherit;    white-space: pre-wrap;    overflow-wrap: anywhere;    appearance: none;    cursor: text;    -webkit-tap-highlight-color: transparent;    transition-property: background-color, box-shadow;    transition-duration: var(--duration-quick);    transition-timing-function: var(--easing-glide);    /* The pencil: it follows the last word, so it says what the press will do where the eye already is. */    .editable-pencil {      display: inline-block;      width: .8125em;      height: .8125em;      margin-inline-start: .375em;      color: var(--color-text-muted);      vertical-align: -.0625em;      opacity: 0;      transition: opacity var(--duration-quick) var(--easing-glide);    }    @media (hover: hover) {      &:hover:not(:disabled) {        background: var(--color-surface-inset);        box-shadow: inset 0 0 0 .5px var(--color-line-contour);        .editable-pencil {          opacity: 1;        }      }    }    /* Without a pointer that hovers, the pencil is always there: the only sign the text can be changed. */    @media (hover: none) {      &:not(:disabled) .editable-pencil {        opacity: .7;      }    }    &:focus-visible {      @apply --focus-ring;      outline-offset: 0;      .editable-pencil {        opacity: 1;      }    }    &:active:not(:disabled) {      background: var(--color-surface-inset-hover);    }    &:disabled {      cursor: default;    }    /* Hidden, it still holds the cell open, so the field takes its place and nothing below moves. */    &[hidden] {      display: block;      visibility: hidden;    }    /* A touch target reaches 44px tall without moving the text. */    @media (pointer: coarse) {      &::before {        @apply --touch-target-block;      }    }    @media (forced-colors: active) {      .editable-pencil {        color: ButtonText;      }      /* Heavier than the focus ring, so it steps aside on a focused preview instead of thinning its ring. */      @media (hover: hover) {        &:hover:not(:disabled, :focus-visible) {          outline: 1px solid ButtonText;        }      }    }  }  /* The field: a well risen to the sheet with one ink contour and a halo, as a focused input is. */  .editable-field {    display: block;    width: 100%;    outline: none;    background: var(--color-surface-raised);    color: inherit;    box-shadow: inset 0 0 0 .5px var(--color-line-mark), 0 0 0 .5px var(--color-line-mark), 0 0 0 3.5px var(--color-focus-halo);    caret-color: var(--color-text-strong);    resize: none;    appearance: none;    &::placeholder {      color: var(--color-text-muted);      opacity: 1;    }    /* Where the field can size itself, it grows past the preview as the value does. */    @supports (field-sizing: content) {      field-sizing: content;      min-width: 100%;    }    &:is([aria-invalid="true"], :user-invalid) {      box-shadow: inset 0 0 0 .5px var(--color-danger), 0 0 0 .5px var(--color-danger), 0 0 0 3.5px color-mix(in oklab, var(--color-danger) 15%, transparent);    }    &[hidden] {      display: none;    }    @media (forced-colors: active) {      outline: 2px solid Highlight;      outline-offset: -2px;      /* The danger edge is a shadow, which forced colors drop: the outline says it instead. */      &:is([aria-invalid="true"], :user-invalid) {        outline-color: Mark;      }    }  }  /* What the preview says while the value is empty: the field's placeholder, in the muted ink. */  .editable-placeholder {    color: var(--color-text-muted);  }}