Environment indicator

Mark every page with the environment's name, so nobody changes live data by mistake

An environment indicator marks every page of the admin panel with the name of the current environment, such as "Live" or "Staging". This allows users to tell the live admin panel apart from a test one, so they don't change live data by mistake.

Add an environment indicator by calling EnableEnvironmentIndicator(). The example below reads the environment from the app's configuration, and displays a red banner in the live environment and a yellow stripe in staging, with no indicator visible in other environments.

var environment = builder.Configuration["Deployment:Environment"];

builder.Services.AddStellarAdmin(admin =>
{
    if (environment == "live")
    {
        admin.EnableEnvironmentIndicator(EnvironmentIndicator.Banner("Live", banner =>
        {
            banner.Color = EnvironmentColor.Danger;
            banner.Description = "Changes affect real customers";
        }));
    }
    else if (environment == "staging")
    {
        admin.EnableEnvironmentIndicator(EnvironmentIndicator.Stripe("Staging", stripe =>
            stripe.Color = EnvironmentColor.Warning));
    }
});

The parameter passed to EnableEnvironmentIndicator() can be one of the following:

IndicatorDescription
EnvironmentIndicator.Stripe(label)Displays a thin bar across the top of the window, with the label on a tab.
EnvironmentIndicator.Frame(label)Displays a border around the window, with the label on a tab at the top.
EnvironmentIndicator.Banner(label)Displays a bar across the top of the window, with the label and the description. The page moves down to make room for it.
The admin panel with each kind of environment indicator: Stripe
Stripe
The admin panel with each kind of environment indicator: Frame
Frame
The admin panel with each kind of environment indicator: Banner
Banner

You can set the following optional properties in the configure callback:

SettingWhat it does
ColorSets the indicator's color. See choosing a color. The default is EnvironmentColor.Neutral, which is gray.
TabSizeSets the size of the tab of a stripe or a frame: EnvironmentIndicatorTabSize.Small, Medium, Large or ExtraLarge. The default is Medium.
DescriptionSets the text displayed after the label on a banner. The default is none.

Choosing a color

EnvironmentColor has predefined colors from your theme for each kind of environment: Neutral, Info, Success, Warning and Danger. These will adapt with your theme, and in dark mode.

To use your own color, pass a CSS color to EnvironmentColor.Custom(). You can also specify the color to use in dark mode, passed as the second argument:

banner.Color = EnvironmentColor.Custom("#7c3aed", "#c4b5fd");

StellarAdmin displays the label in white or in a dark color - whichever contrasts better with the color you specified.

Pages outside the admin panel

The environment indicator is only displayed on the pages of the admin panel, including your custom pages. To mark your app's other pages, such as its sign-in page, add the environment indicator component to their layout.

On this page