Skip to content
Brok UI

Loading…

No results

Gallery

Open source

Image galleries — a masonry wall and a uniform grid with a lightbox.

Preview

1 of 6

resources/views/blocks/gallery-masonry.blade.php Blade
@props([
    'eyebrow' => 'Gallery',
    'heading' => 'Moments from the studio',
    'subheading' => 'A masonry-style collection of work, captured across projects and seasons.',
    'items' => null,
])

@php
    $items ??= [
        ['title' => 'Sunrise sessions', 'caption' => 'Early light over the harbour', 'gradient' => 'from-primary/25 via-muted to-background', 'span' => 'tall'],
        ['title' => 'Quiet corners', 'caption' => 'Interior study, north wing', 'gradient' => 'from-secondary via-muted to-background', 'span' => 'square'],
        ['title' => 'On location', 'caption' => 'Field work, late autumn', 'gradient' => 'from-muted via-secondary to-background', 'span' => 'wide'],
        ['title' => 'The long road', 'caption' => 'Roadside, somewhere north', 'gradient' => 'from-primary/20 via-background to-muted', 'span' => 'short'],
        ['title' => 'After hours', 'caption' => 'City lights, blue hour', 'gradient' => 'from-muted via-primary/15 to-background', 'span' => 'tall'],
        ['title' => 'Textures', 'caption' => 'Material studies, close up', 'gradient' => 'from-secondary via-muted to-primary/10', 'span' => 'square'],
        ['title' => 'In motion', 'caption' => 'Movement on the platform', 'gradient' => 'from-primary/15 via-muted to-background', 'span' => 'short'],
        ['title' => 'Open water', 'caption' => 'Coastline at golden hour', 'gradient' => 'from-muted via-secondary to-primary/15', 'span' => 'wide'],
    ];

    $tileHeights = [
        'tall' => 'h-80 sm:h-96',
        'short' => 'h-52 sm:h-60',
        'square' => 'h-64',
    ];
@endphp

<x-ui.section space="xl" {{ $attributes }}>
    <x-ui.container gutter="sm">
        <x-ui.section-heading align="center" overline-style="badge" :overline="$eyebrow" :title="$heading" :subtitle="$subheading" />

        <div class="mt-12 columns-2 gap-4 md:columns-3 lg:columns-4">
            @foreach ($items as $item)
                <figure class="group relative mb-4 break-inside-avoid overflow-hidden rounded-lg border border-border shadow-sm transition-transform duration-300 ease-out hover:scale-[1.02] focus-within:scale-[1.02]">
                    @if (($item['span'] ?? 'square') === 'wide')
                        <x-ui.aspect-ratio ratio="4 / 3">
                            <div class="size-full bg-gradient-to-br {{ $item['gradient'] ?? 'from-muted via-secondary to-background' }}" aria-hidden="true"></div>
                        </x-ui.aspect-ratio>
                    @else
                        <div class="w-full bg-gradient-to-br {{ $tileHeights[$item['span'] ?? 'square'] ?? $tileHeights['square'] }} {{ $item['gradient'] ?? 'from-muted via-secondary to-background' }}" aria-hidden="true"></div>
                    @endif

                    <figcaption class="pointer-events-none absolute inset-x-0 bottom-0 flex flex-col bg-gradient-to-t from-background/80 via-background/40 to-transparent p-4 text-start opacity-0 transition-opacity duration-300 group-hover:opacity-100 group-focus-within:opacity-100">
                        <span class="text-sm font-semibold text-foreground">{{ __($item['title']) }}</span>
                        @if (! empty($item['caption']))
                            <span class="mt-0.5 text-sm text-muted-foreground">{{ __($item['caption']) }}</span>
                        @endif
                    </figcaption>
                </figure>
            @endforeach
        </div>
    </x-ui.container>
</x-ui.section>

Installation

terminal
php artisan ui:add blocks/gallery-masonry

Installs these dependencies automatically:

Registry contract

Install confidence

php artisan ui:add blocks/gallery-masonry 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/gallery-masonry.blade.php

Registry dependencies

aspect-ratio badge container section section-heading

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.

gallery-masonry.md
# Brok UI block: Gallery Masonry (`gallery-masonry`)

A CSS-columns masonry image gallery with an eyebrow badge, heading, and varying-height tiles that reveal a caption overlay on hover.

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/gallery-masonry
```

## Render it

```blade
<x-blocks.gallery-masonry />
```

## Props

- `eyebrow` (string, default `Gallery`) — Small badge label shown above the heading.
- `heading` (string, default `Moments from the studio`) — Main section heading text.
- `subheading` (string, default `A masonry-style collection of work, captured across projects and seasons.`) — Supporting subheading text below the heading.
- `items` (mixed|null, default `null`) — Array of gallery items ({title, caption, gradient, span}); defaults to a built-in set of eight sample tiles.

## Use when

- Showcasing a broad set of images in an editorial masonry layout with varying tile heights.
- Revealing a title and caption on hover or focus without navigating away from the grid.

## Avoid when

- Use gallery-grid instead when each image should open in a full-size lightbox dialog.

## Rules

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

  • Showcasing a broad set of images in an editorial masonry layout with varying tile heights.
  • Revealing a title and caption on hover or focus without navigating away from the grid.

Avoid when

  • Use gallery-grid instead when each image should open in a full-size lightbox dialog.

Anti-patterns

  • Do not replace semantic props with conflicting utility classes.
  • Do not remove labels, focus styles, or state attributes.
Anatomy
eyebrow badge heading masonry grid image tile hover caption overlay

Usage

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

resources/views/welcome.blade.php Blade
<x-blocks.gallery-masonry />

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/gallery-masonry.blade.php Blade
@props([
    'eyebrow' => 'Gallery',
    'heading' => 'Moments from the studio',
    'subheading' => 'A masonry-style collection of work, captured across projects and seasons.',
    'items' => null,
])

@php
    $items ??= [
        ['title' => 'Sunrise sessions', 'caption' => 'Early light over the harbour', 'gradient' => 'from-primary/25 via-muted to-background', 'span' => 'tall'],
        ['title' => 'Quiet corners', 'caption' => 'Interior study, north wing', 'gradient' => 'from-secondary via-muted to-background', 'span' => 'square'],
        ['title' => 'On location', 'caption' => 'Field work, late autumn', 'gradient' => 'from-muted via-secondary to-background', 'span' => 'wide'],
        ['title' => 'The long road', 'caption' => 'Roadside, somewhere north', 'gradient' => 'from-primary/20 via-background to-muted', 'span' => 'short'],
        ['title' => 'After hours', 'caption' => 'City lights, blue hour', 'gradient' => 'from-muted via-primary/15 to-background', 'span' => 'tall'],
        ['title' => 'Textures', 'caption' => 'Material studies, close up', 'gradient' => 'from-secondary via-muted to-primary/10', 'span' => 'square'],
        ['title' => 'In motion', 'caption' => 'Movement on the platform', 'gradient' => 'from-primary/15 via-muted to-background', 'span' => 'short'],
        ['title' => 'Open water', 'caption' => 'Coastline at golden hour', 'gradient' => 'from-muted via-secondary to-primary/15', 'span' => 'wide'],
    ];

    $tileHeights = [
        'tall' => 'h-80 sm:h-96',
        'short' => 'h-52 sm:h-60',
        'square' => 'h-64',
    ];
@endphp

<x-ui.section space="xl" {{ $attributes }}>
    <x-ui.container gutter="sm">
        <x-ui.section-heading align="center" overline-style="badge" :overline="$eyebrow" :title="$heading" :subtitle="$subheading" />

        <div class="mt-12 columns-2 gap-4 md:columns-3 lg:columns-4">
            @foreach ($items as $item)
                <figure class="group relative mb-4 break-inside-avoid overflow-hidden rounded-lg border border-border shadow-sm transition-transform duration-300 ease-out hover:scale-[1.02] focus-within:scale-[1.02]">
                    @if (($item['span'] ?? 'square') === 'wide')
                        <x-ui.aspect-ratio ratio="4 / 3">
                            <div class="size-full bg-gradient-to-br {{ $item['gradient'] ?? 'from-muted via-secondary to-background' }}" aria-hidden="true"></div>
                        </x-ui.aspect-ratio>
                    @else
                        <div class="w-full bg-gradient-to-br {{ $tileHeights[$item['span'] ?? 'square'] ?? $tileHeights['square'] }} {{ $item['gradient'] ?? 'from-muted via-secondary to-background' }}" aria-hidden="true"></div>
                    @endif

                    <figcaption class="pointer-events-none absolute inset-x-0 bottom-0 flex flex-col bg-gradient-to-t from-background/80 via-background/40 to-transparent p-4 text-start opacity-0 transition-opacity duration-300 group-hover:opacity-100 group-focus-within:opacity-100">
                        <span class="text-sm font-semibold text-foreground">{{ __($item['title']) }}</span>
                        @if (! empty($item['caption']))
                            <span class="mt-0.5 text-sm text-muted-foreground">{{ __($item['caption']) }}</span>
                        @endif
                    </figcaption>
                </figure>
            @endforeach
        </div>
    </x-ui.container>
</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