Skip to content
Brok UI

Loading…

No results

Gradient Bars

Open source

A decorative equalizer-style row of gradient bars that pulse on a staggered loop, ideal as an animated hero backdrop; renders as a static wave under reduced motion.

Version
v1.0.3
Stability
stable
License
MIT
Related
Mesh Gradient
Dither Gradient
Bars Loader

Preview

Now Playing

previews.components.gradient-bars.default.blade.php Blade
<div class="relative mx-auto h-40 w-full max-w-2xl overflow-hidden rounded-lg border bg-card">
    <x-ui.gradient-bars :count="24" color="primary" class="absolute inset-0 opacity-70" />
    <div class="absolute inset-0 flex items-center justify-center">
        <h3 class="text-lg font-semibold text-foreground">Now Playing</h3>
    </div>
</div>

Installation

terminal
php artisan ui:add gradient-bars

Registry contract

php artisan ui:add gradient-bars writes only the files below. The CLI validates each file hash before writing and asks before it replaces a local change, unless you pass --force.

  • blade resources/views/components/ui/gradient-bars.blade.php
Registry dependencies
None — installs on its own.
Packages
composer: jml/brok:^0.2

Use with AI

A brief for your coding agent: install command, usage, props, guidance and the rules. Copy it, or open a prompt about this component in an assistant.

gradient-bars.md
# Brok UI: Gradient Bars (`gradient-bars`)

A decorative equalizer-style row of gradient bars that pulse on a staggered loop, ideal as an animated hero backdrop; renders as a static wave under reduced motion.

Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.

## Install

```bash
php artisan ui:add gradient-bars
```

## Usage

```blade
<div class="relative mx-auto h-40 w-full max-w-2xl overflow-hidden rounded-lg border bg-card">
    <x-ui.gradient-bars :count="24" color="primary" class="absolute inset-0 opacity-70" />
    <div class="absolute inset-0 flex items-center justify-center">
        <h3 class="text-lg font-semibold text-foreground">Now Playing</h3>
    </div>
</div>
```

## Props

- `count` (int, default `15`) — Number of bars rendered.
- `color` (string, default `primary`) — Bar colour: primary, success, warning, or destructive.
- `height` (string, default `100%`) — CSS height of the bar row.
- `speed` (int, default `2`) — Seconds for one pulse cycle.
- `gap` (string, default `0.25rem`) — CSS gap between bars.

## Use when

- Use only when visual expression supports storytelling, brand differentiation, or a clear showcase moment.
- Adding a decorative, animated equalizer-style backdrop behind a hero or audio-themed section.
- Wanting bar count, colour, height, speed, and gap to stay configurable while the wave shape stays intentional even under reduced motion.

## Avoid when

- Do not place heavy effects in task-dense workflows where clarity, speed, and readability matter more.
- Needing a functional audio visualizer tied to real audio data; this component's bars are decorative and fixed, not driven by input.
- Needing a loading indicator; use bars-loader instead, since this component has no status semantics.

## Anti-patterns

- Heavy effects in forms or task-dense workflows
- Motion that interferes with reading or focus

## Rules

- Use the `<brok:gradient-bars>` tag (or `<x-ui.gradient-bars>`) in Blade; do not rewrite the component.
- Prefer the documented props and variants over utility-class overrides; when a utility must win, use the `!` important modifier.
- Use semantic design tokens (`bg-primary`, `text-muted-foreground`), never raw colour utilities.
- Keep the `data-slot` attributes; they are the styling and test hooks.

## Links

- Docs: https://brokui.dev/docs/components/gradient-bars
- Registry JSON (files, props, contract): https://brokui.dev/r/open/gradient-bars.json

Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.

API

manifest knowledge + registry-derived coverage

Props

Props accepted by this component: name, type, default value and description.
Prop Type Default Description
count int 15 Number of bars rendered.
color string primary Bar colour: primary, success, warning, or destructive.
height string 100% CSS height of the bar row.
speed int 2 Seconds for one pulse cycle.
gap string 0.25rem CSS gap between bars.

Slots

  • default — Unused; the component has no visible default slot content.

Data slots

Stable hooks for CSS overrides and browser tests.

gradient-bars gradient-bars-bar

Behavior

  • Each bar pulses its scale on a staggered, looping animation; a deterministic wave of static scale values keeps the row looking intentional when motion is off.
  • Colours come from a fixed set of semantic tokens via a linear gradient fading to transparent, so the effect themes for free.
  • Declares registry capability flags: a11y, responsive, rtl, darkMode, localized, reducedMotion.

Guidance

Expressive and showcase effect

Support brand expression or a showcase moment.

Use when

  • Use only when visual expression supports storytelling, brand differentiation, or a clear showcase moment.
  • Adding a decorative, animated equalizer-style backdrop behind a hero or audio-themed section.
  • Wanting bar count, colour, height, speed, and gap to stay configurable while the wave shape stays intentional even under reduced motion.

Avoid when

  • Do not place heavy effects in task-dense workflows where clarity, speed, and readability matter more.
  • Needing a functional audio visualizer tied to real audio data; this component's bars are decorative and fixed, not driven by input.
  • Needing a loading indicator; use bars-loader instead, since this component has no status semantics.

Use instead

  • Static content-first presentation

Anti-patterns

  • Heavy effects in forms or task-dense workflows
  • Motion that interferes with reading or focus
Anatomy
root gradient-bars-bar
Theming hooks
gradient-bars gradient-bars-bar

Accessibility

WCAG 2.2 AA Keyboard focus-visible RTL-ready Localized labels Dark mode
Keyboard
No component-owned keyboard interaction; native element behavior applies.
Focus
none
  • The root is aria-hidden since the bars carry no information, only decoration.
  • Motion respects motion-safe, so reduced-motion users see the static wave shape instead of the pulsing animation.
  • Semantic HTML and a stable data-slot attribute for styling and scripting hooks.
  • Focus-visible rings use the ring token, so keyboard focus is always visible.
  • Disabled and invalid states are conveyed to assistive tech, not by color alone.
  • Targets WCAG 2.2 AA; verify contrast in light, dark, admin and customer surfaces in the preview.
  • Labels go through __() and layout uses logical properties (ms-*, text-start), so it mirrors under dir="rtl" — flip the preview to RTL to confirm.
  • Dark mode uses the same semantic tokens under the dark class; high contrast follows forced-color system tokens.

Livewire

Safe

Livewire can update this component through forwarded wire:* attributes.

Source

The exact, editable file ui:add writes into your app. Previews render this same code; there are no preview-only components.

resources/views/components/ui/gradient-bars.blade.php Blade
@props([
    'count' => 15,
    'color' => 'primary',
    'height' => '100%',
    'speed' => 2,
    'gap' => '0.25rem',
])

@php
    $count = max(1, (int) $count);

    $colorClass = match ($color) {
        'success' => 'text-success',
        'warning' => 'text-warning',
        'destructive' => 'text-destructive',
        default => 'text-primary',
    };

    // Deterministic static heights so reduced-motion / no-JS renders still look
    // intentional (a gentle wave rather than a flat row). Range ~40%..100%.
    $wave = [0.55, 0.75, 0.9, 1.0, 0.85, 0.6, 0.45, 0.65, 0.85, 1.0, 0.8, 0.6, 0.5, 0.7, 0.95];
@endphp

<div
    data-slot="gradient-bars"
    aria-hidden="true"
    {{ $attributes->merge(['class' => 'flex w-full items-end ' . $colorClass]) }}
    style="height: {{ $height }}; gap: {{ $gap }}; --speed: {{ $speed }}s;"
>
    @for ($i = 0; $i < $count; $i++)
        @php
            $staticScale = $wave[$i % count($wave)];
            $delay = ($i % 5) * 0.15;
        @endphp
        <div
            data-slot="gradient-bars-bar"
            class="h-full min-w-[2px] flex-1 rounded-t-sm [background:linear-gradient(to_top,currentColor,transparent)] motion-safe:animate-[ui-gradient-bars_var(--speed)_ease-in-out_infinite]"
            style="--i: {{ $i }}; transform-origin: bottom; transform: scaleY({{ $staticScale }}); animation-delay: {{ $delay }}s;"
        ></div>
    @endfor
</div>

Ownership & lifecycle

Owner, release state, review evidence and adoption for this item.
Owner
Platform UI (@JoshJML)
Current version
1.0.3
Status
Stable
License
open
Accessibility reviewed
No review date recorded
Last breaking change
No date recorded
Deprecation
Not deprecated
Contract
v6
Foundation
≥ 1.0.0