Styling and layout

Schema Engine splits styling in two. The engine owns a vocabulary of names (half, compact, elevated, a gap token). The form owns the intent, written with those names in plain data. A renderer turns the intent into the same DOM contract in React and in Radiant: data-se-* attributes and CSS custom properties.

OwnerHoldsWritten in
The layout themeBreakpoint thresholds, gap tokens, appearance axes and the tokens each axis value setscreateLayoutTheme from @schema-engine/layout, passed to the engine as layout
The formWhich width, which areas, which sizegrid, appearance, className, style in the form config
The recipeThe markup and CSS of the frame around the fields, which reads the tokensA shell, as a registered recipe
The host appValues of tokens, extra axes, its own CSSA stylesheet and the theme you pass to the engine

Because the form only picks names, the same config validates and renders the same in every renderer, and it can live in JSON or YAML.

Which tool do I use

I want toUseRead
Put two fields on one rowgrid.width: half on each fieldPlacing fields in the grid
Centre or indent a fieldgrid.offsetsame
Draw a layout where one field spans rowsgrid.areas on the form or step, grid.area on each fieldDrawn layouts
Change the layout at a breakpointgrid.responsive, or an areas recordsame
Place one field exactlyRaw column, row, placeSelfRaw grid lines
Make a form denser or roomierappearance: { size: 'compact' }Appearance axes
Change border, shadow or surfaceappearance: { surface: 'outlined' }same
Add a brand colour that every form can pick by nameA host axis with defineAxisAppearance axes
Change the rhythm between fields everywhereThe --se-grid-gap-* tokens, or createLayoutTheme({ grid: { gap } })Theming
Set a size, a width or a gap for one formA class in className that sets the tokenTheming
Style one form, step or field onceclassName, or style with custom propertiesEscape hatches
Show or hide a part of a recipe (descriptions, labels, orientation)Slot config on view, for example view.header.showDescriptionView recipes
Use a different frame around the fieldsA recipe, built in or your ownRecipes
Make two engines or two renderers look the sameOne compiled layout theme passed to bothLayout themes
Copy a working setupA recipeRecipes

When two tools fit, prefer them in this order: a named width before a raw line, an axis value before a token override, a token override before a class, a class before inline style.

Three levels of layout

A form's grid and each element's own grid lay fields out. The levels run from the most to the least readable:

  1. width and offset for fields that flow in rows. Names are shares of 12 tracks: full, three-quarters, two-thirds, half, third, quarter.
  2. areas for a layout you draw as rows of names, with area on each field.
  3. Raw grid lines (column, row, placeSelf) as the escape hatch.

Fieldsets and array rows lay their children out on a grid of their own, so the same names work inside a container. A step's grid replaces the form's grid for that step. The rules, the validation errors and the limits are on Placing fields in the grid.

Appearance

An appearance axis is one independent dimension of appearance with 2 to 5 named values, such as size or surface. Each value stands for a set of CSS tokens that components read. A form, a step, a field or a recipe slot picks a value by name, and the renderer writes it as data-se-<axis>="<value>". The engine ships size and surface; a host adds its own, such as tone. See Appearance axes.

Escape hatches

Names cover the common cases. Three hatches stay open for the rest, and they work the same in every renderer:

  • className on the form, a step or a field. The theme's token rules sit inside :where(), so a class of yours always wins over them on the same element. Its grid and item rules do not, so change placement with grid config or the --se-grid-* and --se-item-* properties.
  • style on the form, a step or a field. It accepts only CSS custom properties (keys starting with --, string or number values), because that is the one style shape that means the same in React, Radiant, JSON and YAML. A value cannot contain ;, { or }.
  • Raw column, row and placeSelf on a field.
{
	id: 'checkout',
	className: 'checkout-form',
	style: { '--se-grid-gap-default': '0.75rem' },
	steps: [/* ... */],
}

Where next

  • Layout themes: compile a theme, share it, the neutral hooks and nested themes.
  • Appearance axes: the definition, the rules, built-in axes and your own.
  • Theming: the custom properties a host overrides, with a complete theme file.
  • Recipes: copy-paste configs with their CSS, each rendered live.
  • YAML Forms: author any of these in a .form.yaml file.