Skip to main content

Key value editor

Edit free-form key and value pairs, with paste and an optional JSON mode.

<mm-key-value-editor label="Metadata" json></mm-key-value-editor>

Guidance​

The key and value editor takes free-form pairs: an asset's metadata, a schema's columns and types, a set of links. Rows are a key, a value and a remove button, with "Add field" below. Pasting several key: value (or key = value, or tab separated) lines into any key splits them into rows, so people can paste from a spreadsheet or a config file. Dotted keys (contact.slack) mean nesting. With json, "Edit as JSON" swaps the rows for a JSON text box for deeper structures, and back.

Adding a row focuses its key; removing one focuses the next row, or Add field. Changes are announced politely.

Properties​

PropertyAttributeTypeDefaultDescription
valueKeyValuePair[][]The pairs.
labellabelstring''Accessible name of the group, such as "Metadata".
keyLabelkey-labelstring''
valueLabelvalue-labelstring''
keyPlaceholderkey-placeholderstring''
valuePlaceholdervalue-placeholderstring''
addLabeladd-labelstring''Text of the add button. Defaults to "Add field".
jsonjsonbooleanfalseOffers "Edit as JSON" for nested values.

Events​

EventDetailDescription
mm-changeCustomEvent<{ value: KeyValuePair[] }>The pairs changed.

CSS parts​

PartDescription
rowEach pair.

Examples​

Every state of mm-key-value-editor in Storybook, with keyboard and screen reader tests.