Environment Badge

Environment Badge is a copy-paste React component that stops edited production thinking it was staging before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/environment-badge
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsEdited production thinking it was staging

Was this component page useful?

How do I install Environment Badge?

pnpm dlx shadcn@latest add @bollard/environment-badge

The files land in your project. They're yours to edit.

How do I use Environment Badge in React?

environment-badge-usage.tsx
import { EnvironmentBadge, useEnvironmentGuard } from "@/components/ui/environment-badge"

<EnvironmentBadge env={env} detail="ap-south-1 · orders-db" prefixTitle={markTab} markFavicon={markTab} />

What input mistakes does Environment Badge catch?

  • Working in production by mistake, via page, tab title and favicon marks
  • Environment names like "eu-prod-2", recognised word by word
  • Unknown environments, which are never shown as safe
  • Production-only confirmation through the hook

What props does Environment Badge accept?

EnvironmentBadge props
PropTypeDefault
env* (required)

The environment this app is running in. Accepts aliases like "prod", "uat", "local" or "prod-eu-1".

string—
fallback

How to treat a name that matches no known alias. Defaults to staging, so an unknown env is never shown as safe.

Environment"staging"
labels

Display names per environment, e.g. to translate them. The short tags (PROD, STG, DEV) stay as they are.

Partial<Record<Environment, string>>—
envSuffix

Read after the name by screen readers: "Production environment".

string"environment"
unknownMessage

Strip message for a name that matched no alias; the name itself is shown as the label.

string"Unrecognised environment, so treat it as live"
variant

`strip` is a full-width bar for the top of an admin layout, `ribbon` a corner sash, `badge` an inline pill.

"strip" | "ribbon" | "badge""strip"
message

What the environment means, shown in the strip after its name.

string—
detail

Extra detail shown in the strip, e.g. a region or database name. Hidden on small screens.

string—
prefixTitle

Prefix the tab title with the environment, e.g. "[PROD] Orders". Kept when the app changes the title; removed on unmount.

booleanfalse
markFavicon

Paint a colored band onto the favicon so the tab itself shows where you are. Restored on unmount.

booleanfalse

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Environment Badge accessible?

  • The environment is written out in text; short codes are aria-hidden
  • The production confirmation is a native <dialog> labelled by its title, with the safe button focused
  • Production uses a hatch pattern as well as colour

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Separate credentials and permissions per environment on the server; a badge is a reminder, not access control.

  • Only as accurate as the env value you pass
  • Marks the browser UI; it doesn't stop API calls made against production

What expensive mistakes does Environment Badge stop?

Edited production thinking it was staging

Also known as

environment banner · prod badge · staging · dev · favicon · tab title · admin panel · env indicator

What dependencies does Environment Badge require?

Environment Badge facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameEnvironment Badge
Registry identifier@bollard/environment-badge
Install commandnpx shadcn@latest add @bollard/environment-badge
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Environment Badge

What form validation mistake does Environment Badge catch?

Environment Badge prevents edited production thinking it was staging. Marks the page, tab title and favicon with the environment, so nobody edits production thinking it is staging. Catches: Working in production by mistake, via page, tab title and favicon marks, Environment names like "eu-prod-2", recognised word by word, Unknown environments, which are never shown as safe, Production-only confirmation through the hook. Limitation: validate environment-badge schemas on backend.

How do I install environment-badge with shadcn?

Run `npx shadcn@latest add @bollard/environment-badge`. Sources added: registry/default/environment-badge/environment-badge.tsx. Package requirements: lucide-react.

What props customize Environment Badge?

Environment Badge accepts `env`, `fallback`, `labels`, `envSuffix`, `unknownMessage`. Configures environment banner, prod badge, staging behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of environment-badge?

Only as accurate as the env value you pass. Marks the browser UI; it doesn't stop API calls made against production Server requirement: Separate credentials and permissions per environment on the server; a badge is a reminder, not access control.

How does Environment Badge meet accessibility guidelines?

The environment is written out in text; short codes are aria-hidden. The production confirmation is a native <dialog> labelled by its title, with the safe button focused. Production uses a hatch pattern as well as colour. Minimizes errors: changed prod instead of staging, which environment am i in.

Which components pair with Environment Badge?