View recipes
Recipes compose a shell with optional header, progress, and actions blocks. Select one with form-level view.$type. @schema-engine/forms-react is headless: the factory does not bind default recipes. FormRenderer still lives in the package.
| Layer | Owns |
|---|---|
@schema-engine/layout | The recipe protocol every domain shares: defineRecipeProtocol, resolveRecipeView, slot defaults |
@schema-engine/forms/recipes | The forms protocol (slots shell, header, progress, actions; kinds single-step, wizard): defineRecipeSpec, defineFormRecipe, view model |
@schema-engine/forms/recipes/built-in | Built-in specs, slot schemas and their config types |
schema-engine-form-recipes (shadcn registry) | React shells, blocks, schemaFormRecipeRegistrations |
@schema-engine/forms-radiant | Radiant shells and blocks, auto-bound by createRadiantFormEngine() |
Default registry recipes
The React Forms page renders the registry's card recipe and input field live, from source copied into the docs app.
Install the default source owned by your app:
pnpm dlx shadcn@latest add andeeplus/schema-engine/schema-engine-form-recipesThe install copies the recipe stylesheets next to the components. Import the entry point once in your global stylesheet, after Tailwind and into the components layer (the components layer keeps Tailwind utilities and your own classes above the recipe rules):
@import 'tailwindcss';
@import './components/schema-engine/forms/recipes/recipes.css' layer(components);The path is relative to your global stylesheet: ./components/schema-engine/forms/recipes/recipes.css from a Vite src/index.css, ../components/schema-engine/forms/recipes/recipes.css from a Next.js app/globals.css. Without the import the shells and blocks render unstyled: each shell and block has its layout in a CSS file beside its component (shells/hero-shell.css, blocks/form-actions.css and the rest), every rule inside :where() so a class of yours wins, and the Tailwind classes left on the components are mostly your shadcn theme's colours and type, plus the few that override a shadcn Button. Without Tailwind, import the file plain. The size axis also needs controls.css, unlayered, after the recipe styles: @import './components/ui/schema-engine/components/controls.css'; (see Appearance and the default styles). Then add the generated recipe barrel when you construct the engine:
import { createFormEngine } from '@schema-engine/forms';
import { schemaFormRecipeRegistrations } from '@/components/schema-engine/forms/recipes/registrations';
import { schemaFormRegistrations } from '@/components/schema-engine/forms/registrations';
const engine = createFormEngine({ elements: schemaFormRegistrations, recipes: schemaFormRecipeRegistrations });$type | Kind | Description |
|---|---|---|
card | single-step | Centered card shell |
split-screen | single-step | Side panel plus form |
hero-background | single-step | Hero image or video |
bare-controls | wizard | Previous / next / submit only |
card-wizard | wizard | Card shell with progress |
wizard | wizard | Horizontal step indicators |
sidebar-wizard | wizard | Step indicators in a sidebar |
hero-wizard | wizard | Wizard over a hero background |
split-screen-wizard | wizard | Wizard with a marketing side panel |
Slot config is optional. The recipe fixes block identity; view only passes options such as shell, header, progress, and actions.
Single-step
Single-step recipes render a submit-only actions bar below the fields (aligned with the actions.align slot config), so the form is submittable without wizard navigation:
const formConfig: FormConfig = {
id: 'contact',
view: {
$type: 'card',
shell: { appearance: { size: 'comfortable', surface: 'elevated' } },
},
steps: [{ id: 'step-1', title: 'Contact', elements: [/* ... */] }],
};Appearance and the default styles
Recipe slots, steps, fields and the form take a named appearance. The guides are Appearance axes and Theming; in short, the engine's layout theme declares the axes (size: compact | default | comfortable, surface: flat | outlined | elevated, plus any a host adds), each element or slot declares the axes it supports, and both renderers emit the picked value as data-se-<axis>. The hero, split screen and sidebar shells declare size on their shell slot and read --se-space for their padding and gaps (the stack shell reads it too, from the form's appearance; a step's pick does not reach a shell, which sits above the steps), as their Radiant shells do. The card shell reads the semantic tokens those values set (--se-space, --se-measure, --se-border-width, --se-shadow, --se-surface-background) from card-shell.css, so, with the built-in axes and no host theme overrides, the same config gives the same padding, width, border and shadow as the Radiant card. controls.css, a separate import from recipes.css, reads --se-control-height for the single-line controls that carry data-se-control (inputs, selects, number, masked and phone inputs, date triggers, the submit and wizard buttons): compact is 1.75rem and comfortable 2.25rem unless the host sets --se-control-height-compact or --se-control-height-comfortable, and no pick or default keeps the height of your own ui component. Import it unlayered, after the layered recipes.css: @import './components/ui/schema-engine/components/controls.css';. A shadcn control sets its height with a Tailwind utility, which outranks every components layer rule, so only an unlayered rule lets the pick win. While a size is picked, a Tailwind height utility you pass to a control loses to it, and an unlayered class of yours still wins. Structural slot config such as header.showDescription is unchanged.
Multi-step
Wizard recipes require at least two steps. Set view.$type to a wizard recipe such as wizard or card-wizard. The live demo renders exactly the configuration below:
const formConfig: FormConfig = {
id: 'onboarding',
title: 'Create your account',
view: {
$type: 'wizard'
},
steps: [
{
id: 'account',
title: 'Account',
elements: [
{
$type: 'input',
id: 'email',
name: 'email',
label: 'Email Address',
inputType: 'email',
rules: [
{
type: 'required',
message: 'Email is required'
}
]
},
{
$type: 'input',
id: 'password',
name: 'password',
label: 'Password',
inputType: 'password',
rules: [
{
type: 'required',
message: 'Password is required'
},
{
type: 'minLength',
value: 8,
message: 'Use at least 8 characters'
}
]
}
]
},
{
id: 'profile',
title: 'Profile',
elements: [
{
$type: 'select',
id: 'role',
name: 'role',
label: 'Role',
placeholder: 'Select your role',
rules: [
{
type: 'required',
message: 'Role is required'
}
],
options: [
{
value: 'developer',
label: 'Developer'
},
{
value: 'designer',
label: 'Designer'
},
{
value: 'product',
label: 'Product Manager'
}
]
},
{
$type: 'checkbox',
id: 'newsletter',
name: 'newsletter',
label: 'Newsletter',
description: 'Optional. Send me product updates.'
}
]
}
]
};If you omit view.$type on a multi-step form, validateForm writes the engine's default wizard recipe as view (bare-controls unless createFormEngine({ defaultWizardRecipe }) names another wizard recipe). If that recipe is not registered, the form keeps no view, validateForm warns, and fields render without chrome.
See Registration Flow for a full wizard configuration.
Skipping steps and the stepper
A step takes constraints (show or hide, the same logic as fields) on fields of earlier steps. A step its
constraints hide is skipped: Next and Back pass over it, goTo refuses it, progress counts only the steps that are
not skipped, and its fields take no part (they are not validated and are left out of the submitted values; the
values are kept and come back if the step is shown again). The first step cannot have constraints:
steps: [
{ id: 'contact', title: 'Contact', elements: [{ $type: 'input', name: 'hasCompany', label: 'Company?' }] },
{
id: 'company',
title: 'Company',
elements: [{ $type: 'input', name: 'companyName', label: 'Company name' }],
constraints: [{ field: 'hasCompany', operator: 'equals', value: 'yes', action: 'show' }],
},
{ id: 'payment', title: 'Payment', elements: [] },
];The form's navigation setting decides how freely the stepper moves forward: 'linear' (the default) reaches only
steps already visited and validates every step on the way, landing on the first that fails; 'free' reaches any step
without validating. Going back is always allowed and Next validates in both. A block reads this from the view model:
steps lists the steps that are not skipped (index and total count only those), and navigation.canGoToStep(id)
and navigation.goToStep(id) take step ids.
Style a recipe
A copy-paste path from install to a styled card:
- Install the recipes and import the stylesheet as above.
- Pick the look in config.
sizeiscompact,defaultorcomfortable;surfaceisflat,outlinedorelevated:
const config = engine.defineForm({
id: 'contact',
className: 'checkout-form',
view: { $type: 'card', shell: { appearance: { size: 'comfortable', surface: 'outlined' } } },
steps: [
{
id: 'details',
title: 'Details',
elements: [{ $type: 'input', id: 'email', name: 'email', label: 'Email' }],
},
],
});- Override it with your own CSS. The recipe rules sit inside
:where(), so any class beats them without!important. The form'sclassName(herecheckout-form) is on an ancestor of the shell, so style the shell parts under it:
.checkout-form .se-card-shell__section {
padding: 2.5rem;
}
.checkout-form .se-card-shell__card {
border-radius: 0;
}The card shell sets no inline styles. Its class hooks are se-card-shell, se-card-shell__card, se-card-shell__section, se-card-shell__header and se-card-shell__content. The other shells and blocks have hooks of the same kind: se-hero-shell (with __video, __overlay, __content, __header and __form), se-split-screen-shell (__side, __main, __actions, __title and __side-content), se-sidebar-shell (__progress, __separator, __main and the --stacked modifier), se-stack-shell, se-step-header, se-form-actions (with --align-*), se-wizard-actions (--minimal, __forward), se-step-indicators (--sidebar, __list, __item, __button, __number, __copy, __title) and se-minimal-progress (__labels, __track, __fill). The hero image is the only inline style: it is data, so it stays an inline background-image, and the progress fill takes its width from the custom property --se-progress. The stack shell and the stacked sidebar are as wide as Radiant's, at most 40rem and centred, so a wizard or a bare-controls form no longer fills its container. Styling and layout says which tool (a token, an axis value, a class) fits which job.
Copy the default source
Canonical source is registry/shared/forms/recipes. After shadcn add, files land under @/components/schema-engine/forms/recipes. Copy the files for each recipe you want. A recipe that has a stylesheet lists recipes.css with it; copy it together with every stylesheet it imports and import it as above. Every shell and block now ships a stylesheet, so when you copy only some recipes, delete the @import lines of recipes.css for the files you did not copy, or the stylesheet fails to resolve them. Each tab has a copy button.
Single-step recipes
Card view.$type: 'card'
import { defineRecipe } from '@schema-engine/forms-react/primitives';
import { cardSpec } from '@schema-engine/forms/recipes/built-in';
import { StepHeader } from '../blocks/step-header';
import { FormActions } from '../blocks/form-actions';
import { CardShell } from '../shells/card-shell';
export const CardRecipe = defineRecipe(cardSpec, {
shell: CardShell,
slots: { header: StepHeader, actions: FormActions },
});
import type { ElementType } from 'react';
import { formatStepLabel, StepHeaderConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useActiveStep, useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { cn } from '@/components/schema-engine/forms/lib/utils';
const titleSizes = {
sm: 'text-xl',
md: 'text-2xl',
lg: 'text-4xl',
} as const;
export function StepHeader() {
const { form } = useViewContext();
const step = useActiveStep();
const {
showDescription,
showStepCounter,
labels,
size,
align,
fallbackToFormTitle,
titleAs,
inheritColor,
counterPlacement,
} = useViewConfig('header', StepHeaderConfigSchema);
const title = step.title || (fallbackToFormTitle ? form.title : undefined);
const description = step.description || form.description;
const counterText = showStepCounter ? formatStepLabel(labels.stepCounter, step.index + 1, step.total) : null;
const Title = titleAs as ElementType;
if (!title && !description && !counterText) return null;
return (
<header
data-align={align}
className={cn('se-step-header', inheritColor && 'se-step-header--inherit-color text-inherit')}
>
{counterText && counterPlacement === 'before' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
{title ? <Title className={cn('font-bold tracking-tight', titleSizes[size])}>{title}</Title> : null}
{showDescription && description ? (
<p className={cn('text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>{description}</p>
) : null}
{counterText && counterPlacement === 'after' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
</header>
);
}
/*
* Layout of the step header block.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The title scale and colours stay with your ui theme (Tailwind classes on the title and the counter).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-step-header) {
display: flex;
flex-direction: column;
gap: 0.5rem;
max-width: none;
}
:where(.se-step-header[data-align='start']) {
text-align: left;
}
:where(.se-step-header[data-align='center']) {
text-align: center;
}
:where(.se-step-header--inherit-color) {
color: inherit;
}
import { FormActionsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
/**
* Submit-only action bar for single-step recipes.
*
* @remarks Wizard recipes author Previous/Next/Submit through {@link WizardActions};
* single-step shells need a plain submit affordance. Reads the `actions` slot
* config for labels and alignment, and the view context for the submitting state.
*/
export function FormActions() {
const { form } = useViewContext();
const { labels, align } = useViewConfig('actions', FormActionsConfigSchema);
return (
<div className={cn('se-form-actions', `se-form-actions--align-${align}`)}>
<Button data-se-control type="submit" aria-label={labels.submitAriaLabel}>
{form.isSubmitting ? labels.submitting : labels.submit}
</Button>
</div>
);
}
/*
* Layout of the submit-only action bar of single-step recipes.
*
* The bar is as wide as its container and the `actions.align` slot config places the button in it, so the
* same config gives the same alignment as in Radiant. Every rule sits inside :where(), so it adds no
* specificity and a host class on the same element wins.
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-form-actions) {
display: flex;
width: 100%;
min-width: 0;
}
:where(.se-form-actions--align-start) {
justify-content: flex-start;
}
:where(.se-form-actions--align-center) {
justify-content: center;
}
:where(.se-form-actions--align-end) {
justify-content: flex-end;
}
import { getAppearanceAttributes } from '@schema-engine/layout';
import { getSlotConfig } from '@schema-engine/forms/recipes';
import { CardShellConfigSchema } from '@schema-engine/forms/recipes/built-in';
import type { FormShellProps } from '@schema-engine/forms-react/primitives';
/**
* Styles live in `card-shell.css`, which the app imports through `recipes.css`.
*
* @remarks
* The card's `appearance` (`size`, `surface`) is emitted as `data-se-*` attributes; the layout theme's
* token rules turn them into `--se-space`, `--se-measure`, `--se-border-width`, `--se-shadow` and
* `--se-surface-background`, which the stylesheet reads. The shell sets no inline style, so a host
* class on the card or a section overrides it.
*/
export function CardShell({ slots, viewConfig }: FormShellProps) {
const { appearance } = getSlotConfig(viewConfig, 'shell', CardShellConfigSchema);
return (
<div className="se-card-shell">
<div className="se-card-shell__card" {...getAppearanceAttributes(appearance)}>
{slots.header ? (
<div className="se-card-shell__header se-card-shell__section">{slots.header}</div>
) : null}
<div className="se-card-shell__content se-card-shell__section">
{slots.progress}
{slots.content}
{slots.actions}
</div>
</div>
</div>
);
}
/*
* Card shell styles for the React registry recipes.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The card reads the semantic appearance tokens the layout theme declares for the `size` and `surface`
* axes (--se-space, --se-measure, --se-border-width, --se-shadow, --se-surface-background); the
* fallbacks are the look of an unpicked card and follow the app's shadcn theme variables.
*
* Import this file into the `components` layer when the app uses Tailwind, so utility classes still
* outrank it: `@import "./components/schema-engine/forms/recipes/recipes.css" layer(components);`
*/
:where(.se-card-shell) {
display: flex;
min-height: 100svh;
align-items: center;
justify-content: center;
padding: 1rem;
background-color: color-mix(in srgb, var(--muted, transparent) 30%, transparent);
}
@media (min-width: 768px) {
:where(.se-card-shell) {
padding: 2rem;
}
}
:where(.se-card-shell__card) {
box-sizing: border-box;
width: 100%;
max-width: var(--se-measure, 28rem);
border: var(--se-border-width, 1px) solid var(--border, currentColor);
border-radius: calc(var(--radius, 0.5rem) + 4px);
background-color: var(--se-surface-background, var(--card, #fff));
color: var(--card-foreground, inherit);
box-shadow: var(--se-shadow, 0 8px 24px color-mix(in srgb, var(--on-surface, #000) 10%, transparent));
}
:where(.se-card-shell__section) {
padding: var(--se-space, 1.5rem);
}
:where(.se-card-shell__header) {
border-bottom: 1px solid var(--border, currentColor);
text-align: center;
}
:where(.se-card-shell__content) {
display: flex;
min-width: 0;
flex-direction: column;
gap: 1.5rem;
}
/*
* Generated entry point for the Schema Engine default recipe styles.
* Import this one file from the app's global stylesheet; each shell's file sits beside its component.
*/
@import './blocks/form-actions.css';
@import './blocks/minimal-progress.css';
@import './blocks/step-header.css';
@import './blocks/step-indicators.css';
@import './blocks/wizard-actions.css';
@import './shells/card-shell.css';
@import './shells/hero-shell.css';
@import './shells/sidebar-shell.css';
@import './shells/split-screen-shell.css';
@import './shells/stack-shell.css';
Hero Background view.$type: 'hero-background'
import { defineRecipe } from '@schema-engine/forms-react/primitives';
import { heroBackgroundSpec } from '@schema-engine/forms/recipes/built-in';
import { StepHeader } from '../blocks/step-header';
import { FormActions } from '../blocks/form-actions';
import { HeroShell } from '../shells/hero-shell';
export const HeroBackgroundRecipe = defineRecipe(heroBackgroundSpec, {
shell: HeroShell,
slots: { header: StepHeader, actions: FormActions },
});
import type { ElementType } from 'react';
import { formatStepLabel, StepHeaderConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useActiveStep, useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { cn } from '@/components/schema-engine/forms/lib/utils';
const titleSizes = {
sm: 'text-xl',
md: 'text-2xl',
lg: 'text-4xl',
} as const;
export function StepHeader() {
const { form } = useViewContext();
const step = useActiveStep();
const {
showDescription,
showStepCounter,
labels,
size,
align,
fallbackToFormTitle,
titleAs,
inheritColor,
counterPlacement,
} = useViewConfig('header', StepHeaderConfigSchema);
const title = step.title || (fallbackToFormTitle ? form.title : undefined);
const description = step.description || form.description;
const counterText = showStepCounter ? formatStepLabel(labels.stepCounter, step.index + 1, step.total) : null;
const Title = titleAs as ElementType;
if (!title && !description && !counterText) return null;
return (
<header
data-align={align}
className={cn('se-step-header', inheritColor && 'se-step-header--inherit-color text-inherit')}
>
{counterText && counterPlacement === 'before' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
{title ? <Title className={cn('font-bold tracking-tight', titleSizes[size])}>{title}</Title> : null}
{showDescription && description ? (
<p className={cn('text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>{description}</p>
) : null}
{counterText && counterPlacement === 'after' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
</header>
);
}
/*
* Layout of the step header block.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The title scale and colours stay with your ui theme (Tailwind classes on the title and the counter).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-step-header) {
display: flex;
flex-direction: column;
gap: 0.5rem;
max-width: none;
}
:where(.se-step-header[data-align='start']) {
text-align: left;
}
:where(.se-step-header[data-align='center']) {
text-align: center;
}
:where(.se-step-header--inherit-color) {
color: inherit;
}
import { FormActionsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
/**
* Submit-only action bar for single-step recipes.
*
* @remarks Wizard recipes author Previous/Next/Submit through {@link WizardActions};
* single-step shells need a plain submit affordance. Reads the `actions` slot
* config for labels and alignment, and the view context for the submitting state.
*/
export function FormActions() {
const { form } = useViewContext();
const { labels, align } = useViewConfig('actions', FormActionsConfigSchema);
return (
<div className={cn('se-form-actions', `se-form-actions--align-${align}`)}>
<Button data-se-control type="submit" aria-label={labels.submitAriaLabel}>
{form.isSubmitting ? labels.submitting : labels.submit}
</Button>
</div>
);
}
/*
* Layout of the submit-only action bar of single-step recipes.
*
* The bar is as wide as its container and the `actions.align` slot config places the button in it, so the
* same config gives the same alignment as in Radiant. Every rule sits inside :where(), so it adds no
* specificity and a host class on the same element wins.
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-form-actions) {
display: flex;
width: 100%;
min-width: 0;
}
:where(.se-form-actions--align-start) {
justify-content: flex-start;
}
:where(.se-form-actions--align-center) {
justify-content: center;
}
:where(.se-form-actions--align-end) {
justify-content: flex-end;
}
import { getAppearanceAttributes } from '@schema-engine/layout';
import { getSlotConfig } from '@schema-engine/forms/recipes';
import { HeroShellConfigSchema } from '@schema-engine/forms/recipes/built-in';
import type { FormShellProps } from '@schema-engine/forms-react/primitives';
/**
* Styles live in `hero-shell.css`, which the app imports through `recipes.css`.
*
* @remarks
* The shell's `appearance` (`size`) is emitted as `data-se-*` attributes and the layout theme's token
* rules turn it into `--se-space`, which the stylesheet reads. The background image is data, so it stays
* an inline `background-image` (a relative URL resolves against the page, as in Radiant); the position and
* size are the stylesheet's. What stays as Tailwind classes is the shadcn theme's colour (`bg-muted`,
* `bg-card/95`).
*/
export function HeroShell({ slots, viewConfig }: FormShellProps) {
const { appearance, backgroundImage, backgroundVideo, contentWidth } = getSlotConfig(
viewConfig,
'shell',
HeroShellConfigSchema,
);
return (
<div
className="se-hero-shell bg-muted text-primary-foreground"
style={backgroundImage ? { backgroundImage: `url(${JSON.stringify(backgroundImage)})` } : undefined}
{...getAppearanceAttributes(appearance)}
>
{backgroundVideo ? (
<video autoPlay muted loop playsInline src={backgroundVideo} className="se-hero-shell__video" />
) : null}
<div className="se-hero-shell__overlay" />
<div className={`se-hero-shell__content se-hero-shell__content--${contentWidth}`}>
{slots.header ? <div className="se-hero-shell__header">{slots.header}</div> : null}
<div className="se-hero-shell__form bg-card/95 text-card-foreground shadow-lg">
{slots.progress}
{slots.content}
{slots.actions}
</div>
</div>
</div>
);
}
/*
* Hero shell styles for the React registry recipes.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The shell reads the semantic `size` token --se-space for its padding and the gaps of its content, as the
* Radiant hero does; the fallbacks are the look of an unpicked hero. The background image is data and stays
* an inline `background-image` on the shell, so no inline style carries layout.
*
* Import this file into the `components` layer when the app uses Tailwind, so utility classes still outrank
* it: `@import "./components/schema-engine/forms/recipes/recipes.css" layer(components);`
*/
:where(.se-hero-shell) {
position: relative;
isolation: isolate;
display: flex;
box-sizing: border-box;
width: 100%;
min-height: 100svh;
align-items: center;
justify-content: center;
overflow: hidden;
padding: var(--se-space, 2rem);
background-position: center;
background-size: cover;
}
:where(.se-hero-shell__video) {
position: absolute;
inset: 0;
z-index: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
:where(.se-hero-shell__overlay) {
position: absolute;
inset: 0;
z-index: 1;
background: rgb(0 0 0 / 0.5);
}
:where(.se-hero-shell__content) {
position: relative;
z-index: 2;
width: 100%;
text-align: center;
}
:where(.se-hero-shell__content--sm) {
max-width: 24rem;
}
:where(.se-hero-shell__content--md) {
max-width: 28rem;
}
:where(.se-hero-shell__content--lg) {
max-width: 32rem;
}
:where(.se-hero-shell__content--xl) {
max-width: 36rem;
}
:where(.se-hero-shell__header) {
margin-bottom: var(--se-space, 2rem);
}
:where(.se-hero-shell__form) {
display: flex;
flex-direction: column;
gap: var(--se-space, 1.5rem);
padding: var(--se-space, 2rem);
border-radius: var(--radius, 0.5rem);
text-align: left;
}
/*
* Generated entry point for the Schema Engine default recipe styles.
* Import this one file from the app's global stylesheet; each shell's file sits beside its component.
*/
@import './blocks/form-actions.css';
@import './blocks/minimal-progress.css';
@import './blocks/step-header.css';
@import './blocks/step-indicators.css';
@import './blocks/wizard-actions.css';
@import './shells/card-shell.css';
@import './shells/hero-shell.css';
@import './shells/sidebar-shell.css';
@import './shells/split-screen-shell.css';
@import './shells/stack-shell.css';
Split Screen view.$type: 'split-screen'
import { defineRecipe } from '@schema-engine/forms-react/primitives';
import { splitScreenSpec } from '@schema-engine/forms/recipes/built-in';
import { FormActions } from '../blocks/form-actions';
import { SplitScreenShell } from '../shells/split-screen-shell';
export const SplitScreenRecipe = defineRecipe(splitScreenSpec, {
shell: SplitScreenShell,
slots: { actions: FormActions },
});
import { FormActionsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
/**
* Submit-only action bar for single-step recipes.
*
* @remarks Wizard recipes author Previous/Next/Submit through {@link WizardActions};
* single-step shells need a plain submit affordance. Reads the `actions` slot
* config for labels and alignment, and the view context for the submitting state.
*/
export function FormActions() {
const { form } = useViewContext();
const { labels, align } = useViewConfig('actions', FormActionsConfigSchema);
return (
<div className={cn('se-form-actions', `se-form-actions--align-${align}`)}>
<Button data-se-control type="submit" aria-label={labels.submitAriaLabel}>
{form.isSubmitting ? labels.submitting : labels.submit}
</Button>
</div>
);
}
/*
* Layout of the submit-only action bar of single-step recipes.
*
* The bar is as wide as its container and the `actions.align` slot config places the button in it, so the
* same config gives the same alignment as in Radiant. Every rule sits inside :where(), so it adds no
* specificity and a host class on the same element wins.
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-form-actions) {
display: flex;
width: 100%;
min-width: 0;
}
:where(.se-form-actions--align-start) {
justify-content: flex-start;
}
:where(.se-form-actions--align-center) {
justify-content: center;
}
:where(.se-form-actions--align-end) {
justify-content: flex-end;
}
import { getAppearanceAttributes } from '@schema-engine/layout';
import { getSlotConfig } from '@schema-engine/forms/recipes';
import { SplitScreenShellConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewContext } from '@schema-engine/forms-react/hooks';
import type { FormShellProps } from '@schema-engine/forms-react/primitives';
import { cn } from '@/components/schema-engine/forms/lib/utils';
/**
* Styles live in `split-screen-shell.css`, which the app imports through `recipes.css`.
*
* @remarks
* The panel shows the form title. When the recipe has a header slot, that header must set
* `fallbackToFormTitle: false` in its slot defaults, or the form title is repeated in the header
* for steps without a title. A custom recipe that reuses this shell with a header slot must set
* that default too.
*
* The shell's `appearance` (`size`) is emitted as `data-se-*` attributes and the layout theme's token
* rules turn it into `--se-space`, which the stylesheet reads for both panels. What stays as Tailwind
* classes is the shadcn theme's colour and type scale.
*/
export function SplitScreenShell({ slots, viewConfig }: FormShellProps) {
const {
appearance,
sideContent,
sidePlacement,
sideWidth,
contentAlignment: alignment,
} = getSlotConfig(viewConfig, 'shell', SplitScreenShellConfigSchema);
const { form, activeStep } = useViewContext();
const title = form.title || (slots.header ? undefined : activeStep.title);
return (
<div className="se-split-screen-shell" {...getAppearanceAttributes(appearance)}>
{title || sideContent ? (
<aside
className={cn(
'se-split-screen-shell__side bg-muted',
`se-split-screen-shell__side--${sideWidth}`,
sidePlacement === 'right' && 'se-split-screen-shell__side--right',
)}
>
{title ? (
<h2 className="se-split-screen-shell__title text-2xl font-semibold tracking-tight">{title}</h2>
) : null}
{sideContent ? (
<div className="se-split-screen-shell__side-content text-sm text-muted-foreground md:text-base">
{sideContent}
</div>
) : null}
</aside>
) : null}
<div className={cn('se-split-screen-shell__main', `se-split-screen-shell__main--${alignment}`)}>
{slots.header}
{slots.progress}
{slots.content}
{slots.actions ? <div className="se-split-screen-shell__actions">{slots.actions}</div> : null}
</div>
</div>
);
}
/*
* Split-screen shell styles for the React registry recipes.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The padding of both panels and the gap between the slots of the content panel read the semantic `size`
* token --se-space, as the Radiant split screen does; the fallbacks are the look of an unpicked shell.
*
* Import this file into the `components` layer when the app uses Tailwind, so utility classes still outrank
* it: `@import "./components/schema-engine/forms/recipes/recipes.css" layer(components);`
*/
:where(.se-split-screen-shell) {
display: flex;
flex-direction: column;
width: 100%;
min-height: 100svh;
}
@media (min-width: 768px) {
:where(.se-split-screen-shell) {
flex-direction: row;
}
}
:where(.se-split-screen-shell__side) {
display: flex;
flex-direction: column;
justify-content: center;
box-sizing: border-box;
width: 100%;
padding: var(--se-space, 1.5rem);
}
@media (min-width: 768px) {
:where(.se-split-screen-shell__side--narrow) {
width: 33.333%;
}
:where(.se-split-screen-shell__side--normal) {
width: 50%;
}
:where(.se-split-screen-shell__side--wide) {
width: 66.666%;
}
:where(.se-split-screen-shell__side--right) {
order: 2;
}
}
:where(.se-split-screen-shell__main) {
display: flex;
flex: 1;
flex-direction: column;
gap: var(--se-space, 1.5rem);
box-sizing: border-box;
min-width: 0;
padding: var(--se-space, 1.5rem);
overflow: auto;
}
:where(.se-split-screen-shell__main--top) {
justify-content: flex-start;
}
:where(.se-split-screen-shell__main--center) {
justify-content: center;
}
:where(.se-split-screen-shell__main--bottom) {
justify-content: flex-end;
}
:where(.se-split-screen-shell__actions) {
flex-shrink: 0;
margin-top: auto;
}
:where(.se-split-screen-shell__title) {
max-width: 28rem;
margin: 0;
}
:where(.se-split-screen-shell__side-content) {
max-width: 28rem;
margin: 0.75rem 0 0;
}
/*
* Generated entry point for the Schema Engine default recipe styles.
* Import this one file from the app's global stylesheet; each shell's file sits beside its component.
*/
@import './blocks/form-actions.css';
@import './blocks/minimal-progress.css';
@import './blocks/step-header.css';
@import './blocks/step-indicators.css';
@import './blocks/wizard-actions.css';
@import './shells/card-shell.css';
@import './shells/hero-shell.css';
@import './shells/sidebar-shell.css';
@import './shells/split-screen-shell.css';
@import './shells/stack-shell.css';
Wizard recipes
Use these when the form has two or more steps. Each tab is a file; use Copy on the tab you need.
Bare Controls view.$type: 'bare-controls'
import { defineRecipe } from '@schema-engine/forms-react/primitives';
import { bareControlsSpec } from '@schema-engine/forms/recipes/built-in';
import { WizardActions } from '../blocks/wizard-actions';
import { StackShell } from '../shells/stack-shell';
export const BareControlsRecipe = defineRecipe(bareControlsSpec, {
shell: StackShell,
slots: { actions: WizardActions },
});
import { formatStepLabel, WizardActionsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
/**
* @remarks
* Next and Submit carry distinct keys so React replaces the button instead of turning
* Next into a submit button while its click is still being handled, which submitted the
* form on arriving at the last step.
*/
export function WizardActions() {
const { navigation, form, steps, currentStepIndex } = useViewContext();
const { labels, variant, showStepCounter } = useViewConfig('actions', WizardActionsConfigSchema);
return (
<div className={cn('se-wizard-actions', variant === 'minimal' && 'se-wizard-actions--minimal')}>
<Button
data-se-control
type="button"
variant={variant === 'minimal' ? 'ghost' : 'outline'}
onClick={navigation.goToPreviousStep}
disabled={navigation.isFirstStep}
aria-label={labels.previousAriaLabel}
>
{labels.previous}
</Button>
{showStepCounter ? (
<Badge variant="secondary" aria-live="polite">
{formatStepLabel(labels.stepCounter, currentStepIndex + 1, steps.length)}
</Badge>
) : null}
<div className="se-wizard-actions__forward">
{navigation.isLastStep ? (
<Button key="submit" data-se-control type="submit" aria-label={labels.submitAriaLabel}>
{form.isSubmitting ? labels.submitting : labels.submit}
</Button>
) : (
<Button
key="next"
data-se-control
type="button"
onClick={navigation.goToNextStep}
disabled={!navigation.canGoNext}
aria-label={labels.nextAriaLabel}
>
{labels.next}
</Button>
)}
</div>
</div>
);
}
/*
* Layout of the wizard action bar: Previous on the left, the step counter between, Next or Submit on the right.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-wizard-actions) {
display: flex;
min-width: 0;
align-items: center;
justify-content: space-between;
gap: 1rem;
}
:where(.se-wizard-actions--minimal) {
width: 100%;
}
:where(.se-wizard-actions__forward) {
display: flex;
gap: 0.5rem;
}
import type { FormShellProps } from '@schema-engine/forms-react/primitives';
/** Styles live in `stack-shell.css`, which the app imports through `recipes.css`. */
export function StackShell({ slots }: FormShellProps) {
return (
<div className="se-stack-shell">
{slots.header}
{slots.progress}
{slots.content}
{slots.actions}
</div>
);
}
/*
* Stack shell styles for the React registry recipes.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The gap between the slots reads the semantic `size` token --se-space, as the Radiant stack does; the
* fallback is the look of an unpicked shell.
*
* Import this file into the `components` layer when the app uses Tailwind, so utility classes still outrank
* it: `@import "./components/schema-engine/forms/recipes/recipes.css" layer(components);`
*/
:where(.se-stack-shell) {
display: flex;
min-width: 0;
width: 100%;
max-width: 40rem;
flex-direction: column;
gap: var(--se-space, 1.5rem);
margin-inline: auto;
}
/*
* Generated entry point for the Schema Engine default recipe styles.
* Import this one file from the app's global stylesheet; each shell's file sits beside its component.
*/
@import './blocks/form-actions.css';
@import './blocks/minimal-progress.css';
@import './blocks/step-header.css';
@import './blocks/step-indicators.css';
@import './blocks/wizard-actions.css';
@import './shells/card-shell.css';
@import './shells/hero-shell.css';
@import './shells/sidebar-shell.css';
@import './shells/split-screen-shell.css';
@import './shells/stack-shell.css';
Card Wizard view.$type: 'card-wizard'
import { defineRecipe } from '@schema-engine/forms-react/primitives';
import { cardWizardSpec } from '@schema-engine/forms/recipes/built-in';
import { MinimalProgress } from '../blocks/minimal-progress';
import { StepHeader } from '../blocks/step-header';
import { WizardActions } from '../blocks/wizard-actions';
import { CardShell } from '../shells/card-shell';
export const CardWizardRecipe = defineRecipe(cardWizardSpec, {
shell: CardShell,
slots: { header: StepHeader, progress: MinimalProgress, actions: WizardActions },
});
import type { CSSProperties } from 'react';
import { formatStepLabel, MinimalProgressConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
/**
* @remarks
* A custom progress bar rather than a landmark or a `meter`: the form is partway through a
* task, not navigating, and the value is a step position. The track and fill are presentational;
* the visible percentage is hidden from assistive technology because `aria-valuetext` already
* announces the step. The bar is named by the visible label so the two cannot drift apart.
*/
export function MinimalProgress() {
const { form, steps, currentStepIndex } = useViewContext();
const { showPercentage, labels } = useViewConfig('progress', MinimalProgressConfigSchema);
const labelId = `${form.id}-progress-label`;
const progressValue = Math.round(((currentStepIndex + 1) / steps.length) * 100);
const fillStyle: CSSProperties & Record<'--se-progress', string> = { '--se-progress': `${progressValue}%` };
return (
<div className="se-minimal-progress">
<div className="se-minimal-progress__labels text-sm">
<span id={labelId}>{labels.progress}</span>
{showPercentage ? (
<span aria-hidden className="text-muted-foreground tabular-nums">
{progressValue}%
</span>
) : null}
</div>
<div
role="progressbar"
aria-labelledby={labelId}
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={progressValue}
aria-valuetext={formatStepLabel(labels.valueText, currentStepIndex + 1, steps.length)}
className="se-minimal-progress__track bg-secondary"
>
<div aria-hidden className="se-minimal-progress__fill bg-primary" style={fillStyle} />
</div>
</div>
);
}
/*
* Layout of the minimal progress bar.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The fill's width is data: the component hands it over as the custom property --se-progress (`50%`), so no
* inline style carries layout. Colours stay with your ui theme (Tailwind classes on the track and the fill).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-minimal-progress) {
display: flex;
width: 100%;
min-width: 0;
flex-direction: column;
gap: 0.5rem;
}
:where(.se-minimal-progress__labels) {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
}
:where(.se-minimal-progress__track) {
width: 100%;
height: 0.5rem;
overflow: hidden;
border-radius: 999px;
}
:where(.se-minimal-progress__fill) {
width: var(--se-progress, 0%);
height: 100%;
border-radius: inherit;
}
import type { ElementType } from 'react';
import { formatStepLabel, StepHeaderConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useActiveStep, useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { cn } from '@/components/schema-engine/forms/lib/utils';
const titleSizes = {
sm: 'text-xl',
md: 'text-2xl',
lg: 'text-4xl',
} as const;
export function StepHeader() {
const { form } = useViewContext();
const step = useActiveStep();
const {
showDescription,
showStepCounter,
labels,
size,
align,
fallbackToFormTitle,
titleAs,
inheritColor,
counterPlacement,
} = useViewConfig('header', StepHeaderConfigSchema);
const title = step.title || (fallbackToFormTitle ? form.title : undefined);
const description = step.description || form.description;
const counterText = showStepCounter ? formatStepLabel(labels.stepCounter, step.index + 1, step.total) : null;
const Title = titleAs as ElementType;
if (!title && !description && !counterText) return null;
return (
<header
data-align={align}
className={cn('se-step-header', inheritColor && 'se-step-header--inherit-color text-inherit')}
>
{counterText && counterPlacement === 'before' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
{title ? <Title className={cn('font-bold tracking-tight', titleSizes[size])}>{title}</Title> : null}
{showDescription && description ? (
<p className={cn('text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>{description}</p>
) : null}
{counterText && counterPlacement === 'after' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
</header>
);
}
/*
* Layout of the step header block.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The title scale and colours stay with your ui theme (Tailwind classes on the title and the counter).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-step-header) {
display: flex;
flex-direction: column;
gap: 0.5rem;
max-width: none;
}
:where(.se-step-header[data-align='start']) {
text-align: left;
}
:where(.se-step-header[data-align='center']) {
text-align: center;
}
:where(.se-step-header--inherit-color) {
color: inherit;
}
import { formatStepLabel, WizardActionsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
/**
* @remarks
* Next and Submit carry distinct keys so React replaces the button instead of turning
* Next into a submit button while its click is still being handled, which submitted the
* form on arriving at the last step.
*/
export function WizardActions() {
const { navigation, form, steps, currentStepIndex } = useViewContext();
const { labels, variant, showStepCounter } = useViewConfig('actions', WizardActionsConfigSchema);
return (
<div className={cn('se-wizard-actions', variant === 'minimal' && 'se-wizard-actions--minimal')}>
<Button
data-se-control
type="button"
variant={variant === 'minimal' ? 'ghost' : 'outline'}
onClick={navigation.goToPreviousStep}
disabled={navigation.isFirstStep}
aria-label={labels.previousAriaLabel}
>
{labels.previous}
</Button>
{showStepCounter ? (
<Badge variant="secondary" aria-live="polite">
{formatStepLabel(labels.stepCounter, currentStepIndex + 1, steps.length)}
</Badge>
) : null}
<div className="se-wizard-actions__forward">
{navigation.isLastStep ? (
<Button key="submit" data-se-control type="submit" aria-label={labels.submitAriaLabel}>
{form.isSubmitting ? labels.submitting : labels.submit}
</Button>
) : (
<Button
key="next"
data-se-control
type="button"
onClick={navigation.goToNextStep}
disabled={!navigation.canGoNext}
aria-label={labels.nextAriaLabel}
>
{labels.next}
</Button>
)}
</div>
</div>
);
}
/*
* Layout of the wizard action bar: Previous on the left, the step counter between, Next or Submit on the right.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-wizard-actions) {
display: flex;
min-width: 0;
align-items: center;
justify-content: space-between;
gap: 1rem;
}
:where(.se-wizard-actions--minimal) {
width: 100%;
}
:where(.se-wizard-actions__forward) {
display: flex;
gap: 0.5rem;
}
import { getAppearanceAttributes } from '@schema-engine/layout';
import { getSlotConfig } from '@schema-engine/forms/recipes';
import { CardShellConfigSchema } from '@schema-engine/forms/recipes/built-in';
import type { FormShellProps } from '@schema-engine/forms-react/primitives';
/**
* Styles live in `card-shell.css`, which the app imports through `recipes.css`.
*
* @remarks
* The card's `appearance` (`size`, `surface`) is emitted as `data-se-*` attributes; the layout theme's
* token rules turn them into `--se-space`, `--se-measure`, `--se-border-width`, `--se-shadow` and
* `--se-surface-background`, which the stylesheet reads. The shell sets no inline style, so a host
* class on the card or a section overrides it.
*/
export function CardShell({ slots, viewConfig }: FormShellProps) {
const { appearance } = getSlotConfig(viewConfig, 'shell', CardShellConfigSchema);
return (
<div className="se-card-shell">
<div className="se-card-shell__card" {...getAppearanceAttributes(appearance)}>
{slots.header ? (
<div className="se-card-shell__header se-card-shell__section">{slots.header}</div>
) : null}
<div className="se-card-shell__content se-card-shell__section">
{slots.progress}
{slots.content}
{slots.actions}
</div>
</div>
</div>
);
}
/*
* Card shell styles for the React registry recipes.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The card reads the semantic appearance tokens the layout theme declares for the `size` and `surface`
* axes (--se-space, --se-measure, --se-border-width, --se-shadow, --se-surface-background); the
* fallbacks are the look of an unpicked card and follow the app's shadcn theme variables.
*
* Import this file into the `components` layer when the app uses Tailwind, so utility classes still
* outrank it: `@import "./components/schema-engine/forms/recipes/recipes.css" layer(components);`
*/
:where(.se-card-shell) {
display: flex;
min-height: 100svh;
align-items: center;
justify-content: center;
padding: 1rem;
background-color: color-mix(in srgb, var(--muted, transparent) 30%, transparent);
}
@media (min-width: 768px) {
:where(.se-card-shell) {
padding: 2rem;
}
}
:where(.se-card-shell__card) {
box-sizing: border-box;
width: 100%;
max-width: var(--se-measure, 28rem);
border: var(--se-border-width, 1px) solid var(--border, currentColor);
border-radius: calc(var(--radius, 0.5rem) + 4px);
background-color: var(--se-surface-background, var(--card, #fff));
color: var(--card-foreground, inherit);
box-shadow: var(--se-shadow, 0 8px 24px color-mix(in srgb, var(--on-surface, #000) 10%, transparent));
}
:where(.se-card-shell__section) {
padding: var(--se-space, 1.5rem);
}
:where(.se-card-shell__header) {
border-bottom: 1px solid var(--border, currentColor);
text-align: center;
}
:where(.se-card-shell__content) {
display: flex;
min-width: 0;
flex-direction: column;
gap: 1.5rem;
}
/*
* Generated entry point for the Schema Engine default recipe styles.
* Import this one file from the app's global stylesheet; each shell's file sits beside its component.
*/
@import './blocks/form-actions.css';
@import './blocks/minimal-progress.css';
@import './blocks/step-header.css';
@import './blocks/step-indicators.css';
@import './blocks/wizard-actions.css';
@import './shells/card-shell.css';
@import './shells/hero-shell.css';
@import './shells/sidebar-shell.css';
@import './shells/split-screen-shell.css';
@import './shells/stack-shell.css';
Hero Wizard view.$type: 'hero-wizard'
import { defineRecipe } from '@schema-engine/forms-react/primitives';
import { heroWizardSpec } from '@schema-engine/forms/recipes/built-in';
import { MinimalProgress } from '../blocks/minimal-progress';
import { StepHeader } from '../blocks/step-header';
import { WizardActions } from '../blocks/wizard-actions';
import { HeroShell } from '../shells/hero-shell';
export const HeroWizardRecipe = defineRecipe(heroWizardSpec, {
shell: HeroShell,
slots: { header: StepHeader, progress: MinimalProgress, actions: WizardActions },
});
import type { CSSProperties } from 'react';
import { formatStepLabel, MinimalProgressConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
/**
* @remarks
* A custom progress bar rather than a landmark or a `meter`: the form is partway through a
* task, not navigating, and the value is a step position. The track and fill are presentational;
* the visible percentage is hidden from assistive technology because `aria-valuetext` already
* announces the step. The bar is named by the visible label so the two cannot drift apart.
*/
export function MinimalProgress() {
const { form, steps, currentStepIndex } = useViewContext();
const { showPercentage, labels } = useViewConfig('progress', MinimalProgressConfigSchema);
const labelId = `${form.id}-progress-label`;
const progressValue = Math.round(((currentStepIndex + 1) / steps.length) * 100);
const fillStyle: CSSProperties & Record<'--se-progress', string> = { '--se-progress': `${progressValue}%` };
return (
<div className="se-minimal-progress">
<div className="se-minimal-progress__labels text-sm">
<span id={labelId}>{labels.progress}</span>
{showPercentage ? (
<span aria-hidden className="text-muted-foreground tabular-nums">
{progressValue}%
</span>
) : null}
</div>
<div
role="progressbar"
aria-labelledby={labelId}
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={progressValue}
aria-valuetext={formatStepLabel(labels.valueText, currentStepIndex + 1, steps.length)}
className="se-minimal-progress__track bg-secondary"
>
<div aria-hidden className="se-minimal-progress__fill bg-primary" style={fillStyle} />
</div>
</div>
);
}
/*
* Layout of the minimal progress bar.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The fill's width is data: the component hands it over as the custom property --se-progress (`50%`), so no
* inline style carries layout. Colours stay with your ui theme (Tailwind classes on the track and the fill).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-minimal-progress) {
display: flex;
width: 100%;
min-width: 0;
flex-direction: column;
gap: 0.5rem;
}
:where(.se-minimal-progress__labels) {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
}
:where(.se-minimal-progress__track) {
width: 100%;
height: 0.5rem;
overflow: hidden;
border-radius: 999px;
}
:where(.se-minimal-progress__fill) {
width: var(--se-progress, 0%);
height: 100%;
border-radius: inherit;
}
import type { ElementType } from 'react';
import { formatStepLabel, StepHeaderConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useActiveStep, useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { cn } from '@/components/schema-engine/forms/lib/utils';
const titleSizes = {
sm: 'text-xl',
md: 'text-2xl',
lg: 'text-4xl',
} as const;
export function StepHeader() {
const { form } = useViewContext();
const step = useActiveStep();
const {
showDescription,
showStepCounter,
labels,
size,
align,
fallbackToFormTitle,
titleAs,
inheritColor,
counterPlacement,
} = useViewConfig('header', StepHeaderConfigSchema);
const title = step.title || (fallbackToFormTitle ? form.title : undefined);
const description = step.description || form.description;
const counterText = showStepCounter ? formatStepLabel(labels.stepCounter, step.index + 1, step.total) : null;
const Title = titleAs as ElementType;
if (!title && !description && !counterText) return null;
return (
<header
data-align={align}
className={cn('se-step-header', inheritColor && 'se-step-header--inherit-color text-inherit')}
>
{counterText && counterPlacement === 'before' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
{title ? <Title className={cn('font-bold tracking-tight', titleSizes[size])}>{title}</Title> : null}
{showDescription && description ? (
<p className={cn('text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>{description}</p>
) : null}
{counterText && counterPlacement === 'after' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
</header>
);
}
/*
* Layout of the step header block.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The title scale and colours stay with your ui theme (Tailwind classes on the title and the counter).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-step-header) {
display: flex;
flex-direction: column;
gap: 0.5rem;
max-width: none;
}
:where(.se-step-header[data-align='start']) {
text-align: left;
}
:where(.se-step-header[data-align='center']) {
text-align: center;
}
:where(.se-step-header--inherit-color) {
color: inherit;
}
import { formatStepLabel, WizardActionsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
/**
* @remarks
* Next and Submit carry distinct keys so React replaces the button instead of turning
* Next into a submit button while its click is still being handled, which submitted the
* form on arriving at the last step.
*/
export function WizardActions() {
const { navigation, form, steps, currentStepIndex } = useViewContext();
const { labels, variant, showStepCounter } = useViewConfig('actions', WizardActionsConfigSchema);
return (
<div className={cn('se-wizard-actions', variant === 'minimal' && 'se-wizard-actions--minimal')}>
<Button
data-se-control
type="button"
variant={variant === 'minimal' ? 'ghost' : 'outline'}
onClick={navigation.goToPreviousStep}
disabled={navigation.isFirstStep}
aria-label={labels.previousAriaLabel}
>
{labels.previous}
</Button>
{showStepCounter ? (
<Badge variant="secondary" aria-live="polite">
{formatStepLabel(labels.stepCounter, currentStepIndex + 1, steps.length)}
</Badge>
) : null}
<div className="se-wizard-actions__forward">
{navigation.isLastStep ? (
<Button key="submit" data-se-control type="submit" aria-label={labels.submitAriaLabel}>
{form.isSubmitting ? labels.submitting : labels.submit}
</Button>
) : (
<Button
key="next"
data-se-control
type="button"
onClick={navigation.goToNextStep}
disabled={!navigation.canGoNext}
aria-label={labels.nextAriaLabel}
>
{labels.next}
</Button>
)}
</div>
</div>
);
}
/*
* Layout of the wizard action bar: Previous on the left, the step counter between, Next or Submit on the right.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-wizard-actions) {
display: flex;
min-width: 0;
align-items: center;
justify-content: space-between;
gap: 1rem;
}
:where(.se-wizard-actions--minimal) {
width: 100%;
}
:where(.se-wizard-actions__forward) {
display: flex;
gap: 0.5rem;
}
import { getAppearanceAttributes } from '@schema-engine/layout';
import { getSlotConfig } from '@schema-engine/forms/recipes';
import { HeroShellConfigSchema } from '@schema-engine/forms/recipes/built-in';
import type { FormShellProps } from '@schema-engine/forms-react/primitives';
/**
* Styles live in `hero-shell.css`, which the app imports through `recipes.css`.
*
* @remarks
* The shell's `appearance` (`size`) is emitted as `data-se-*` attributes and the layout theme's token
* rules turn it into `--se-space`, which the stylesheet reads. The background image is data, so it stays
* an inline `background-image` (a relative URL resolves against the page, as in Radiant); the position and
* size are the stylesheet's. What stays as Tailwind classes is the shadcn theme's colour (`bg-muted`,
* `bg-card/95`).
*/
export function HeroShell({ slots, viewConfig }: FormShellProps) {
const { appearance, backgroundImage, backgroundVideo, contentWidth } = getSlotConfig(
viewConfig,
'shell',
HeroShellConfigSchema,
);
return (
<div
className="se-hero-shell bg-muted text-primary-foreground"
style={backgroundImage ? { backgroundImage: `url(${JSON.stringify(backgroundImage)})` } : undefined}
{...getAppearanceAttributes(appearance)}
>
{backgroundVideo ? (
<video autoPlay muted loop playsInline src={backgroundVideo} className="se-hero-shell__video" />
) : null}
<div className="se-hero-shell__overlay" />
<div className={`se-hero-shell__content se-hero-shell__content--${contentWidth}`}>
{slots.header ? <div className="se-hero-shell__header">{slots.header}</div> : null}
<div className="se-hero-shell__form bg-card/95 text-card-foreground shadow-lg">
{slots.progress}
{slots.content}
{slots.actions}
</div>
</div>
</div>
);
}
/*
* Hero shell styles for the React registry recipes.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The shell reads the semantic `size` token --se-space for its padding and the gaps of its content, as the
* Radiant hero does; the fallbacks are the look of an unpicked hero. The background image is data and stays
* an inline `background-image` on the shell, so no inline style carries layout.
*
* Import this file into the `components` layer when the app uses Tailwind, so utility classes still outrank
* it: `@import "./components/schema-engine/forms/recipes/recipes.css" layer(components);`
*/
:where(.se-hero-shell) {
position: relative;
isolation: isolate;
display: flex;
box-sizing: border-box;
width: 100%;
min-height: 100svh;
align-items: center;
justify-content: center;
overflow: hidden;
padding: var(--se-space, 2rem);
background-position: center;
background-size: cover;
}
:where(.se-hero-shell__video) {
position: absolute;
inset: 0;
z-index: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
:where(.se-hero-shell__overlay) {
position: absolute;
inset: 0;
z-index: 1;
background: rgb(0 0 0 / 0.5);
}
:where(.se-hero-shell__content) {
position: relative;
z-index: 2;
width: 100%;
text-align: center;
}
:where(.se-hero-shell__content--sm) {
max-width: 24rem;
}
:where(.se-hero-shell__content--md) {
max-width: 28rem;
}
:where(.se-hero-shell__content--lg) {
max-width: 32rem;
}
:where(.se-hero-shell__content--xl) {
max-width: 36rem;
}
:where(.se-hero-shell__header) {
margin-bottom: var(--se-space, 2rem);
}
:where(.se-hero-shell__form) {
display: flex;
flex-direction: column;
gap: var(--se-space, 1.5rem);
padding: var(--se-space, 2rem);
border-radius: var(--radius, 0.5rem);
text-align: left;
}
/*
* Generated entry point for the Schema Engine default recipe styles.
* Import this one file from the app's global stylesheet; each shell's file sits beside its component.
*/
@import './blocks/form-actions.css';
@import './blocks/minimal-progress.css';
@import './blocks/step-header.css';
@import './blocks/step-indicators.css';
@import './blocks/wizard-actions.css';
@import './shells/card-shell.css';
@import './shells/hero-shell.css';
@import './shells/sidebar-shell.css';
@import './shells/split-screen-shell.css';
@import './shells/stack-shell.css';
Sidebar Wizard view.$type: 'sidebar-wizard'
import { defineRecipe } from '@schema-engine/forms-react/primitives';
import { sidebarWizardSpec } from '@schema-engine/forms/recipes/built-in';
import { StepHeader } from '../blocks/step-header';
import { StepIndicators } from '../blocks/step-indicators';
import { WizardActions } from '../blocks/wizard-actions';
import { SidebarShell } from '../shells/sidebar-shell';
export const SidebarWizardRecipe = defineRecipe(sidebarWizardSpec, {
shell: SidebarShell,
slots: { header: StepHeader, progress: StepIndicators, actions: WizardActions },
});
import type { ElementType } from 'react';
import { formatStepLabel, StepHeaderConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useActiveStep, useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { cn } from '@/components/schema-engine/forms/lib/utils';
const titleSizes = {
sm: 'text-xl',
md: 'text-2xl',
lg: 'text-4xl',
} as const;
export function StepHeader() {
const { form } = useViewContext();
const step = useActiveStep();
const {
showDescription,
showStepCounter,
labels,
size,
align,
fallbackToFormTitle,
titleAs,
inheritColor,
counterPlacement,
} = useViewConfig('header', StepHeaderConfigSchema);
const title = step.title || (fallbackToFormTitle ? form.title : undefined);
const description = step.description || form.description;
const counterText = showStepCounter ? formatStepLabel(labels.stepCounter, step.index + 1, step.total) : null;
const Title = titleAs as ElementType;
if (!title && !description && !counterText) return null;
return (
<header
data-align={align}
className={cn('se-step-header', inheritColor && 'se-step-header--inherit-color text-inherit')}
>
{counterText && counterPlacement === 'before' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
{title ? <Title className={cn('font-bold tracking-tight', titleSizes[size])}>{title}</Title> : null}
{showDescription && description ? (
<p className={cn('text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>{description}</p>
) : null}
{counterText && counterPlacement === 'after' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
</header>
);
}
/*
* Layout of the step header block.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The title scale and colours stay with your ui theme (Tailwind classes on the title and the counter).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-step-header) {
display: flex;
flex-direction: column;
gap: 0.5rem;
max-width: none;
}
:where(.se-step-header[data-align='start']) {
text-align: left;
}
:where(.se-step-header[data-align='center']) {
text-align: center;
}
:where(.se-step-header--inherit-color) {
color: inherit;
}
import { useEffect, useRef } from 'react';
import { Check } from 'lucide-react';
import { formatStepLabel, StepIndicatorsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useFormNavigation, useIsMobile, useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
export function StepIndicators() {
const { steps, currentStepIndex } = useViewContext();
const navigation = useFormNavigation();
const { orientation, showStepNumbers, showStepTitles, showStepDescriptions, labels } = useViewConfig(
'progress',
StepIndicatorsConfigSchema,
);
const isMobile = useIsMobile();
const sidebar = orientation === 'sidebar' && !isMobile;
const stepRefs = useRef<(HTMLLIElement | null)[]>([]);
const containerRef = useRef<HTMLElement>(null);
useEffect(() => {
const currentStepElement = stepRefs.current[currentStepIndex];
if (currentStepElement && containerRef.current) {
currentStepElement.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });
}
}, [currentStepIndex]);
return (
<nav
aria-label={labels.regionAriaLabel}
ref={containerRef}
className={cn('se-step-indicators', sidebar && 'se-step-indicators--sidebar')}
>
<ol className="se-step-indicators__list">
{steps.map((step, index) => {
const isDisabled = !step.isActive && !navigation.canGoToStep(step.id);
return (
<li
key={step.id}
ref={(element) => {
stepRefs.current[index] = element;
}}
className="se-step-indicators__item"
>
<Button
type="button"
variant="ghost"
onClick={() => navigation.goToStep(step.id)}
disabled={isDisabled}
aria-current={step.isActive ? 'step' : undefined}
className={cn(
'se-step-indicators__button h-auto whitespace-normal rounded-xl p-3',
sidebar
? 'flex-row items-center justify-start text-left'
: 'flex-col items-center text-center',
step.isActive && 'bg-muted',
)}
>
{showStepNumbers ? (
<span
className={cn(
'se-step-indicators__number border text-sm font-semibold tabular-nums',
step.isCompleted && 'border-primary bg-primary text-primary-foreground',
step.isActive && !step.isCompleted && 'border-primary text-primary',
!step.isActive &&
!step.isCompleted &&
'border-border text-muted-foreground',
)}
>
{step.isCompleted ? <Check className="size-4" aria-hidden /> : index + 1}
</span>
) : null}
{showStepTitles || (showStepDescriptions && step.description) ? (
<span className="se-step-indicators__copy">
{showStepTitles ? (
<span
className={cn(
'se-step-indicators__title text-sm font-medium',
step.isActive ? 'text-foreground' : 'text-muted-foreground',
)}
>
{step.title ||
formatStepLabel(labels.untitledStep, index + 1, steps.length)}
</span>
) : null}
{showStepDescriptions && step.description ? (
<span className="block text-xs text-muted-foreground">
{step.description}
</span>
) : null}
</span>
) : null}
{step.isCompleted ? (
<span className="sr-only">
{formatStepLabel(labels.completed, index + 1, steps.length)}
</span>
) : null}
</Button>
</li>
);
})}
</ol>
</nav>
);
}
/*
* Layout of the step indicators: a row of steps that scrolls sideways, or a column beside the form.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* Colours and the step number's border stay with your ui theme (Tailwind classes on the elements).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-step-indicators) {
position: relative;
display: flex;
width: 100%;
min-width: 0;
overflow-x: auto;
scroll-behavior: smooth;
}
:where(.se-step-indicators--sidebar) {
overflow: visible;
}
:where(.se-step-indicators__list) {
position: relative;
display: flex;
min-width: 100%;
margin: 0;
padding: 0;
gap: 0.5rem;
list-style: none;
}
:where(.se-step-indicators--sidebar .se-step-indicators__list) {
min-width: 0;
flex-direction: column;
gap: 0.25rem;
}
:where(.se-step-indicators__item) {
display: flex;
flex: 1 1 0;
min-width: 7.5rem;
}
:where(.se-step-indicators--sidebar .se-step-indicators__item) {
width: 100%;
min-width: 0;
}
:where(.se-step-indicators__button) {
display: flex;
width: 100%;
height: auto;
min-width: 0;
flex-shrink: 1;
flex-direction: column;
align-items: center;
gap: 0.5rem;
padding: 0.75rem;
border-radius: var(--radius-control, 0.75rem);
text-align: center;
white-space: normal;
}
:where(.se-step-indicators--sidebar .se-step-indicators__button) {
flex-direction: row;
justify-content: flex-start;
text-align: left;
}
:where(.se-step-indicators__number) {
display: inline-flex;
width: 2rem;
height: 2rem;
flex-shrink: 0;
align-items: center;
justify-content: center;
border-radius: 999px;
}
:where(.se-step-indicators__copy) {
display: flex;
width: 100%;
min-width: 0;
flex-direction: column;
gap: 0.25rem;
align-items: center;
text-align: center;
line-height: 1.25rem;
}
:where(.se-step-indicators--sidebar .se-step-indicators__copy) {
width: auto;
align-items: flex-start;
text-align: left;
}
:where(.se-step-indicators__title) {
display: block;
overflow-wrap: break-word;
text-wrap: balance;
}
import { formatStepLabel, WizardActionsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
/**
* @remarks
* Next and Submit carry distinct keys so React replaces the button instead of turning
* Next into a submit button while its click is still being handled, which submitted the
* form on arriving at the last step.
*/
export function WizardActions() {
const { navigation, form, steps, currentStepIndex } = useViewContext();
const { labels, variant, showStepCounter } = useViewConfig('actions', WizardActionsConfigSchema);
return (
<div className={cn('se-wizard-actions', variant === 'minimal' && 'se-wizard-actions--minimal')}>
<Button
data-se-control
type="button"
variant={variant === 'minimal' ? 'ghost' : 'outline'}
onClick={navigation.goToPreviousStep}
disabled={navigation.isFirstStep}
aria-label={labels.previousAriaLabel}
>
{labels.previous}
</Button>
{showStepCounter ? (
<Badge variant="secondary" aria-live="polite">
{formatStepLabel(labels.stepCounter, currentStepIndex + 1, steps.length)}
</Badge>
) : null}
<div className="se-wizard-actions__forward">
{navigation.isLastStep ? (
<Button key="submit" data-se-control type="submit" aria-label={labels.submitAriaLabel}>
{form.isSubmitting ? labels.submitting : labels.submit}
</Button>
) : (
<Button
key="next"
data-se-control
type="button"
onClick={navigation.goToNextStep}
disabled={!navigation.canGoNext}
aria-label={labels.nextAriaLabel}
>
{labels.next}
</Button>
)}
</div>
</div>
);
}
/*
* Layout of the wizard action bar: Previous on the left, the step counter between, Next or Submit on the right.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-wizard-actions) {
display: flex;
min-width: 0;
align-items: center;
justify-content: space-between;
gap: 1rem;
}
:where(.se-wizard-actions--minimal) {
width: 100%;
}
:where(.se-wizard-actions__forward) {
display: flex;
gap: 0.5rem;
}
import { Separator } from '@/components/ui/separator';
import { getAppearanceAttributes } from '@schema-engine/layout';
import { useIsMobile } from '@schema-engine/forms-react/hooks';
import { getSlotConfig } from '@schema-engine/forms/recipes';
import { SidebarShellConfigSchema } from '@schema-engine/forms/recipes/built-in';
import type { FormShellProps } from '@schema-engine/forms-react/primitives';
/**
* Styles live in `sidebar-shell.css`, which the app imports through `recipes.css`.
*
* @remarks
* The shell's `appearance` (`size`) is emitted as `data-se-*` attributes and the layout theme's token
* rules turn it into `--se-space`, which the stylesheet reads for the gaps. On a small screen the
* progress slot joins the column instead of sitting beside it.
*/
export function SidebarShell({ slots, viewConfig }: FormShellProps) {
const isMobile = useIsMobile();
const { appearance, showSeparator } = getSlotConfig(viewConfig, 'shell', SidebarShellConfigSchema);
const appearanceAttributes = getAppearanceAttributes(appearance);
if (isMobile) {
return (
<div className="se-sidebar-shell se-sidebar-shell--stacked" {...appearanceAttributes}>
{slots.header}
{slots.progress}
{slots.content}
{slots.actions}
</div>
);
}
return (
<div className="se-sidebar-shell" {...appearanceAttributes}>
{slots.progress ? <aside className="se-sidebar-shell__progress">{slots.progress}</aside> : null}
{showSeparator ? (
<Separator orientation="vertical" className="se-sidebar-shell__separator h-auto w-px bg-border" />
) : null}
<div className="se-sidebar-shell__main">
{slots.header}
{slots.content}
{slots.actions}
</div>
</div>
);
}
/*
* Sidebar shell styles for the React registry recipes.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The gaps read the semantic `size` token --se-space, as the Radiant sidebar does; the fallbacks are the look
* of an unpicked shell. The stacked variant is the small-screen layout, where the progress slot joins the
* column.
*
* Import this file into the `components` layer when the app uses Tailwind, so utility classes still outrank
* it: `@import "./components/schema-engine/forms/recipes/recipes.css" layer(components);`
*/
:where(.se-sidebar-shell) {
display: flex;
width: 100%;
flex-direction: row;
align-items: stretch;
}
:where(.se-sidebar-shell--stacked) {
min-width: 0;
max-width: 40rem;
flex-direction: column;
gap: var(--se-space, 1.5rem);
margin-inline: auto;
}
:where(.se-sidebar-shell__progress) {
flex-shrink: 0;
align-self: stretch;
width: 18rem;
padding-right: var(--se-space, 2rem);
}
:where(.se-sidebar-shell__separator) {
align-self: stretch;
width: 1px;
height: auto;
}
:where(.se-sidebar-shell__main) {
display: flex;
min-width: 0;
flex: 1;
flex-direction: column;
gap: var(--se-space, 1.5rem);
padding-left: var(--se-space, 2rem);
}
/*
* Generated entry point for the Schema Engine default recipe styles.
* Import this one file from the app's global stylesheet; each shell's file sits beside its component.
*/
@import './blocks/form-actions.css';
@import './blocks/minimal-progress.css';
@import './blocks/step-header.css';
@import './blocks/step-indicators.css';
@import './blocks/wizard-actions.css';
@import './shells/card-shell.css';
@import './shells/hero-shell.css';
@import './shells/sidebar-shell.css';
@import './shells/split-screen-shell.css';
@import './shells/stack-shell.css';
Split Screen Wizard view.$type: 'split-screen-wizard'
import { defineRecipe } from '@schema-engine/forms-react/primitives';
import { splitScreenWizardSpec } from '@schema-engine/forms/recipes/built-in';
import { StepHeader } from '../blocks/step-header';
import { StepIndicators } from '../blocks/step-indicators';
import { WizardActions } from '../blocks/wizard-actions';
import { SplitScreenShell } from '../shells/split-screen-shell';
export const SplitScreenWizardRecipe = defineRecipe(splitScreenWizardSpec, {
shell: SplitScreenShell,
slots: { header: StepHeader, progress: StepIndicators, actions: WizardActions },
});
import type { ElementType } from 'react';
import { formatStepLabel, StepHeaderConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useActiveStep, useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { cn } from '@/components/schema-engine/forms/lib/utils';
const titleSizes = {
sm: 'text-xl',
md: 'text-2xl',
lg: 'text-4xl',
} as const;
export function StepHeader() {
const { form } = useViewContext();
const step = useActiveStep();
const {
showDescription,
showStepCounter,
labels,
size,
align,
fallbackToFormTitle,
titleAs,
inheritColor,
counterPlacement,
} = useViewConfig('header', StepHeaderConfigSchema);
const title = step.title || (fallbackToFormTitle ? form.title : undefined);
const description = step.description || form.description;
const counterText = showStepCounter ? formatStepLabel(labels.stepCounter, step.index + 1, step.total) : null;
const Title = titleAs as ElementType;
if (!title && !description && !counterText) return null;
return (
<header
data-align={align}
className={cn('se-step-header', inheritColor && 'se-step-header--inherit-color text-inherit')}
>
{counterText && counterPlacement === 'before' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
{title ? <Title className={cn('font-bold tracking-tight', titleSizes[size])}>{title}</Title> : null}
{showDescription && description ? (
<p className={cn('text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>{description}</p>
) : null}
{counterText && counterPlacement === 'after' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
</header>
);
}
/*
* Layout of the step header block.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The title scale and colours stay with your ui theme (Tailwind classes on the title and the counter).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-step-header) {
display: flex;
flex-direction: column;
gap: 0.5rem;
max-width: none;
}
:where(.se-step-header[data-align='start']) {
text-align: left;
}
:where(.se-step-header[data-align='center']) {
text-align: center;
}
:where(.se-step-header--inherit-color) {
color: inherit;
}
import { useEffect, useRef } from 'react';
import { Check } from 'lucide-react';
import { formatStepLabel, StepIndicatorsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useFormNavigation, useIsMobile, useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
export function StepIndicators() {
const { steps, currentStepIndex } = useViewContext();
const navigation = useFormNavigation();
const { orientation, showStepNumbers, showStepTitles, showStepDescriptions, labels } = useViewConfig(
'progress',
StepIndicatorsConfigSchema,
);
const isMobile = useIsMobile();
const sidebar = orientation === 'sidebar' && !isMobile;
const stepRefs = useRef<(HTMLLIElement | null)[]>([]);
const containerRef = useRef<HTMLElement>(null);
useEffect(() => {
const currentStepElement = stepRefs.current[currentStepIndex];
if (currentStepElement && containerRef.current) {
currentStepElement.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });
}
}, [currentStepIndex]);
return (
<nav
aria-label={labels.regionAriaLabel}
ref={containerRef}
className={cn('se-step-indicators', sidebar && 'se-step-indicators--sidebar')}
>
<ol className="se-step-indicators__list">
{steps.map((step, index) => {
const isDisabled = !step.isActive && !navigation.canGoToStep(step.id);
return (
<li
key={step.id}
ref={(element) => {
stepRefs.current[index] = element;
}}
className="se-step-indicators__item"
>
<Button
type="button"
variant="ghost"
onClick={() => navigation.goToStep(step.id)}
disabled={isDisabled}
aria-current={step.isActive ? 'step' : undefined}
className={cn(
'se-step-indicators__button h-auto whitespace-normal rounded-xl p-3',
sidebar
? 'flex-row items-center justify-start text-left'
: 'flex-col items-center text-center',
step.isActive && 'bg-muted',
)}
>
{showStepNumbers ? (
<span
className={cn(
'se-step-indicators__number border text-sm font-semibold tabular-nums',
step.isCompleted && 'border-primary bg-primary text-primary-foreground',
step.isActive && !step.isCompleted && 'border-primary text-primary',
!step.isActive &&
!step.isCompleted &&
'border-border text-muted-foreground',
)}
>
{step.isCompleted ? <Check className="size-4" aria-hidden /> : index + 1}
</span>
) : null}
{showStepTitles || (showStepDescriptions && step.description) ? (
<span className="se-step-indicators__copy">
{showStepTitles ? (
<span
className={cn(
'se-step-indicators__title text-sm font-medium',
step.isActive ? 'text-foreground' : 'text-muted-foreground',
)}
>
{step.title ||
formatStepLabel(labels.untitledStep, index + 1, steps.length)}
</span>
) : null}
{showStepDescriptions && step.description ? (
<span className="block text-xs text-muted-foreground">
{step.description}
</span>
) : null}
</span>
) : null}
{step.isCompleted ? (
<span className="sr-only">
{formatStepLabel(labels.completed, index + 1, steps.length)}
</span>
) : null}
</Button>
</li>
);
})}
</ol>
</nav>
);
}
/*
* Layout of the step indicators: a row of steps that scrolls sideways, or a column beside the form.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* Colours and the step number's border stay with your ui theme (Tailwind classes on the elements).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-step-indicators) {
position: relative;
display: flex;
width: 100%;
min-width: 0;
overflow-x: auto;
scroll-behavior: smooth;
}
:where(.se-step-indicators--sidebar) {
overflow: visible;
}
:where(.se-step-indicators__list) {
position: relative;
display: flex;
min-width: 100%;
margin: 0;
padding: 0;
gap: 0.5rem;
list-style: none;
}
:where(.se-step-indicators--sidebar .se-step-indicators__list) {
min-width: 0;
flex-direction: column;
gap: 0.25rem;
}
:where(.se-step-indicators__item) {
display: flex;
flex: 1 1 0;
min-width: 7.5rem;
}
:where(.se-step-indicators--sidebar .se-step-indicators__item) {
width: 100%;
min-width: 0;
}
:where(.se-step-indicators__button) {
display: flex;
width: 100%;
height: auto;
min-width: 0;
flex-shrink: 1;
flex-direction: column;
align-items: center;
gap: 0.5rem;
padding: 0.75rem;
border-radius: var(--radius-control, 0.75rem);
text-align: center;
white-space: normal;
}
:where(.se-step-indicators--sidebar .se-step-indicators__button) {
flex-direction: row;
justify-content: flex-start;
text-align: left;
}
:where(.se-step-indicators__number) {
display: inline-flex;
width: 2rem;
height: 2rem;
flex-shrink: 0;
align-items: center;
justify-content: center;
border-radius: 999px;
}
:where(.se-step-indicators__copy) {
display: flex;
width: 100%;
min-width: 0;
flex-direction: column;
gap: 0.25rem;
align-items: center;
text-align: center;
line-height: 1.25rem;
}
:where(.se-step-indicators--sidebar .se-step-indicators__copy) {
width: auto;
align-items: flex-start;
text-align: left;
}
:where(.se-step-indicators__title) {
display: block;
overflow-wrap: break-word;
text-wrap: balance;
}
import { formatStepLabel, WizardActionsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
/**
* @remarks
* Next and Submit carry distinct keys so React replaces the button instead of turning
* Next into a submit button while its click is still being handled, which submitted the
* form on arriving at the last step.
*/
export function WizardActions() {
const { navigation, form, steps, currentStepIndex } = useViewContext();
const { labels, variant, showStepCounter } = useViewConfig('actions', WizardActionsConfigSchema);
return (
<div className={cn('se-wizard-actions', variant === 'minimal' && 'se-wizard-actions--minimal')}>
<Button
data-se-control
type="button"
variant={variant === 'minimal' ? 'ghost' : 'outline'}
onClick={navigation.goToPreviousStep}
disabled={navigation.isFirstStep}
aria-label={labels.previousAriaLabel}
>
{labels.previous}
</Button>
{showStepCounter ? (
<Badge variant="secondary" aria-live="polite">
{formatStepLabel(labels.stepCounter, currentStepIndex + 1, steps.length)}
</Badge>
) : null}
<div className="se-wizard-actions__forward">
{navigation.isLastStep ? (
<Button key="submit" data-se-control type="submit" aria-label={labels.submitAriaLabel}>
{form.isSubmitting ? labels.submitting : labels.submit}
</Button>
) : (
<Button
key="next"
data-se-control
type="button"
onClick={navigation.goToNextStep}
disabled={!navigation.canGoNext}
aria-label={labels.nextAriaLabel}
>
{labels.next}
</Button>
)}
</div>
</div>
);
}
/*
* Layout of the wizard action bar: Previous on the left, the step counter between, Next or Submit on the right.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-wizard-actions) {
display: flex;
min-width: 0;
align-items: center;
justify-content: space-between;
gap: 1rem;
}
:where(.se-wizard-actions--minimal) {
width: 100%;
}
:where(.se-wizard-actions__forward) {
display: flex;
gap: 0.5rem;
}
import { getAppearanceAttributes } from '@schema-engine/layout';
import { getSlotConfig } from '@schema-engine/forms/recipes';
import { SplitScreenShellConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewContext } from '@schema-engine/forms-react/hooks';
import type { FormShellProps } from '@schema-engine/forms-react/primitives';
import { cn } from '@/components/schema-engine/forms/lib/utils';
/**
* Styles live in `split-screen-shell.css`, which the app imports through `recipes.css`.
*
* @remarks
* The panel shows the form title. When the recipe has a header slot, that header must set
* `fallbackToFormTitle: false` in its slot defaults, or the form title is repeated in the header
* for steps without a title. A custom recipe that reuses this shell with a header slot must set
* that default too.
*
* The shell's `appearance` (`size`) is emitted as `data-se-*` attributes and the layout theme's token
* rules turn it into `--se-space`, which the stylesheet reads for both panels. What stays as Tailwind
* classes is the shadcn theme's colour and type scale.
*/
export function SplitScreenShell({ slots, viewConfig }: FormShellProps) {
const {
appearance,
sideContent,
sidePlacement,
sideWidth,
contentAlignment: alignment,
} = getSlotConfig(viewConfig, 'shell', SplitScreenShellConfigSchema);
const { form, activeStep } = useViewContext();
const title = form.title || (slots.header ? undefined : activeStep.title);
return (
<div className="se-split-screen-shell" {...getAppearanceAttributes(appearance)}>
{title || sideContent ? (
<aside
className={cn(
'se-split-screen-shell__side bg-muted',
`se-split-screen-shell__side--${sideWidth}`,
sidePlacement === 'right' && 'se-split-screen-shell__side--right',
)}
>
{title ? (
<h2 className="se-split-screen-shell__title text-2xl font-semibold tracking-tight">{title}</h2>
) : null}
{sideContent ? (
<div className="se-split-screen-shell__side-content text-sm text-muted-foreground md:text-base">
{sideContent}
</div>
) : null}
</aside>
) : null}
<div className={cn('se-split-screen-shell__main', `se-split-screen-shell__main--${alignment}`)}>
{slots.header}
{slots.progress}
{slots.content}
{slots.actions ? <div className="se-split-screen-shell__actions">{slots.actions}</div> : null}
</div>
</div>
);
}
/*
* Split-screen shell styles for the React registry recipes.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The padding of both panels and the gap between the slots of the content panel read the semantic `size`
* token --se-space, as the Radiant split screen does; the fallbacks are the look of an unpicked shell.
*
* Import this file into the `components` layer when the app uses Tailwind, so utility classes still outrank
* it: `@import "./components/schema-engine/forms/recipes/recipes.css" layer(components);`
*/
:where(.se-split-screen-shell) {
display: flex;
flex-direction: column;
width: 100%;
min-height: 100svh;
}
@media (min-width: 768px) {
:where(.se-split-screen-shell) {
flex-direction: row;
}
}
:where(.se-split-screen-shell__side) {
display: flex;
flex-direction: column;
justify-content: center;
box-sizing: border-box;
width: 100%;
padding: var(--se-space, 1.5rem);
}
@media (min-width: 768px) {
:where(.se-split-screen-shell__side--narrow) {
width: 33.333%;
}
:where(.se-split-screen-shell__side--normal) {
width: 50%;
}
:where(.se-split-screen-shell__side--wide) {
width: 66.666%;
}
:where(.se-split-screen-shell__side--right) {
order: 2;
}
}
:where(.se-split-screen-shell__main) {
display: flex;
flex: 1;
flex-direction: column;
gap: var(--se-space, 1.5rem);
box-sizing: border-box;
min-width: 0;
padding: var(--se-space, 1.5rem);
overflow: auto;
}
:where(.se-split-screen-shell__main--top) {
justify-content: flex-start;
}
:where(.se-split-screen-shell__main--center) {
justify-content: center;
}
:where(.se-split-screen-shell__main--bottom) {
justify-content: flex-end;
}
:where(.se-split-screen-shell__actions) {
flex-shrink: 0;
margin-top: auto;
}
:where(.se-split-screen-shell__title) {
max-width: 28rem;
margin: 0;
}
:where(.se-split-screen-shell__side-content) {
max-width: 28rem;
margin: 0.75rem 0 0;
}
/*
* Generated entry point for the Schema Engine default recipe styles.
* Import this one file from the app's global stylesheet; each shell's file sits beside its component.
*/
@import './blocks/form-actions.css';
@import './blocks/minimal-progress.css';
@import './blocks/step-header.css';
@import './blocks/step-indicators.css';
@import './blocks/wizard-actions.css';
@import './shells/card-shell.css';
@import './shells/hero-shell.css';
@import './shells/sidebar-shell.css';
@import './shells/split-screen-shell.css';
@import './shells/stack-shell.css';
Wizard view.$type: 'wizard'
import { defineRecipe } from '@schema-engine/forms-react/primitives';
import { wizardSpec } from '@schema-engine/forms/recipes/built-in';
import { StepHeader } from '../blocks/step-header';
import { StepIndicators } from '../blocks/step-indicators';
import { WizardActions } from '../blocks/wizard-actions';
import { StackShell } from '../shells/stack-shell';
export const WizardRecipe = defineRecipe(wizardSpec, {
shell: StackShell,
slots: { header: StepHeader, progress: StepIndicators, actions: WizardActions },
});
import type { ElementType } from 'react';
import { formatStepLabel, StepHeaderConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useActiveStep, useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { cn } from '@/components/schema-engine/forms/lib/utils';
const titleSizes = {
sm: 'text-xl',
md: 'text-2xl',
lg: 'text-4xl',
} as const;
export function StepHeader() {
const { form } = useViewContext();
const step = useActiveStep();
const {
showDescription,
showStepCounter,
labels,
size,
align,
fallbackToFormTitle,
titleAs,
inheritColor,
counterPlacement,
} = useViewConfig('header', StepHeaderConfigSchema);
const title = step.title || (fallbackToFormTitle ? form.title : undefined);
const description = step.description || form.description;
const counterText = showStepCounter ? formatStepLabel(labels.stepCounter, step.index + 1, step.total) : null;
const Title = titleAs as ElementType;
if (!title && !description && !counterText) return null;
return (
<header
data-align={align}
className={cn('se-step-header', inheritColor && 'se-step-header--inherit-color text-inherit')}
>
{counterText && counterPlacement === 'before' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
{title ? <Title className={cn('font-bold tracking-tight', titleSizes[size])}>{title}</Title> : null}
{showDescription && description ? (
<p className={cn('text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>{description}</p>
) : null}
{counterText && counterPlacement === 'after' ? (
<p className={cn('text-sm text-muted-foreground', inheritColor && 'text-inherit opacity-80')}>
{counterText}
</p>
) : null}
</header>
);
}
/*
* Layout of the step header block.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The title scale and colours stay with your ui theme (Tailwind classes on the title and the counter).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-step-header) {
display: flex;
flex-direction: column;
gap: 0.5rem;
max-width: none;
}
:where(.se-step-header[data-align='start']) {
text-align: left;
}
:where(.se-step-header[data-align='center']) {
text-align: center;
}
:where(.se-step-header--inherit-color) {
color: inherit;
}
import { useEffect, useRef } from 'react';
import { Check } from 'lucide-react';
import { formatStepLabel, StepIndicatorsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useFormNavigation, useIsMobile, useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
export function StepIndicators() {
const { steps, currentStepIndex } = useViewContext();
const navigation = useFormNavigation();
const { orientation, showStepNumbers, showStepTitles, showStepDescriptions, labels } = useViewConfig(
'progress',
StepIndicatorsConfigSchema,
);
const isMobile = useIsMobile();
const sidebar = orientation === 'sidebar' && !isMobile;
const stepRefs = useRef<(HTMLLIElement | null)[]>([]);
const containerRef = useRef<HTMLElement>(null);
useEffect(() => {
const currentStepElement = stepRefs.current[currentStepIndex];
if (currentStepElement && containerRef.current) {
currentStepElement.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });
}
}, [currentStepIndex]);
return (
<nav
aria-label={labels.regionAriaLabel}
ref={containerRef}
className={cn('se-step-indicators', sidebar && 'se-step-indicators--sidebar')}
>
<ol className="se-step-indicators__list">
{steps.map((step, index) => {
const isDisabled = !step.isActive && !navigation.canGoToStep(step.id);
return (
<li
key={step.id}
ref={(element) => {
stepRefs.current[index] = element;
}}
className="se-step-indicators__item"
>
<Button
type="button"
variant="ghost"
onClick={() => navigation.goToStep(step.id)}
disabled={isDisabled}
aria-current={step.isActive ? 'step' : undefined}
className={cn(
'se-step-indicators__button h-auto whitespace-normal rounded-xl p-3',
sidebar
? 'flex-row items-center justify-start text-left'
: 'flex-col items-center text-center',
step.isActive && 'bg-muted',
)}
>
{showStepNumbers ? (
<span
className={cn(
'se-step-indicators__number border text-sm font-semibold tabular-nums',
step.isCompleted && 'border-primary bg-primary text-primary-foreground',
step.isActive && !step.isCompleted && 'border-primary text-primary',
!step.isActive &&
!step.isCompleted &&
'border-border text-muted-foreground',
)}
>
{step.isCompleted ? <Check className="size-4" aria-hidden /> : index + 1}
</span>
) : null}
{showStepTitles || (showStepDescriptions && step.description) ? (
<span className="se-step-indicators__copy">
{showStepTitles ? (
<span
className={cn(
'se-step-indicators__title text-sm font-medium',
step.isActive ? 'text-foreground' : 'text-muted-foreground',
)}
>
{step.title ||
formatStepLabel(labels.untitledStep, index + 1, steps.length)}
</span>
) : null}
{showStepDescriptions && step.description ? (
<span className="block text-xs text-muted-foreground">
{step.description}
</span>
) : null}
</span>
) : null}
{step.isCompleted ? (
<span className="sr-only">
{formatStepLabel(labels.completed, index + 1, steps.length)}
</span>
) : null}
</Button>
</li>
);
})}
</ol>
</nav>
);
}
/*
* Layout of the step indicators: a row of steps that scrolls sideways, or a column beside the form.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* Colours and the step number's border stay with your ui theme (Tailwind classes on the elements).
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-step-indicators) {
position: relative;
display: flex;
width: 100%;
min-width: 0;
overflow-x: auto;
scroll-behavior: smooth;
}
:where(.se-step-indicators--sidebar) {
overflow: visible;
}
:where(.se-step-indicators__list) {
position: relative;
display: flex;
min-width: 100%;
margin: 0;
padding: 0;
gap: 0.5rem;
list-style: none;
}
:where(.se-step-indicators--sidebar .se-step-indicators__list) {
min-width: 0;
flex-direction: column;
gap: 0.25rem;
}
:where(.se-step-indicators__item) {
display: flex;
flex: 1 1 0;
min-width: 7.5rem;
}
:where(.se-step-indicators--sidebar .se-step-indicators__item) {
width: 100%;
min-width: 0;
}
:where(.se-step-indicators__button) {
display: flex;
width: 100%;
height: auto;
min-width: 0;
flex-shrink: 1;
flex-direction: column;
align-items: center;
gap: 0.5rem;
padding: 0.75rem;
border-radius: var(--radius-control, 0.75rem);
text-align: center;
white-space: normal;
}
:where(.se-step-indicators--sidebar .se-step-indicators__button) {
flex-direction: row;
justify-content: flex-start;
text-align: left;
}
:where(.se-step-indicators__number) {
display: inline-flex;
width: 2rem;
height: 2rem;
flex-shrink: 0;
align-items: center;
justify-content: center;
border-radius: 999px;
}
:where(.se-step-indicators__copy) {
display: flex;
width: 100%;
min-width: 0;
flex-direction: column;
gap: 0.25rem;
align-items: center;
text-align: center;
line-height: 1.25rem;
}
:where(.se-step-indicators--sidebar .se-step-indicators__copy) {
width: auto;
align-items: flex-start;
text-align: left;
}
:where(.se-step-indicators__title) {
display: block;
overflow-wrap: break-word;
text-wrap: balance;
}
import { formatStepLabel, WizardActionsConfigSchema } from '@schema-engine/forms/recipes/built-in';
import { useViewConfig, useViewContext } from '@schema-engine/forms-react/hooks';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/schema-engine/forms/lib/utils';
/**
* @remarks
* Next and Submit carry distinct keys so React replaces the button instead of turning
* Next into a submit button while its click is still being handled, which submitted the
* form on arriving at the last step.
*/
export function WizardActions() {
const { navigation, form, steps, currentStepIndex } = useViewContext();
const { labels, variant, showStepCounter } = useViewConfig('actions', WizardActionsConfigSchema);
return (
<div className={cn('se-wizard-actions', variant === 'minimal' && 'se-wizard-actions--minimal')}>
<Button
data-se-control
type="button"
variant={variant === 'minimal' ? 'ghost' : 'outline'}
onClick={navigation.goToPreviousStep}
disabled={navigation.isFirstStep}
aria-label={labels.previousAriaLabel}
>
{labels.previous}
</Button>
{showStepCounter ? (
<Badge variant="secondary" aria-live="polite">
{formatStepLabel(labels.stepCounter, currentStepIndex + 1, steps.length)}
</Badge>
) : null}
<div className="se-wizard-actions__forward">
{navigation.isLastStep ? (
<Button key="submit" data-se-control type="submit" aria-label={labels.submitAriaLabel}>
{form.isSubmitting ? labels.submitting : labels.submit}
</Button>
) : (
<Button
key="next"
data-se-control
type="button"
onClick={navigation.goToNextStep}
disabled={!navigation.canGoNext}
aria-label={labels.nextAriaLabel}
>
{labels.next}
</Button>
)}
</div>
</div>
);
}
/*
* Layout of the wizard action bar: Previous on the left, the step counter between, Next or Submit on the right.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
*
* Import this file into the `components` layer when the app uses Tailwind, as recipes.css says.
*/
:where(.se-wizard-actions) {
display: flex;
min-width: 0;
align-items: center;
justify-content: space-between;
gap: 1rem;
}
:where(.se-wizard-actions--minimal) {
width: 100%;
}
:where(.se-wizard-actions__forward) {
display: flex;
gap: 0.5rem;
}
import type { FormShellProps } from '@schema-engine/forms-react/primitives';
/** Styles live in `stack-shell.css`, which the app imports through `recipes.css`. */
export function StackShell({ slots }: FormShellProps) {
return (
<div className="se-stack-shell">
{slots.header}
{slots.progress}
{slots.content}
{slots.actions}
</div>
);
}
/*
* Stack shell styles for the React registry recipes.
*
* Every rule sits inside :where(), so it adds no specificity and a host class on the same element wins.
* The gap between the slots reads the semantic `size` token --se-space, as the Radiant stack does; the
* fallback is the look of an unpicked shell.
*
* Import this file into the `components` layer when the app uses Tailwind, so utility classes still outrank
* it: `@import "./components/schema-engine/forms/recipes/recipes.css" layer(components);`
*/
:where(.se-stack-shell) {
display: flex;
min-width: 0;
width: 100%;
max-width: 40rem;
flex-direction: column;
gap: var(--se-space, 1.5rem);
margin-inline: auto;
}
/*
* Generated entry point for the Schema Engine default recipe styles.
* Import this one file from the app's global stylesheet; each shell's file sits beside its component.
*/
@import './blocks/form-actions.css';
@import './blocks/minimal-progress.css';
@import './blocks/step-header.css';
@import './blocks/step-indicators.css';
@import './blocks/wizard-actions.css';
@import './shells/card-shell.css';
@import './shells/hero-shell.css';
@import './shells/sidebar-shell.css';
@import './shells/split-screen-shell.css';
@import './shells/stack-shell.css';
Custom recipes
A recipe is a registration: a spec bound to your components. Recipes has a custom shell that renders live in React and in Radiant, with its CSS.
import * as z from 'zod/mini';
import { createFormEngine } from '@schema-engine/forms';
import { defineRecipeSpec } from '@schema-engine/forms/recipes';
import { defineRecipe, type FormShellProps } from '@schema-engine/forms-react/primitives';
function BrandShell({ slots }: FormShellProps) {
return (
<div>
{slots.header}
{slots.content}
{slots.actions}
</div>
);
}
const BrandRecipe = defineRecipe(
defineRecipeSpec({
$type: 'brand',
kind: 'single-step',
slotSchemas: { shell: z.strictObject({ accent: z.optional(z.string()) }) },
metadata: { name: 'Brand', description: 'Branded form shell' },
}),
{ shell: BrandShell, slots: {} },
);
const engine = createFormEngine({ recipes: [BrandRecipe] });