Skip to content
Brok UI

Loading…

No results

Sale

Open source

Promotional sale sections — a bold gradient panel with countdown pills, dual CTAs and a discount code, and a dismissible full-width promo bar with a copyable code.

Preview

resources/views/blocks/sale-banner.blade.php Blade
@props([
    'eyebrow'  => 'Flash sale',
    'headline' => 'Up to 50% off everything — today only',
    'hours'    => '04',
    'minutes'  => '32',
    'seconds'  => '09',
    'ctaLabel' => 'Shop now',
    'ctaHref'  => '#',
    'code'     => 'FLASH50',
    'showCode' => true,
])

@php
    $chips = [['value' => $hours, 'aria' => __('hours')], ['value' => $minutes, 'aria' => __('minutes')], ['value' => $seconds, 'aria' => __('seconds')]];
@endphp

<x-ui.section data-slot="sale-banner" space="none" surface="primary" {{ $attributes }}>
    <div class="mx-auto max-w-7xl px-4 py-4">
        <div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
            <div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-4">
                <x-ui.badge class="w-fit border-transparent bg-primary-foreground text-primary">{{ __($eyebrow) }}</x-ui.badge>
                <p class="text-sm font-semibold leading-snug text-primary-foreground sm:text-base">{{ __($headline) }}</p>
            </div>

            <div class="flex items-center gap-2" role="timer" aria-label="{{ __('Time remaining') }}">
                @foreach ($chips as $chip)
                    <span class="inline-flex min-w-[2.25rem] items-center justify-center rounded-md border border-primary-foreground/20 bg-primary-foreground/10 px-2 py-0.5 font-mono text-xs font-bold tabular-nums text-primary-foreground" aria-label="{{ $chip['aria'] }}">{{ $chip['value'] }}</span>
                    @unless ($loop->last)<span class="select-none text-xs font-bold text-primary-foreground" aria-hidden="true">:</span>@endunless
                @endforeach
            </div>

            <div class="flex shrink-0 items-center gap-2">
                @if ($showCode && $code)
                    <span class="hidden items-center gap-2 sm:inline-flex">
                        <span class="text-xs text-primary-foreground">{{ __('Code') }}</span>
                        <span class="inline-block rounded-sm border border-primary-foreground/25 bg-primary-foreground/10 px-2 py-0.5 font-mono text-xs font-semibold tracking-wider text-primary-foreground">{{ $code }}</span>
                        <x-ui.copy-button :value="$code" :label="__('Copy code :code', ['code' => $code])" class="text-primary-foreground hover:bg-primary-foreground/15 hover:text-primary-foreground" />
                    </span>
                @endif
                <x-ui.button :href="$ctaHref" size="sm" class="bg-background text-foreground hover:bg-background/90">
                    {{ __($ctaLabel) }}
                    <svg class="ms-2 size-4 shrink-0 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>
                </x-ui.button>
            </div>
        </div>
    </div>
</x-ui.section>

Installation

terminal
php artisan ui:add blocks/sale-banner

Installs these dependencies automatically:

Registry contract

Install confidence

php artisan ui:add blocks/sale-banner 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.1.2
License
open
Stability
stable
Contract
v1
Foundation
≥ 1.0.0
Type Generated target
blade resources/views/blocks/sale-banner.blade.php

Registry dependencies

badge button copy-button section

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.

sale-banner.md
# Brok UI block: Sale Banner (`sale-banner`)

A full-width horizontal sale strip on the primary surface with an eyebrow, headline, inline countdown chips, a discount code and a contrast call-to-action.

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/sale-banner
```

## Render it

```blade
<x-blocks.sale-banner />
```

## Props

- `eyebrow` (string, default `Flash sale`) — Small label shown above the heading.
- `headline` (string, default `Up to 50% off everything — today only`) — Promotion headline shown beside the eyebrow badge.
- `hours` (string, default `04`) — Countdown hours value.
- `minutes` (string, default `32`) — Countdown minutes value.
- `seconds` (string, default `09`) — Countdown seconds value.
- `cta-label` (string, default `Shop now`) — Call-to-action button label.
- `cta-href` (string, default `#`) — Call-to-action destination.
- `code` (string, default `FLASH50`) — Discount code shown in the strip.
- `show-code` (bool, default `true`) — Toggles whether the discount code chip renders.

## Use when

- Running a compact, full-width sale strip on the primary surface with an inline countdown and a discount code.
- Needing the promotion to sit as a slim horizontal banner rather than a dedicated section.

## Avoid when

- Wanting a large standalone promotional section; use sale-promo instead. Wanting a dismissible sticky urgency bar; use sale-countdown-bar instead.

## Rules

- Render the installed block with `<x-blocks.sale-banner />` 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/sale-banner
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/sale-banner.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

  • Running a compact, full-width sale strip on the primary surface with an inline countdown and a discount code.
  • Needing the promotion to sit as a slim horizontal banner rather than a dedicated section.

Avoid when

  • Wanting a large standalone promotional section; use sale-promo instead. Wanting a dismissible sticky urgency bar; use sale-countdown-bar instead.

Anti-patterns

  • Do not replace semantic props with conflicting utility classes.
  • Do not remove labels, focus styles, or state attributes.
Anatomy
root sale-banner

Usage

Render the block as a component, passing data where useful:

resources/views/welcome.blade.php Blade
<x-blocks.sale-banner />

Built from primitives

Composes <brok:*> Semantic tokens Re-themeable RTL-ready

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.

resources/views/blocks/sale-banner.blade.php Blade
@props([
    'eyebrow'  => 'Flash sale',
    'headline' => 'Up to 50% off everything — today only',
    'hours'    => '04',
    'minutes'  => '32',
    'seconds'  => '09',
    'ctaLabel' => 'Shop now',
    'ctaHref'  => '#',
    'code'     => 'FLASH50',
    'showCode' => true,
])

@php
    $chips = [['value' => $hours, 'aria' => __('hours')], ['value' => $minutes, 'aria' => __('minutes')], ['value' => $seconds, 'aria' => __('seconds')]];
@endphp

<x-ui.section data-slot="sale-banner" space="none" surface="primary" {{ $attributes }}>
    <div class="mx-auto max-w-7xl px-4 py-4">
        <div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
            <div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-4">
                <x-ui.badge class="w-fit border-transparent bg-primary-foreground text-primary">{{ __($eyebrow) }}</x-ui.badge>
                <p class="text-sm font-semibold leading-snug text-primary-foreground sm:text-base">{{ __($headline) }}</p>
            </div>

            <div class="flex items-center gap-2" role="timer" aria-label="{{ __('Time remaining') }}">
                @foreach ($chips as $chip)
                    <span class="inline-flex min-w-[2.25rem] items-center justify-center rounded-md border border-primary-foreground/20 bg-primary-foreground/10 px-2 py-0.5 font-mono text-xs font-bold tabular-nums text-primary-foreground" aria-label="{{ $chip['aria'] }}">{{ $chip['value'] }}</span>
                    @unless ($loop->last)<span class="select-none text-xs font-bold text-primary-foreground" aria-hidden="true">:</span>@endunless
                @endforeach
            </div>

            <div class="flex shrink-0 items-center gap-2">
                @if ($showCode && $code)
                    <span class="hidden items-center gap-2 sm:inline-flex">
                        <span class="text-xs text-primary-foreground">{{ __('Code') }}</span>
                        <span class="inline-block rounded-sm border border-primary-foreground/25 bg-primary-foreground/10 px-2 py-0.5 font-mono text-xs font-semibold tracking-wider text-primary-foreground">{{ $code }}</span>
                        <x-ui.copy-button :value="$code" :label="__('Copy code :code', ['code' => $code])" class="text-primary-foreground hover:bg-primary-foreground/15 hover:text-primary-foreground" />
                    </span>
                @endif
                <x-ui.button :href="$ctaHref" size="sm" class="bg-background text-foreground hover:bg-background/90">
                    {{ __($ctaLabel) }}
                    <svg class="ms-2 size-4 shrink-0 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>
                </x-ui.button>
            </div>
        </div>
    </div>
</x-ui.section>

Ownership & lifecycle

Owner, release state, review evidence and adoption for this item.
Owner
Platform UI (@JoshJML)
Current version
1.1.2
Status
Stable
License
open
Deprecation
Not deprecated
Contract
v1
Foundation
≥ 1.0.0