Skip to content
Brok UI

Loading…

No results

Schema Builder

Pro

Visually build a JSON Schema for document extraction with nested fields, types, and a live preview.

Version
v1.1.0
Stability
stable
License
Commercial license
Related
Document Frame
Form

Preview

Invoice

JSON Schema

JSON Schema

{
  "type": "object",
  "properties": {}
}
previews.components.schema-builder.default.blade.php Blade
@php
    $fields = [
        ['name' => 'invoice_number', 'type' => 'string', 'required' => true, 'description' => 'The invoice identifier'],
        ['name' => 'total', 'type' => 'number', 'required' => true, 'description' => 'Grand total amount'],
        [
            'name' => 'vendor',
            'type' => 'object',
            'required' => true,
            'description' => 'Vendor details',
            'children' => [
                ['name' => 'name', 'type' => 'string', 'required' => true, 'description' => 'Vendor name'],
                ['name' => 'address', 'type' => 'string', 'required' => false, 'description' => 'Billing address'],
            ],
        ],
        [
            'name' => 'line_items',
            'type' => 'array',
            'required' => false,
            'description' => 'Itemized charges',
            'children' => [
                ['name' => 'description', 'type' => 'string', 'required' => true],
                ['name' => 'amount', 'type' => 'number', 'required' => true],
                ['name' => 'quantity', 'type' => 'integer', 'required' => false],
            ],
        ],
    ];
@endphp

<div class="mx-auto w-full max-w-2xl">
    <x-ui.schema-builder :fields="$fields" title="Invoice" />
</div>

Installation

terminal
php artisan ui:add pro/schema-builder

Note

This component ships an Alpine behavior module at resources/js/ui/schema-builder.js. Import it once from your bundle so it registers on alpine:init:

resources/js/ui/index.js JS
import './schema-builder.js';

Use with AI

A brief for your coding agent: install command, usage, props, guidance and the rules. Copy it, or open a prompt about this component in an assistant.

schema-builder.md
# Brok UI: Schema Builder (`schema-builder`)

Visually build a JSON Schema for document extraction with nested fields, types, and a live preview.

Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.

## Install

```bash
php artisan ui:add pro/schema-builder
```

## Usage

```blade
@php
    $fields = [
        ['name' => 'invoice_number', 'type' => 'string', 'required' => true, 'description' => 'The invoice identifier'],
        ['name' => 'total', 'type' => 'number', 'required' => true, 'description' => 'Grand total amount'],
        [
            'name' => 'vendor',
            'type' => 'object',
            'required' => true,
            'description' => 'Vendor details',
            'children' => [
                ['name' => 'name', 'type' => 'string', 'required' => true, 'description' => 'Vendor name'],
                ['name' => 'address', 'type' => 'string', 'required' => false, 'description' => 'Billing address'],
            ],
        ],
        [
            'name' => 'line_items',
            'type' => 'array',
            'required' => false,
            'description' => 'Itemized charges',
            'children' => [
                ['name' => 'description', 'type' => 'string', 'required' => true],
                ['name' => 'amount', 'type' => 'number', 'required' => true],
                ['name' => 'quantity', 'type' => 'integer', 'required' => false],
            ],
        ],
    ];
@endphp

<div class="mx-auto w-full max-w-2xl">
    <x-ui.schema-builder :fields="$fields" title="Invoice" />
</div>
```

## Use when

- Use when users need to upload, inspect, edit, annotate, or sign real documents as part of the workflow.
- Letting a non-technical user define the fields a document-extraction or data-import pipeline should pull out, without writing raw JSON Schema.
- Needing nested object and array fields with a live schema preview as the user edits.

## Avoid when

- Do not use a heavy document interface when the same task can be completed more simply in structured product UI.
- The schema is fixed and defined by developers; hand-write the JSON Schema instead of adding a visual editor.
- Only a flat list of simple fields is ever needed; a plain repeated form row may be simpler than the full tree editor.

## Anti-patterns

- Heavy document UI when structured fields are simpler

## Rules

- Use the `<brok:schema-builder>` tag (or `<x-ui.schema-builder>`) in Blade; do not rewrite the component.
- Prefer the documented props and variants over utility-class overrides; when a utility must win, use the `!` important modifier.
- Use semantic design tokens (`bg-primary`, `text-muted-foreground`), never raw colour utilities.
- Keep the `data-slot` attributes; they are the styling and test hooks.

## Links

- Docs: https://brokui.dev/docs/components/schema-builder

Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.

API

manifest knowledge + registry-derived coverage

Props

No documented props. Pass normal Blade attributes through the component root.

Slots

  • default —

Data slots

Stable hooks for CSS overrides and browser tests.

No data-slot selectors found in the registry source.

Behavior

  • Each field is a one-line row (name, type, required, description, and allowed values for an enum), with a child button on object and array fields to add nested fields.
  • The field tree is flattened internally for rendering, so nesting has no fixed depth limit while the row template exists once.
  • The preview panel re-renders the resulting JSON Schema live from the same tree as the editor changes.
  • Installs a JavaScript behavior module when the registry item includes resources/js/ui files.

Guidance

Document workflow

Upload, inspect, edit, annotate, or sign a real document.

Use when

  • Use when users need to upload, inspect, edit, annotate, or sign real documents as part of the workflow.
  • Letting a non-technical user define the fields a document-extraction or data-import pipeline should pull out, without writing raw JSON Schema.
  • Needing nested object and array fields with a live schema preview as the user edits.

Avoid when

  • Do not use a heavy document interface when the same task can be completed more simply in structured product UI.
  • The schema is fixed and defined by developers; hand-write the JSON Schema instead of adding a visual editor.
  • Only a flat list of simple fields is ever needed; a plain repeated form row may be simpler than the full tree editor.

Use instead

  • Structured product form
  • Direct data entry

Anti-patterns

  • Heavy document UI when structured fields are simpler
Anatomy
root schema-builder-row

Accessibility

WCAG 2.2 AA Keyboard focus-visible RTL-ready Localized labels Dark mode
Keyboard
No component-owned keyboard interaction; native element behavior applies.
Focus
none
  • The editor is labelled as a region so assistive tech can locate it, and every row control is a real input, select, or switch rather than a custom widget.
  • Semantic HTML and a stable data-slot attribute for styling and scripting hooks.
  • Focus-visible rings use the ring token, so keyboard focus is always visible.
  • Disabled and invalid states are conveyed to assistive tech, not by color alone.
  • Targets WCAG 2.2 AA; verify contrast in light, dark, admin and customer surfaces in the preview.
  • Labels go through __() and layout uses logical properties (ms-*, text-start), so it mirrors under dir="rtl" — flip the preview to RTL to confirm.
  • Dark mode uses the same semantic tokens under the dark class; high contrast follows forced-color system tokens.

Livewire

Safe

Livewire can update this component through forwarded wire:* attributes.

Source

Source available with Pro

This preview shows the real Pro component, while its installable source is delivered only through the authenticated registry. Activate a license, then use the installation command above.

Open the authenticated source endpoint

Ownership & lifecycle

Owner, release state, review evidence and adoption for this item.
Owner
Platform UI (@JoshJML)
Current version
1.1.0
Status
Stable
License
pro
Accessibility reviewed
No review date recorded
Last breaking change
No date recorded
Deprecation
Not deprecated