Skip to content
Brok UI

Loading…

No results

FAQ

Open source

Frequently-asked-question sections — an accordion, a two-column split, a static grid and grouped categories.

Preview

4 of 8

resources/views/blocks/faq-categories.blade.php Blade
@props([
    'heading' => 'Frequently asked questions',
    'subheading' => 'Browse common questions by topic. Still stuck? Reach out and our team will help.',
    'categories' => null,
])

@php
    $categories ??= [
        [
            'label' => 'Getting started',
            'items' => [
                ['question' => 'How do I install a component?', 'answer' => 'Run the add command for any item and the source is copied into your project as plain Blade. There is no runtime dependency once the code lives in your app.'],
                ['question' => 'Do I need a build step?', 'answer' => 'Static blocks render as-is. Interactive items ship their own JS, which is wired into your bundle automatically when you add them.'],
                ['question' => 'Can I edit the installed files?', 'answer' => 'Yes. Everything you install is yours to own and change. Edited files are never overwritten on update — you get a reviewable diff instead.'],
            ],
        ],
        [
            'label' => 'Billing & plans',
            'items' => [
                ['question' => 'Is there a free tier?', 'answer' => 'The open core is free and MIT licensed. Pro items require a license and unlock additional blocks and admin tooling.'],
                ['question' => 'How does billing work?', 'answer' => 'Plans are billed monthly or annually. You can upgrade, downgrade, or cancel at any time from your account settings.'],
                ['question' => 'Can I get a refund?', 'answer' => 'If the product is not a fit, contact support within 14 days of purchase and we will issue a full refund.'],
            ],
        ],
        [
            'label' => 'Theming & accessibility',
            'items' => [
                ['question' => 'How do I re-theme the system?', 'answer' => 'The entire system is driven by CSS design tokens. Override the variables to retheme light, dark, and per-surface variants without touching component markup.'],
                ['question' => 'Is it accessible?', 'answer' => 'Components target WCAG 2.2 AA: keyboard support, focus-visible states, ARIA wiring, reduced motion, and RTL-safe layout.'],
            ],
        ],
    ];
@endphp

<x-ui.section space="xl" {{ $attributes }}>
    <div class="mx-auto max-w-3xl px-4">
        <div class="text-center">
            <h2 class="text-3xl font-bold tracking-tight sm:text-4xl">{{ __($heading) }}</h2>
            <p class="mx-auto mt-4 max-w-2xl text-lg text-muted-foreground">{{ __($subheading) }}</p>
        </div>

        <div class="mt-12 space-y-12 sm:mt-16 sm:space-y-16">
            @foreach ($categories as $c => $category)
                <div>
                    <div class="flex items-center gap-4">
                        <x-ui.badge variant="secondary">{{ __($category['label']) }}</x-ui.badge>
                        <span class="h-px flex-1 bg-border" aria-hidden="true"></span>
                    </div>

                    <x-ui.accordion class="mt-6">
                        @foreach ($category['items'] as $i => $item)
                            <x-ui.accordion.item :value="'faq-'.$c.'-'.$i">
                                <x-ui.accordion.trigger class="text-start">{{ __($item['question']) }}</x-ui.accordion.trigger>
                                <x-ui.accordion.content>{{ __($item['answer']) }}</x-ui.accordion.content>
                            </x-ui.accordion.item>
                        @endforeach
                    </x-ui.accordion>
                </div>
            @endforeach
        </div>
    </div>
</x-ui.section>

Installation

terminal
php artisan ui:add blocks/faq-categories

Installs these dependencies automatically:

Registry contract

Install confidence

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

Registry dependencies

accordion badge 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.

faq-categories.md
# Brok UI block: FAQ Categories (`faq-categories`)

A centered FAQ section that groups questions into labelled categories, each rendered as its own accordion stacked with generous spacing.

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/faq-categories
```

## Render it

```blade
<x-blocks.faq-categories />
```

## Props

- `heading` (string, default `Frequently asked questions`)
- `subheading` (string, default `Browse common questions by topic. Still stuck? Reach out and our team will help.`)
- `categories` (mixed|null, default `null`)

## Use when

- Grouping questions into labelled categories, each rendered as its own accordion, for a longer FAQ set.
- Helping a visitor scan topics before opening the category that matters to them.

## Avoid when

- Use faq-accordion for a single ungrouped accordion, or faq-search for a searchable FAQ with grouped questions.

## Rules

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

  • Grouping questions into labelled categories, each rendered as its own accordion, for a longer FAQ set.
  • Helping a visitor scan topics before opening the category that matters to them.

Avoid when

  • Use faq-accordion for a single ungrouped accordion, or faq-search for a searchable FAQ with grouped questions.

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.faq-categories />

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/faq-categories.blade.php Blade
@props([
    'heading' => 'Frequently asked questions',
    'subheading' => 'Browse common questions by topic. Still stuck? Reach out and our team will help.',
    'categories' => null,
])

@php
    $categories ??= [
        [
            'label' => 'Getting started',
            'items' => [
                ['question' => 'How do I install a component?', 'answer' => 'Run the add command for any item and the source is copied into your project as plain Blade. There is no runtime dependency once the code lives in your app.'],
                ['question' => 'Do I need a build step?', 'answer' => 'Static blocks render as-is. Interactive items ship their own JS, which is wired into your bundle automatically when you add them.'],
                ['question' => 'Can I edit the installed files?', 'answer' => 'Yes. Everything you install is yours to own and change. Edited files are never overwritten on update — you get a reviewable diff instead.'],
            ],
        ],
        [
            'label' => 'Billing & plans',
            'items' => [
                ['question' => 'Is there a free tier?', 'answer' => 'The open core is free and MIT licensed. Pro items require a license and unlock additional blocks and admin tooling.'],
                ['question' => 'How does billing work?', 'answer' => 'Plans are billed monthly or annually. You can upgrade, downgrade, or cancel at any time from your account settings.'],
                ['question' => 'Can I get a refund?', 'answer' => 'If the product is not a fit, contact support within 14 days of purchase and we will issue a full refund.'],
            ],
        ],
        [
            'label' => 'Theming & accessibility',
            'items' => [
                ['question' => 'How do I re-theme the system?', 'answer' => 'The entire system is driven by CSS design tokens. Override the variables to retheme light, dark, and per-surface variants without touching component markup.'],
                ['question' => 'Is it accessible?', 'answer' => 'Components target WCAG 2.2 AA: keyboard support, focus-visible states, ARIA wiring, reduced motion, and RTL-safe layout.'],
            ],
        ],
    ];
@endphp

<x-ui.section space="xl" {{ $attributes }}>
    <div class="mx-auto max-w-3xl px-4">
        <div class="text-center">
            <h2 class="text-3xl font-bold tracking-tight sm:text-4xl">{{ __($heading) }}</h2>
            <p class="mx-auto mt-4 max-w-2xl text-lg text-muted-foreground">{{ __($subheading) }}</p>
        </div>

        <div class="mt-12 space-y-12 sm:mt-16 sm:space-y-16">
            @foreach ($categories as $c => $category)
                <div>
                    <div class="flex items-center gap-4">
                        <x-ui.badge variant="secondary">{{ __($category['label']) }}</x-ui.badge>
                        <span class="h-px flex-1 bg-border" aria-hidden="true"></span>
                    </div>

                    <x-ui.accordion class="mt-6">
                        @foreach ($category['items'] as $i => $item)
                            <x-ui.accordion.item :value="'faq-'.$c.'-'.$i">
                                <x-ui.accordion.trigger class="text-start">{{ __($item['question']) }}</x-ui.accordion.trigger>
                                <x-ui.accordion.content>{{ __($item['answer']) }}</x-ui.accordion.content>
                            </x-ui.accordion.item>
                        @endforeach
                    </x-ui.accordion>
                </div>
            @endforeach
        </div>
    </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