Skip to content

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'

On this page
  1. Environment variables
  2. When to use it
  3. For everyone
  4. Props

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

KeyValueEditorTypeDefault
onChangerequired (rows: KeyValueRow[]) => void
rowsrequired KeyValueRow[]
keyLabel string
secrets

Lets each value be marked secret: hidden on screen.

boolean true
upper

Writes names in capitals, as environment variables are.

boolean true
valueLabel string
KeyValueEditorSkeletonTypeDefault
rows number 3
  1. Environment variables
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms