Skip to content
Brok UI

Loading…

No results

Blog

Open source

Blog sections — a dashed list, a card grid (with an optional image panel), a magazine layout and a single-article post header.

Preview

1 of 6

resources/views/blocks/blog-image-grid.blade.php Blade
@props([
    'heading' => 'From the blog',
    'subheading' => 'Guides, deep dives, and product updates from the team.',
    'posts' => null,
    'media' => true,
])

@php
    $posts ??= [
        [
            'category' => 'Engineering',
            'title' => 'Building a token-driven design system',
            'excerpt' => 'How we ship light, dark, and per-surface themes by editing CSS variables only — never the components.',
            'author' => 'Avery Quinn',
            'initials' => 'AQ',
            'readTime' => '6 min read',
            'href' => '#',
        ],
        [
            'category' => 'Product',
            'title' => 'Own your UI: copy-in, no lock-in',
            'excerpt' => 'Why we copy plain Blade into your project instead of shipping a runtime dependency you can never edit.',
            'author' => 'Jordan Lee',
            'initials' => 'JL',
            'readTime' => '4 min read',
            'href' => '#',
        ],
        [
            'category' => 'Accessibility',
            'title' => 'Designing for WCAG 2.2 AA from day one',
            'excerpt' => 'Keyboard support, focus-visible states, RTL-safe layout, and reduced motion baked into every primitive.',
            'author' => 'Sam Rivera',
            'initials' => 'SR',
            'readTime' => '8 min read',
            'href' => '#',
        ],
    ];
@endphp

<x-ui.section data-slot="blog-03" space="xl" {{ $attributes }}>
    <x-ui.container gutter="sm">
        <x-ui.section-heading align="start" :title="$heading" :subtitle="$subheading" />

        <div class="mt-12 grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3">
            @foreach ($posts as $post)
                <article class="relative h-full">
                    <x-ui.card @class([
                        'group flex h-full flex-col transition-all duration-200 hover:shadow-md',
                        'overflow-hidden p-0' => $media,
                        'p-6 hover:-translate-y-1 hover:border-primary/40 focus-within:border-primary/40' => ! $media,
                    ])>
                        @if ($media)
                            <a href="{{ $post['href'] }}" class="relative block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background">
                                <x-ui.aspect-ratio ratio="16 / 9">
                                    <div class="size-full bg-gradient-to-br from-primary/20 via-muted to-background transition-transform duration-300 group-hover:scale-105" aria-hidden="true"></div>
                                </x-ui.aspect-ratio>
                                <x-ui.badge variant="secondary" class="absolute start-3 top-3 shadow-sm">
                                    {{ __($post['category']) }}
                                </x-ui.badge>
                            </a>
                        @endif

                        <div @class(['flex flex-1 flex-col', 'p-6' => $media])>
                            @unless ($media)
                                <div class="flex items-center gap-2">
                                    <x-ui.badge variant="secondary">{{ __($post['category']) }}</x-ui.badge>
                                </div>
                            @endunless

                            <h3 @class(['text-lg font-semibold tracking-tight', 'leading-snug' => $media, 'mt-4' => ! $media])>
                                @if ($media)
                                    <a href="{{ $post['href'] }}" class="transition-colors hover:text-link focus-visible:text-link focus-visible:outline-none">
                                        {{ __($post['title']) }}
                                    </a>
                                @else
                                    <a
                                        href="{{ $post['href'] }}"
                                        class="text-balance outline-none transition-colors after:absolute after:inset-0 hover:text-primary focus-visible:text-primary"
                                    >
                                        {{ __($post['title']) }}
                                    </a>
                                @endif
                            </h3>

                            <p class="mt-2 flex-1 text-pretty text-sm text-muted-foreground">
                                {{ __($post['excerpt']) }}
                            </p>

                            <div class="mt-6 flex items-center gap-4 border-t border-border pt-4">
                                <x-ui.avatar size="sm" :alt="$post['author']" :fallback="$post['initials']" />
                                <div class="min-w-0 text-sm">
                                    <p class="truncate font-medium text-foreground">{{ $post['author'] }}</p>
                                    @if (! empty($post['readTime']))
                                        <p class="truncate text-muted-foreground">{{ __($post['readTime']) }}</p>
                                    @elseif (! empty($post['datetime']))
                                        <time datetime="{{ $post['datetime'] }}" class="text-muted-foreground">{{ __($post['date']) }}</time>
                                    @endif
                                </div>
                            </div>
                        </div>
                    </x-ui.card>
                </article>
            @endforeach
        </div>
    </x-ui.container>
</x-ui.section>

Installation

terminal
php artisan ui:add blocks/blog-image-grid

Registry contract

Install confidence

php artisan ui:add blocks/blog-image-grid 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/blog-image-grid.blade.php

Registry dependencies

aspect-ratio avatar badge card 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.

blog-image-grid.md
# Brok UI block: Blog Image Grid (`blog-image-grid`)

A responsive blog grid of cards, each with an optional 16/9 gradient panel and overlaid category badge (or an in-body category badge), title, excerpt, and an author avatar with read time or date.

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/blog-image-grid
```

## Render it

```blade
<x-blocks.blog-image-grid media="true" />
```

## Props

- `media` (boolean, default `true`) (variant) — true renders a 16/9 gradient media panel with an overlaid category badge; false renders a plain bordered card with an in-body category badge and a whole-card title link.

## Use when

- Listing blog posts as a responsive grid of cards, each with an optional gradient media panel and category badge.
- Toggling the media prop to switch between an image-led card and a plain bordered text card.

## Avoid when

- Use blog-list for a single dashed-divider list, or blog-magazine/blog-featured for a magazine layout with a featured post.

## Rules

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

  • Listing blog posts as a responsive grid of cards, each with an optional gradient media panel and category badge.
  • Toggling the media prop to switch between an image-led card and a plain bordered text card.

Avoid when

  • Use blog-list for a single dashed-divider list, or blog-magazine/blog-featured for a magazine layout with a featured post.

Anti-patterns

  • Do not replace semantic props with conflicting utility classes.
  • Do not remove labels, focus styles, or state attributes.

Usage

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

resources/views/welcome.blade.php Blade
<x-blocks.blog-image-grid />

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/blog-image-grid.blade.php Blade
@props([
    'heading' => 'From the blog',
    'subheading' => 'Guides, deep dives, and product updates from the team.',
    'posts' => null,
    'media' => true,
])

@php
    $posts ??= [
        [
            'category' => 'Engineering',
            'title' => 'Building a token-driven design system',
            'excerpt' => 'How we ship light, dark, and per-surface themes by editing CSS variables only — never the components.',
            'author' => 'Avery Quinn',
            'initials' => 'AQ',
            'readTime' => '6 min read',
            'href' => '#',
        ],
        [
            'category' => 'Product',
            'title' => 'Own your UI: copy-in, no lock-in',
            'excerpt' => 'Why we copy plain Blade into your project instead of shipping a runtime dependency you can never edit.',
            'author' => 'Jordan Lee',
            'initials' => 'JL',
            'readTime' => '4 min read',
            'href' => '#',
        ],
        [
            'category' => 'Accessibility',
            'title' => 'Designing for WCAG 2.2 AA from day one',
            'excerpt' => 'Keyboard support, focus-visible states, RTL-safe layout, and reduced motion baked into every primitive.',
            'author' => 'Sam Rivera',
            'initials' => 'SR',
            'readTime' => '8 min read',
            'href' => '#',
        ],
    ];
@endphp

<x-ui.section data-slot="blog-03" space="xl" {{ $attributes }}>
    <x-ui.container gutter="sm">
        <x-ui.section-heading align="start" :title="$heading" :subtitle="$subheading" />

        <div class="mt-12 grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3">
            @foreach ($posts as $post)
                <article class="relative h-full">
                    <x-ui.card @class([
                        'group flex h-full flex-col transition-all duration-200 hover:shadow-md',
                        'overflow-hidden p-0' => $media,
                        'p-6 hover:-translate-y-1 hover:border-primary/40 focus-within:border-primary/40' => ! $media,
                    ])>
                        @if ($media)
                            <a href="{{ $post['href'] }}" class="relative block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background">
                                <x-ui.aspect-ratio ratio="16 / 9">
                                    <div class="size-full bg-gradient-to-br from-primary/20 via-muted to-background transition-transform duration-300 group-hover:scale-105" aria-hidden="true"></div>
                                </x-ui.aspect-ratio>
                                <x-ui.badge variant="secondary" class="absolute start-3 top-3 shadow-sm">
                                    {{ __($post['category']) }}
                                </x-ui.badge>
                            </a>
                        @endif

                        <div @class(['flex flex-1 flex-col', 'p-6' => $media])>
                            @unless ($media)
                                <div class="flex items-center gap-2">
                                    <x-ui.badge variant="secondary">{{ __($post['category']) }}</x-ui.badge>
                                </div>
                            @endunless

                            <h3 @class(['text-lg font-semibold tracking-tight', 'leading-snug' => $media, 'mt-4' => ! $media])>
                                @if ($media)
                                    <a href="{{ $post['href'] }}" class="transition-colors hover:text-link focus-visible:text-link focus-visible:outline-none">
                                        {{ __($post['title']) }}
                                    </a>
                                @else
                                    <a
                                        href="{{ $post['href'] }}"
                                        class="text-balance outline-none transition-colors after:absolute after:inset-0 hover:text-primary focus-visible:text-primary"
                                    >
                                        {{ __($post['title']) }}
                                    </a>
                                @endif
                            </h3>

                            <p class="mt-2 flex-1 text-pretty text-sm text-muted-foreground">
                                {{ __($post['excerpt']) }}
                            </p>

                            <div class="mt-6 flex items-center gap-4 border-t border-border pt-4">
                                <x-ui.avatar size="sm" :alt="$post['author']" :fallback="$post['initials']" />
                                <div class="min-w-0 text-sm">
                                    <p class="truncate font-medium text-foreground">{{ $post['author'] }}</p>
                                    @if (! empty($post['readTime']))
                                        <p class="truncate text-muted-foreground">{{ __($post['readTime']) }}</p>
                                    @elseif (! empty($post['datetime']))
                                        <time datetime="{{ $post['datetime'] }}" class="text-muted-foreground">{{ __($post['date']) }}</time>
                                    @endif
                                </div>
                            </div>
                        </div>
                    </x-ui.card>
                </article>
            @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.1.2
Status
Stable
License
open
Deprecation
Not deprecated
Contract
v1
Foundation
≥ 1.0.0