Skip to content

EnvironmentSwitcher

Which environment of the project: production, staging, a preview. Production carries a warning light so nobody changes it by mistake.

import { EnvironmentSwitcher } from '@sypnia/ui/react'

On this page
  1. Three environments
  2. When to use it
  3. For everyone
  4. Props

Three environments

Code
import { useState } from 'react';
import { EnvironmentSwitcher } from '@sypnia/ui/react';

// Production carries a warning light, so nobody changes it thinking it is staging.
export default function Envs() {
  const [env, setEnv] = useState('production');
  return <EnvironmentSwitcher current={env} onChange={setEnv}
    options={[{ id: 'production', name: 'Production', tone: 'warn' }, { id: 'staging', name: 'Staging', tone: 'ok' }, { id: 'preview', name: 'Preview #212', tone: 'neutral', detail: 'Branch fix-login' }]} />;
}

When to use it

Use it when

  • Projects with more than one environment.
  • Mark production with tone="warn".

Do not use it when

  • One environment only.

For everyone

  • The light is decoration; the name says which environment it is.

Props

EnvironmentSwitcherTypeDefault
currentrequired string
onChangerequired (id: string) => void
optionsrequired SwitcherOption[]
compact boolean
createLabel

The thing to create: «organization». Defaults to `kind`.

string
kind string
onCreate

Adds «Create …» at the end of the list.

(() => void)
onSettings

Adds a settings entry at the end of the list («Organization settings» on the OrgSwitcher).

(() => void)
settingsLabel

The words of that entry.

string
  1. Three environments
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms