UnflowUI
Components

ListEditor

Edits a list of strings, such as globs, domains or keywords, with optional reordering and per-row validation.

Overview

ListEditor renders one input per row plus an add button. It is controlled: pass value and update it from onChange. It never trims or dedupes the rows, so do that when you save.

  • Enter in the last row adds a row; Backspace in an empty row removes it.
  • reorderable adds a drag handle plus move up and move down buttons to each row.
  • validate returns an error message for a row, shown under that row's input.

Import

import { ListEditor } from '@unflowio/ui/components/ListEditor';

Props

PropTypeDefaultDescription
valuestring[]—Required. The rows
onChange(next: string[]) => void—Required. Called with the next list after an edit, add, remove or reorder
labelstring—Required. Accessible name of the list (e.g. "Ignore globs")
placeholderstring—Placeholder shown in every row
addLabelstringtranslated "Add"Label of the add button
maxItemsnumber—Disables the add button (and Enter-to-add) once the list has this many rows
reorderablebooleanfalseShows a drag handle plus move up and move down buttons on each row
validate(value: string, index: number) => string | undefined—Returns an error message for a row, or undefined when it is valid
disabledboolean—Disables every row and button

Basic usage

const [globs, setGlobs] = useState(['dist/**', '*.log']);

<ListEditor label="Ignore globs" placeholder="e.g. dist/**" addLabel="Add glob" value={globs} onChange={setGlobs} />

Reorderable

<ListEditor label="Ignore globs" value={globs} onChange={setGlobs} reorderable />

Validation

<ListEditor
  label="Ignore globs"
  value={globs}
  onChange={setGlobs}
  validate={(value) => (value.startsWith('/') ? 'Use a path relative to the repository root' : undefined)}
/>

Maximum rows

<ListEditor label="Allowed domains" value={domains} onChange={setDomains} maxItems={2} />

Customization (slotProps)

Slot PropPropsDescription
inputOmit<IInput, 'value' | 'onChange' | 'onKeyDown' | 'disabled' | 'status' | 'statusMessage' | 'ref'>Props for every row's Input

Accessibility

  • The list is a role="group" named by label; each row's input is named by its position ("Row 2").
  • The remove, move up and move down buttons name the row they act on ("Remove row 2"), and all labels are translated.
  • Reordering works without a pointer through the move up and move down buttons.