Schema Spec
A brij form is defined entirely by a JSON schema your server returns at GET /brij/schema/:slug. brij.js fetches this at open() time - no build step, no client-side config.
BrijSchema
The top-level schema object.
interface BrijSchema {
title?: string
description?: string
submitLabel?: string
steps: BrijStepSchema[]
}
| Property | Type | Description |
|---|---|---|
title | string | Displayed in the form header. Defaults to 'Complete the form'. |
description | string | Subtitle below the title. |
submitLabel | string | Text on the submit button. Defaults to 'Submit'. |
steps | BrijStepSchema[] | One or more steps. Required - must have at least one. |
BrijStepSchema
Each element in steps.
interface BrijStepSchema {
id?: string
title?: string
description?: string
fields: BrijFieldSchema[]
}
| Property | Type | Description |
|---|---|---|
id | string | Optional identifier for the step. Not displayed. |
title | string | Displayed as the step heading. Defaults to 'Step N'. |
description | string | Displayed below the step heading. |
fields | BrijFieldSchema[] | Fields rendered in this step. |
BrijFieldSchema
Defines a single input field.
interface BrijFieldSchema {
name: string
label: string
type: BrijFieldType
placeholder?: string
description?: string
options?: BrijFieldOption[]
validation?: BrijFieldValidation
defaultValue?: string | boolean | string[]
}
| Property | Type | Description |
|---|---|---|
name | string | HTML name attribute. Must be unique within the schema. Submitted as the form field key. |
label | string | Displayed above the input. |
type | BrijFieldType | Input type - see Field Types below. |
placeholder | string | Input placeholder text. For select, becomes the empty option label. |
description | string | Help text rendered below the input. |
options | BrijFieldOption[] | Required for select, radio, and multi-checkbox fields. |
validation | BrijFieldValidation | Client-side validation rules - see Validation below. |
defaultValue | string or boolean or string[] | Pre-filled value when the form opens. Use an array for multi-checkbox defaults. |
Field Types
| Type | Renders as | Notes |
|---|---|---|
text | text input | General text input. |
email | email input | Browser email validation built in. |
textarea | textarea | Multi-line text. Min-height 120px, resizable vertically. |
select | dropdown | Requires options. |
radio | radio group | Single choice. Requires options. |
checkbox | checkbox or checkbox group | With options: multi-select group. Without: single boolean checkbox. |
Example - radio group:
{
"name": "plan",
"label": "Plan",
"type": "radio",
"options": [
{ "label": "Starter", "value": "starter" },
{ "label": "Pro", "value": "pro" },
{ "label": "Enterprise", "value": "enterprise" }
]
}
Validation
interface BrijFieldValidation {
required?: boolean
minLength?: number
maxLength?: number
pattern?: string
min?: number
max?: number
}
Validation runs client-side when the user clicks Next or Submit. If any field fails, an error message is shown and the step does not advance.
| Rule | Applies to | Description |
|---|---|---|
required | all | Field must have a non-empty value. |
minLength | text, email, textarea | Minimum character count. |
maxLength | text, email, textarea | Maximum character count. |
pattern | text, email, textarea | JavaScript regex string. Matched with new RegExp(pattern). |
min | text, email | Numeric minimum (value cast to number). |
max | text, email | Numeric maximum. |
BrijFieldOption
Used by select, radio, and multi-checkbox fields.
interface BrijFieldOption {
label: string
value: string
}
value is what gets submitted. label is what the user sees.
Full example
A two-step form with a variety of field types:
{
"title": "Team Signup",
"description": "Tell us a bit about your team.",
"submitLabel": "Create account",
"steps": [
{
"title": "About you",
"fields": [
{
"name": "name",
"label": "Full name",
"type": "text",
"validation": { "required": true }
},
{
"name": "email",
"label": "Work email",
"type": "email",
"validation": { "required": true }
}
]
},
{
"title": "Your team",
"fields": [
{
"name": "team_size",
"label": "Team size",
"type": "radio",
"options": [
{ "label": "Just me", "value": "1" },
{ "label": "2-10", "value": "2-10" },
{ "label": "11-50", "value": "11-50" },
{ "label": "50+", "value": "50+" }
],
"validation": { "required": true }
},
{
"name": "use_cases",
"label": "What will you use brij for?",
"type": "checkbox",
"options": [
{ "label": "Lead capture", "value": "leads" },
{ "label": "Onboarding", "value": "onboarding" },
{ "label": "Support intake", "value": "support" }
]
},
{
"name": "notes",
"label": "Anything else?",
"type": "textarea",
"placeholder": "Optional"
}
]
}
]
}