Banner
Announcement bars — a slim dismissible top-of-page announcement on the primary surface, static or auto-rotating.
Preview
@props([
'messages' => null,
])
@php
$messages ??= [
['text' => 'Free shipping on every order over $50.', 'linkLabel' => 'Shop now', 'href' => '#'],
['text' => 'New winter collection just dropped.', 'linkLabel' => 'Explore', 'href' => '#'],
['text' => 'Save 20% with code WELCOME20 at checkout.', 'linkLabel' => 'Get the code', 'href' => '#'],
];
$messages = array_values($messages);
$count = count($messages);
@endphp
<x-ui.section
data-slot="banner-04"
aria-label="{{ __('Announcements') }}"
x-data="{
active: 0,
count: {{ $count }},
open: true,
paused: false,
timer: null,
init() {
if (this.count > 1) {
this.timer = setInterval(() => {
if (!this.paused) {
this.active = (this.active + 1) % this.count;
}
}, 5000);
}
},
destroy() {
clearInterval(this.timer);
},
next() {
this.active = (this.active + 1) % this.count;
},
prev() {
this.active = (this.active - 1 + this.count) % this.count;
},
}"
x-show="open"
x-on:mouseenter="paused = true"
x-on:mouseleave="paused = false"
space="none" surface="primary" class="relative w-full" {{ $attributes }}
>
<div class="mx-auto flex max-w-7xl items-center gap-x-2 px-4 py-2 pe-12 sm:gap-x-4 sm:pe-14">
@if ($count > 1)
<x-ui.button
variant="ghost"
size="icon"
x-on:click="prev()"
aria-label="{{ __('Previous announcement') }}"
class="hidden size-7 shrink-0 text-primary-foreground hover:bg-primary-foreground/10 hover:text-primary-foreground sm:inline-flex"
>
<svg class="size-4 rtl:-scale-x-100" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="m15 18-6-6 6-6" />
</svg>
</x-ui.button>
@endif
<div class="relative flex min-w-0 flex-1 items-center justify-center" aria-live="polite">
@foreach ($messages as $i => $message)
<div
x-show="active === {{ $i }}"
x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
@class(['absolute inset-0' => ! $loop->first])
>
<div class="flex flex-wrap items-center justify-center gap-x-2 gap-y-2 text-center text-sm">
<span class="text-primary-foreground">{{ __($message['text']) }}</span>
@if (! empty($message['linkLabel']))
<a
href="{{ $message['href'] ?? '#' }}"
class="inline-flex shrink-0 items-center gap-x-2 font-medium underline decoration-primary-foreground/50 underline-offset-2 transition-colors hover:decoration-primary-foreground"
>
{{ __($message['linkLabel']) }}
<svg class="size-4 rtl:-scale-x-100" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M5 12h14M13 6l6 6-6 6" />
</svg>
</a>
@endif
</div>
</div>
@endforeach
</div>
@if ($count > 1)
<div class="hidden shrink-0 items-center gap-x-2 sm:flex" aria-hidden="true">
@foreach ($messages as $i => $message)
<span
x-bind:class="active === {{ $i }} ? 'bg-primary-foreground' : 'bg-primary-foreground/40'"
class="size-2 rounded-full transition-colors"
></span>
@endforeach
</div>
<x-ui.button
variant="ghost"
size="icon"
x-on:click="next()"
aria-label="{{ __('Next announcement') }}"
class="hidden size-7 shrink-0 text-primary-foreground hover:bg-primary-foreground/10 hover:text-primary-foreground sm:inline-flex"
>
<svg class="size-4 rtl:-scale-x-100" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="m9 18 6-6-6-6" />
</svg>
</x-ui.button>
@endif
</div>
<div class="absolute inset-y-0 end-2 flex items-center sm:end-4">
<x-ui.button
variant="ghost"
size="icon"
x-on:click="open = false"
aria-label="{{ __('Dismiss announcements') }}"
class="text-primary-foreground hover:bg-primary-foreground/10 hover:text-primary-foreground"
>
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</x-ui.button>
</div>
</x-ui.section>
Installation
php artisan ui:add blocks/banner-rotating
Registry contract
Install confidence
php artisan ui:add blocks/banner-rotating
writes only the generated targets below. The CLI validates each file hash before writing and
prompts before replacing local changes unless --force is used.
- Version
- 1.0.4
- License
- open
- Stability
- stable
- Contract
- v1
- Foundation
- ≥ 1.0.0
| Type | Generated target |
|---|---|
| blade | resources/views/blocks/banner-rotating.blade.php |
Registry dependencies
Package dependencies
composer: jml/brok:^0.2
Use with AI
A brief for your coding agent: what the block is, the install command, how to render it, its props and the rules. Copy it, or open a prompt about this block in an assistant.
# Brok UI block: Banner 04 (`banner-rotating`)
A slim full-width announcement bar that auto-rotates through several short messages on the primary surface — each with an optional inline call-to-action link. Includes prev/next chevrons for manual stepping, dot indicators, pause-on-hover, an aria-live region for screen readers, and an end-aligned dismiss button.
Brok UI is a Laravel Blade registry. `ui:add` copies this block into the app as plain Blade the app owns; it composes installed `<brok:*>` primitives and semantic design tokens.
## Install
```bash
php artisan ui:add blocks/banner-rotating
```
## Render it
```blade
<x-blocks.banner-rotating />
```
## Props
- `messages` (mixed|null, default `null`)
## Use when
- Cycling through several short announcements in a slim bar, each with its own optional call-to-action link.
- Letting a visitor step through messages manually with prev/next chevrons and dot indicators, pausing on hover.
## Avoid when
- Use banner-announcement for a single, non-rotating announcement message instead of a carousel of several.
## Rules
- Render the installed block with `<x-blocks.banner-rotating />` and pass data through its props; edit the copied file only for structural changes.
- Keep the semantic design tokens (`bg-background`, `text-muted-foreground`); never swap in raw colour utilities.
- Keep the `data-slot` attributes and the logical (start/end) spacing so the markup still mirrors under `dir="rtl"`.
## Links
- Docs: https://brokui.dev/blocks/banner-rotating
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/banner-rotating.json
Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.
Guidance
Use when
- Cycling through several short announcements in a slim bar, each with its own optional call-to-action link.
- Letting a visitor step through messages manually with prev/next chevrons and dot indicators, pausing on hover.
Avoid when
- Use banner-announcement for a single, non-rotating announcement message instead of a carousel of several.
Anti-patterns
- Do not replace semantic props with conflicting utility classes.
- Do not remove labels, focus styles, or state attributes.
- Anatomy
Usage
Render the block as a component, passing data where useful:
<x-blocks.banner-rotating />
Built from primitives
This block composes installed <brok:*> primitives and semantic design
tokens only — it does not reimplement any primitive. Re-theme it (light, dark, admin, customer) by
editing CSS variables; flip the preview to RTL to confirm it mirrors.
Source
The exact, editable file ui:add writes
into your app. The preview above renders this same source — there are no preview-only blocks.
@props([
'messages' => null,
])
@php
$messages ??= [
['text' => 'Free shipping on every order over $50.', 'linkLabel' => 'Shop now', 'href' => '#'],
['text' => 'New winter collection just dropped.', 'linkLabel' => 'Explore', 'href' => '#'],
['text' => 'Save 20% with code WELCOME20 at checkout.', 'linkLabel' => 'Get the code', 'href' => '#'],
];
$messages = array_values($messages);
$count = count($messages);
@endphp
<x-ui.section
data-slot="banner-04"
aria-label="{{ __('Announcements') }}"
x-data="{
active: 0,
count: {{ $count }},
open: true,
paused: false,
timer: null,
init() {
if (this.count > 1) {
this.timer = setInterval(() => {
if (!this.paused) {
this.active = (this.active + 1) % this.count;
}
}, 5000);
}
},
destroy() {
clearInterval(this.timer);
},
next() {
this.active = (this.active + 1) % this.count;
},
prev() {
this.active = (this.active - 1 + this.count) % this.count;
},
}"
x-show="open"
x-on:mouseenter="paused = true"
x-on:mouseleave="paused = false"
space="none" surface="primary" class="relative w-full" {{ $attributes }}
>
<div class="mx-auto flex max-w-7xl items-center gap-x-2 px-4 py-2 pe-12 sm:gap-x-4 sm:pe-14">
@if ($count > 1)
<x-ui.button
variant="ghost"
size="icon"
x-on:click="prev()"
aria-label="{{ __('Previous announcement') }}"
class="hidden size-7 shrink-0 text-primary-foreground hover:bg-primary-foreground/10 hover:text-primary-foreground sm:inline-flex"
>
<svg class="size-4 rtl:-scale-x-100" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="m15 18-6-6 6-6" />
</svg>
</x-ui.button>
@endif
<div class="relative flex min-w-0 flex-1 items-center justify-center" aria-live="polite">
@foreach ($messages as $i => $message)
<div
x-show="active === {{ $i }}"
x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
@class(['absolute inset-0' => ! $loop->first])
>
<div class="flex flex-wrap items-center justify-center gap-x-2 gap-y-2 text-center text-sm">
<span class="text-primary-foreground">{{ __($message['text']) }}</span>
@if (! empty($message['linkLabel']))
<a
href="{{ $message['href'] ?? '#' }}"
class="inline-flex shrink-0 items-center gap-x-2 font-medium underline decoration-primary-foreground/50 underline-offset-2 transition-colors hover:decoration-primary-foreground"
>
{{ __($message['linkLabel']) }}
<svg class="size-4 rtl:-scale-x-100" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M5 12h14M13 6l6 6-6 6" />
</svg>
</a>
@endif
</div>
</div>
@endforeach
</div>
@if ($count > 1)
<div class="hidden shrink-0 items-center gap-x-2 sm:flex" aria-hidden="true">
@foreach ($messages as $i => $message)
<span
x-bind:class="active === {{ $i }} ? 'bg-primary-foreground' : 'bg-primary-foreground/40'"
class="size-2 rounded-full transition-colors"
></span>
@endforeach
</div>
<x-ui.button
variant="ghost"
size="icon"
x-on:click="next()"
aria-label="{{ __('Next announcement') }}"
class="hidden size-7 shrink-0 text-primary-foreground hover:bg-primary-foreground/10 hover:text-primary-foreground sm:inline-flex"
>
<svg class="size-4 rtl:-scale-x-100" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="m9 18 6-6-6-6" />
</svg>
</x-ui.button>
@endif
</div>
<div class="absolute inset-y-0 end-2 flex items-center sm:end-4">
<x-ui.button
variant="ghost"
size="icon"
x-on:click="open = false"
aria-label="{{ __('Dismiss announcements') }}"
class="text-primary-foreground hover:bg-primary-foreground/10 hover:text-primary-foreground"
>
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</x-ui.button>
</div>
</x-ui.section>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.0.4 - Status
- Stable
- License
-
open - Deprecation
- Not deprecated
- Contract
-
v1 - Foundation
-
≥ 1.0.0