Skip to content
Brok UI

Loading…

No results

Compare Products

Open source

A three-column product comparison table with a recommended plan, per-feature check or cross indicators, and choose-plan actions.

Responsive Dark mode RTL Localized SEO

Preview

resources/views/blocks/compare-products.blade.php Blade
@props([
    'heading' => 'Compare products',
    'subheading' => 'Find the plan that scales with your store. Switch or cancel anytime, no hidden fees.',
    'products' => null,
    'features' => null,
])

@php
    // Each product column. `featured` marks the recommended, highlighted column.
    $products ??= [
        ['name' => 'Solo', 'tagline' => 'For makers shipping their first store', 'price' => '$0', 'period' => '/mo', 'cta' => 'Start free', 'featured' => false],
        ['name' => 'Growth', 'tagline' => 'For growing brands that need more room', 'price' => '$49', 'period' => '/mo', 'cta' => 'Choose Growth', 'featured' => true],
        ['name' => 'Scale', 'tagline' => 'For high-volume, multi-region sellers', 'price' => '$149', 'period' => '/mo', 'cta' => 'Choose Scale', 'featured' => false],
    ];

    // Each feature row carries a label plus one value per product column (same order as $products).
    // A boolean renders a check (true) / cross (false); a string renders inline.
    $features ??= [
        ['label' => 'Products', 'values' => ['Up to 50', 'Up to 2,500', 'Unlimited']],
        ['label' => 'Storage', 'values' => ['5 GB', '100 GB', '1 TB']],
        ['label' => 'Staff accounts', 'values' => ['1', '10', 'Unlimited']],
        ['label' => 'Transaction fee', 'values' => ['2.9%', '1.9%', '0.9%']],
        ['label' => 'Abandoned cart recovery', 'values' => [false, true, true]],
        ['label' => 'Discount codes', 'values' => [true, true, true]],
        ['label' => 'API access', 'values' => [false, true, true]],
        ['label' => 'Multi-currency checkout', 'values' => [false, false, true]],
        ['label' => 'Priority support', 'values' => [false, true, true]],
        ['label' => 'Dedicated account manager', 'values' => [false, false, true]],
    ];
@endphp

<x-ui.section
    aria-label="{{ __('Product comparison') }}"
    data-slot="compare-products"
    space="lg" {{ $attributes }}
>
    <x-ui.container gutter="sm">
        <div class="mx-auto max-w-2xl text-center">
            <h2 class="text-balance text-3xl font-bold tracking-tight sm:text-4xl">{{ __($heading) }}</h2>
            @if ($subheading)
                <p class="mt-4 text-pretty text-sm text-muted-foreground sm:text-base">{{ __($subheading) }}</p>
            @endif
        </div>

        {{-- Product header cards --}}
        <ul role="list" class="mt-10 grid grid-cols-1 gap-4 sm:grid-cols-3">
            @foreach ($products as $product)
                <li>
                    <x-ui.card @class([
                        'flex h-full flex-col gap-4 p-6 text-start',
                        'ring-1 ring-primary bg-primary/5' => $product['featured'] ?? false,
                    ])>
                        <div class="flex items-center justify-between gap-2">
                            <h3 class="text-lg font-semibold text-foreground">{{ __($product['name']) }}</h3>
                            @if ($product['featured'] ?? false)
                                <x-ui.badge>{{ __('Recommended') }}</x-ui.badge>
                            @endif
                        </div>

                        <p class="text-sm text-muted-foreground">{{ __($product['tagline']) }}</p>

                        <p class="flex items-baseline gap-2">
                            <span class="text-3xl font-bold tracking-tight text-foreground">{{ $product['price'] }}</span>
                            <span class="text-sm font-medium text-muted-foreground">{{ $product['period'] ?? '' }}</span>
                        </p>

                        <div class="mt-auto pt-2">
                            <x-ui.button
                                type="button"
                                class="w-full"
                                :variant="($product['featured'] ?? false) ? 'default' : 'outline'"
                                aria-label="{{ __('Choose the :name plan', ['name' => $product['name']]) }}"
                            >
                                {{ __($product['cta']) }}
                            </x-ui.button>
                        </div>
                    </x-ui.card>
                </li>
            @endforeach
        </ul>

        {{-- Feature-by-feature comparison --}}
        <div class="mt-6 overflow-x-auto rounded-lg border border-border shadow-sm">
            <x-ui.table class="min-w-[44rem] border-separate border-spacing-0">
                <caption class="sr-only">{{ __('Feature comparison across all plans') }}</caption>

                <x-ui.table.header>
                    <x-ui.table.row class="hover:bg-transparent">
                        <x-ui.table.head scope="col" class="w-1/3">
                            {{ __('Feature') }}
                        </x-ui.table.head>

                        @foreach ($products as $product)
                            <x-ui.table.head scope="col" @class([
                                '[width:22.222%] text-center text-sm font-semibold text-foreground',
                                'bg-primary/5' => $product['featured'] ?? false,
                            ])>
                                {{ __($product['name']) }}
                            </x-ui.table.head>
                        @endforeach
                    </x-ui.table.row>
                </x-ui.table.header>

                <x-ui.table.body>
                    @foreach ($features as $feature)
                        <x-ui.table.row class="hover:bg-transparent">
                            <x-ui.table.head scope="row" class="text-sm font-medium text-foreground">
                                {{ __($feature['label']) }}
                            </x-ui.table.head>

                            @foreach ($products as $i => $product)
                                @php $value = $feature['values'][$i] ?? false; @endphp
                                <x-ui.table.cell @class([
                                    'text-center',
                                    'bg-primary/5' => $product['featured'] ?? false,
                                ])>
                                    @if (is_string($value))
                                        <span class="text-sm text-foreground">{{ __($value) }}</span>
                                    @elseif ($value)
                                        <svg class="mx-auto size-5 text-success" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
                                            <path fill-rule="evenodd" d="M16.7 5.3a1 1 0 010 1.4l-7.5 7.5a1 1 0 01-1.4 0L3.3 9.7a1 1 0 011.4-1.4l3.3 3.29 6.8-6.8a1 1 0 011.4 0z" clip-rule="evenodd" />
                                        </svg>
                                        <span class="sr-only">{{ __('Included') }}</span>
                                    @else
                                        <svg class="mx-auto size-5 text-muted-foreground" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
                                            <path d="M6 6l8 8M14 6l-8 8" />
                                        </svg>
                                        <span class="sr-only">{{ __('Not included') }}</span>
                                    @endif
                                </x-ui.table.cell>
                            @endforeach
                        </x-ui.table.row>
                    @endforeach
                </x-ui.table.body>
            </x-ui.table>
        </div>
    </x-ui.container>
</x-ui.section>

Installation

terminal
php artisan ui:add blocks/compare-products

Installs these dependencies automatically:

Registry contract

Install confidence

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

Registry dependencies

badge button card container section table

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.

compare-products.md
# Brok UI block: Compare Products (`compare-products`)

A three-column product comparison table with a recommended plan, per-feature check or cross indicators, and choose-plan actions.

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/compare-products
```

## Render it

```blade
<x-blocks.compare-products />
```

## Props

- `heading` (string, default `Compare products`)
- `subheading` (string, default `Find the plan that scales with your store. Switch or cancel anytime, no hidden fees.`)
- `products` (mixed|null, default `null`)
- `features` (mixed|null, default `null`)

## Use when

- Comparing three product or plan tiers in a table with per-feature check/cross marks and a highlighted recommended column.
- Closing each column with its own choose-plan action beneath the feature rows.

## Avoid when

- Use comparison-competitor-table through comparison-toggle to compare against a named competitor rather than your own product tiers.

## Rules

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

  • Comparing three product or plan tiers in a table with per-feature check/cross marks and a highlighted recommended column.
  • Closing each column with its own choose-plan action beneath the feature rows.

Avoid when

  • Use comparison-competitor-table through comparison-toggle to compare against a named competitor rather than your own product tiers.

Anti-patterns

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

Usage

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

resources/views/welcome.blade.php Blade
<x-blocks.compare-products />

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/compare-products.blade.php Blade
@props([
    'heading' => 'Compare products',
    'subheading' => 'Find the plan that scales with your store. Switch or cancel anytime, no hidden fees.',
    'products' => null,
    'features' => null,
])

@php
    // Each product column. `featured` marks the recommended, highlighted column.
    $products ??= [
        ['name' => 'Solo', 'tagline' => 'For makers shipping their first store', 'price' => '$0', 'period' => '/mo', 'cta' => 'Start free', 'featured' => false],
        ['name' => 'Growth', 'tagline' => 'For growing brands that need more room', 'price' => '$49', 'period' => '/mo', 'cta' => 'Choose Growth', 'featured' => true],
        ['name' => 'Scale', 'tagline' => 'For high-volume, multi-region sellers', 'price' => '$149', 'period' => '/mo', 'cta' => 'Choose Scale', 'featured' => false],
    ];

    // Each feature row carries a label plus one value per product column (same order as $products).
    // A boolean renders a check (true) / cross (false); a string renders inline.
    $features ??= [
        ['label' => 'Products', 'values' => ['Up to 50', 'Up to 2,500', 'Unlimited']],
        ['label' => 'Storage', 'values' => ['5 GB', '100 GB', '1 TB']],
        ['label' => 'Staff accounts', 'values' => ['1', '10', 'Unlimited']],
        ['label' => 'Transaction fee', 'values' => ['2.9%', '1.9%', '0.9%']],
        ['label' => 'Abandoned cart recovery', 'values' => [false, true, true]],
        ['label' => 'Discount codes', 'values' => [true, true, true]],
        ['label' => 'API access', 'values' => [false, true, true]],
        ['label' => 'Multi-currency checkout', 'values' => [false, false, true]],
        ['label' => 'Priority support', 'values' => [false, true, true]],
        ['label' => 'Dedicated account manager', 'values' => [false, false, true]],
    ];
@endphp

<x-ui.section
    aria-label="{{ __('Product comparison') }}"
    data-slot="compare-products"
    space="lg" {{ $attributes }}
>
    <x-ui.container gutter="sm">
        <div class="mx-auto max-w-2xl text-center">
            <h2 class="text-balance text-3xl font-bold tracking-tight sm:text-4xl">{{ __($heading) }}</h2>
            @if ($subheading)
                <p class="mt-4 text-pretty text-sm text-muted-foreground sm:text-base">{{ __($subheading) }}</p>
            @endif
        </div>

        {{-- Product header cards --}}
        <ul role="list" class="mt-10 grid grid-cols-1 gap-4 sm:grid-cols-3">
            @foreach ($products as $product)
                <li>
                    <x-ui.card @class([
                        'flex h-full flex-col gap-4 p-6 text-start',
                        'ring-1 ring-primary bg-primary/5' => $product['featured'] ?? false,
                    ])>
                        <div class="flex items-center justify-between gap-2">
                            <h3 class="text-lg font-semibold text-foreground">{{ __($product['name']) }}</h3>
                            @if ($product['featured'] ?? false)
                                <x-ui.badge>{{ __('Recommended') }}</x-ui.badge>
                            @endif
                        </div>

                        <p class="text-sm text-muted-foreground">{{ __($product['tagline']) }}</p>

                        <p class="flex items-baseline gap-2">
                            <span class="text-3xl font-bold tracking-tight text-foreground">{{ $product['price'] }}</span>
                            <span class="text-sm font-medium text-muted-foreground">{{ $product['period'] ?? '' }}</span>
                        </p>

                        <div class="mt-auto pt-2">
                            <x-ui.button
                                type="button"
                                class="w-full"
                                :variant="($product['featured'] ?? false) ? 'default' : 'outline'"
                                aria-label="{{ __('Choose the :name plan', ['name' => $product['name']]) }}"
                            >
                                {{ __($product['cta']) }}
                            </x-ui.button>
                        </div>
                    </x-ui.card>
                </li>
            @endforeach
        </ul>

        {{-- Feature-by-feature comparison --}}
        <div class="mt-6 overflow-x-auto rounded-lg border border-border shadow-sm">
            <x-ui.table class="min-w-[44rem] border-separate border-spacing-0">
                <caption class="sr-only">{{ __('Feature comparison across all plans') }}</caption>

                <x-ui.table.header>
                    <x-ui.table.row class="hover:bg-transparent">
                        <x-ui.table.head scope="col" class="w-1/3">
                            {{ __('Feature') }}
                        </x-ui.table.head>

                        @foreach ($products as $product)
                            <x-ui.table.head scope="col" @class([
                                '[width:22.222%] text-center text-sm font-semibold text-foreground',
                                'bg-primary/5' => $product['featured'] ?? false,
                            ])>
                                {{ __($product['name']) }}
                            </x-ui.table.head>
                        @endforeach
                    </x-ui.table.row>
                </x-ui.table.header>

                <x-ui.table.body>
                    @foreach ($features as $feature)
                        <x-ui.table.row class="hover:bg-transparent">
                            <x-ui.table.head scope="row" class="text-sm font-medium text-foreground">
                                {{ __($feature['label']) }}
                            </x-ui.table.head>

                            @foreach ($products as $i => $product)
                                @php $value = $feature['values'][$i] ?? false; @endphp
                                <x-ui.table.cell @class([
                                    'text-center',
                                    'bg-primary/5' => $product['featured'] ?? false,
                                ])>
                                    @if (is_string($value))
                                        <span class="text-sm text-foreground">{{ __($value) }}</span>
                                    @elseif ($value)
                                        <svg class="mx-auto size-5 text-success" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
                                            <path fill-rule="evenodd" d="M16.7 5.3a1 1 0 010 1.4l-7.5 7.5a1 1 0 01-1.4 0L3.3 9.7a1 1 0 011.4-1.4l3.3 3.29 6.8-6.8a1 1 0 011.4 0z" clip-rule="evenodd" />
                                        </svg>
                                        <span class="sr-only">{{ __('Included') }}</span>
                                    @else
                                        <svg class="mx-auto size-5 text-muted-foreground" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
                                            <path d="M6 6l8 8M14 6l-8 8" />
                                        </svg>
                                        <span class="sr-only">{{ __('Not included') }}</span>
                                    @endif
                                </x-ui.table.cell>
                            @endforeach
                        </x-ui.table.row>
                    @endforeach
                </x-ui.table.body>
            </x-ui.table>
        </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.6
Status
Stable
License
open
Deprecation
Not deprecated
Contract
v1
Foundation
≥ 1.0.0