Xzero UI
Pro library

Environment variablesPro

An environment variables and secrets manager with masked values, per-environment scope toggles, .env paste import with duplicate and invalid key warnings, write-only sensitive values, an environment diff by fingerprint, and a redeploy banner.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/env-variables
Live · keyboard ready

Render <EnvVariables /> for the demo, or pass variables, project and sampleDotenv with onChange to persist rows and onRedeploy (which can return a promise) to run a real deploy.

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/env-variables

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { EnvVariables } from "@/components/xzero/blocks/env-variables/env-variables";

export function ProjectEnvironment({ project, variables }) {
  return (
    <EnvVariables
      project={project.slug}
      variables={variables}
      sampleDotenv=""
      onChange={rows => saveVariables(project.id, rows)}
      onRedeploy={environments => triggerRedeploy(project.id, environments)}
    />
  );
}

API reference

EnvVariables

An environment variables and secrets manager. Each row is one value and the environments it applies to, drawn as a matrix of Development, Preview, and Production toggles, so a key can hold a different value per environment. Values stay masked and are not in the DOM until revealed; sensitive values are write-only. Add one variable or paste a whole .env file, compare two environments by fingerprint, and redeploy from a banner that appears after changes.

PropTypeDefaultDescription
variablesEnvVariable[]VARIABLESRows in any order: { id, key, value, environments, sensitive, updated, updatedBy }. A key can appear on several rows as long as each environment is covered at most once. The block sorts rows by key.
projectstring"northwind-storefront"Project name shown under the heading.
sampleDotenvstringSAMPLE_DOTENVText the paste area starts with when Import .env opens. Pass an empty string for a blank paste area.
titlestring"Environment variables"Heading text.
onChange(variables: EnvVariable[]) => void–Called with every row after each add, import, edit, removal, scope toggle, or copy between environments.
onRedeploy(environments: EnvName[]) => void | Promise<void>–Called when Redeploy is pressed with the environments that changed. Return a promise to keep the banner pending until it settles; a rejection shows the failure state and keeps the changes queued. Without it, the deploy is simulated.
classNamestring–Class on the root section.

Keyboard interactions

KeysAction
TabMoves through the header actions, search, view switch, and each row's reveal, copy, environment toggles, and edit button.
Enter / SpaceReveals or hides a value, turns an environment on or off for a row, opens the inline editor, or presses a button.
EscapeCloses the inline editor or the add panel and returns focus to the button that opened it.
Arrow keysMove between options in the view switch, the add mode switch, and the compare environment selects.
Enter in a formSaves the edited value, saves a new variable, or imports the parsed .env lines.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Blocks are complete, self-contained screens with sample data. Replace the sample data and connect the callbacks described above. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components