DitherCharts

Inline edit

Updated

InlineEdit shows text with a pixel pencil that turns into an input on click or Enter, for renaming a chart or a dashboard in place. Enter or leaving the input saves, Escape cancels, and the keyboard returns to the text either way. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.

Example

import "@/components/dithercharts/controls.css"
import { InlineEdit } from "@/components/dithercharts/inline-edit"

<InlineEdit label="Chart title" value={title} onValueChange={(next) => setTitle(next)} />
<InlineEdit label="Description" placeholder="Add a description" />

Install

Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.

npx dithercharts add inline-edit

Props

It renders a native element, so every other attribute that element takes passes through.

InlineEdit props
PropTypeDefaultDescription
labelrequiredType stringDefault –What the text is, e.g. "Title": the input's accessible name, and read as "Edit Title" on the text.
valueType stringDefault –The text, for a controlled field; pair it with onValueChange.
defaultValueType stringDefault ""The text at first, for an uncontrolled field.
onValueChangeType (value: string) => voidDefault –Called with the new text when an edit is saved.
placeholderType stringDefault "Empty"Shown while the text is empty.
disabledType booleanDefault false
classNameType stringDefault –