Environment
Environment component.
Environment, Personalization Blocks
Example:
TallStackUi::personalize() ->environment() ->block('block', 'classes');
Many modern applications need to have different environments for different purposes, such as: local -
for local development environment, staging - for general testing environment and production - for the
actual application. The environment
component consists of the current environment
of the application in a summarized form to serve as a warning.
With the example above you should realize that the environment is a basic component. With the release of version 2.x of TallStackUI a new helper was introduced: EnvBar. Unlike the environment component, the EnvBar is a fixed bar at the top of the screen that serves to display several other information about the current environment - not just the environment name and branch. If you want to go further and use the EnvBar click here.
![](https://tallstackui.com/assets/images/env-bar.png)
Internally TallStackUI uses a simple algorithm to get the current branch name based
on the .git
folder and its content. However, you can create your
own algorithm to be used for branch detection.
This is the current original algorithm:
use Illuminate\Support\Facades\File; private function branch(): ?string{ // ... if (($branch = rescue(fn () => File::get(base_path('.git/HEAD')), report: false)) === null) { return null; } $string = str($branch); if (! $string->contains('ref: refs/heads/')) { return null; } return $string->replace('ref: refs/heads/', '')->trim()->value();}
If you want to create your own algorithm, just define it through a service provider:
use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider{ public function register(): void { // ... $this->app->bind('tallstackui::environment::branch', function () { return 'logic goes here'; }); }}
You may have noticed that there is no way to define component colors. Internally TallStackUI defines default colors by environment name, however you can customize all colors, as well as create new ones by environment name.
local
- shades of green colorsstating
- shades of yellow colorssandbox
- shades of orange colorsproduction
- shades of red colors- Others - shades of primary colors
You can personalize or create new colors per room by following TallStackUI color personalization.