KeyValueEditor
Pairs of a name and a value: environment variables, headers. Add, remove, hide a secret value; pasting several NAME=value lines fills a row each.
import { KeyValueEditor, KeyValueEditorSkeleton } from '@sypnia/ui/react'
Environment variables
Paste several NAME=value lines into a name to fill them all.
Code
import { useState } from 'react';
import { KeyValueEditor, KeyValueEditorSkeleton, type KeyValueRow } from '@sypnia/ui/react';
// Paste «A=1» lines into a name to fill several rows. Write the same name twice to see the message.
export default function Env() {
const [rows, setRows] = useState<KeyValueRow[]>([{ key: 'DATABASE_URL', value: 'postgres://shop.eu.sypnia.app/shop', secret: true }, { key: 'LOG_LEVEL', value: 'info' }]);
return <div className="sy-stack"><KeyValueEditor rows={rows} onChange={setRows} /><KeyValueEditorSkeleton rows={2} /></div>;
} When to use it
Use it when
- Environment variables, request headers, metadata.
Do not use it when
- A fixed set of settings: give each its own field.
For everyone
- Each input is named with its row; repeated names are said in words.
Props
| KeyValueEditor | Type | Default |
|---|---|---|
onChangerequired | (rows: KeyValueRow[]) => void | |
rowsrequired | KeyValueRow[] | |
keyLabel | string | |
secretsLets each value be marked secret: hidden on screen. | boolean | true |
upperWrites names in capitals, as environment variables are. | boolean | true |
valueLabel | string |
| KeyValueEditorSkeleton | Type | Default |
|---|---|---|
rows | number | 3 |