Style presets
A style preset is a named CSS cube, stored once and posed on blocks. A pose is a link, not a copy: editing the preset restyles every block that uses it.
It behaves like a CSS class under local overrides: preset values fill the gaps, the block's own values always win.
The logic lives in the StylePresets class; the render-time cascade in BSPK_MERGE_STYLE_PRESET. In the dev panel, the selector is in the "Mise en page" (Layout) tab, and presets are managed in the "Styles prédéfinis" tab.
Data
- Table
BSPK_WEB_STYLE_PRESET(a host database table):uuidKey,name,description,sourceType(the block type it was captured from),cssProperties. - A preset's cube has exactly the shape of a block's
cssProperties:[part][breakpoint][variant][prop], with partsbspk,input,label,select… (see Styling: CSS cube and Tailwind). - A pose is stored on the block:
properties.stylePresets[part][breakpoint][variant] = "<preset uuidKey>"stylePresetsis declared bySchemaEnginefor every type that has a CSS cube (valueType: object,internal: true); it is not in the type schemas. Several poses may coexist on one block.
Two older forms are still read, without migration: stylePresets[part] = "<uuid>" reads as a pose at default/default, and a cube whose top-level keys are all breakpoints (default, xs…2xl) is "part-neutral": it applies to the part it is posed on.
What one pose contributes
On each axis, the general value takes the whole axis; a precise value takes only itself (expandPose).
| Pose at | Brings |
|---|---|
bspk / default / default | the entire preset cube, every part |
input / default / default | preset.input, every breakpoint and variant |
input / md / hover | preset.input.md.hover only |
bspk / md / hover | preset.bspk.md.hover only |
A preset never moves a part onto another: the destination keeps the source coordinates.
The cascade at render
BSPK_MERGE_STYLE_PRESET($cube; $WebContent) modifies a copy of the block's cube. It is called by BSPK_GENERATE_ALL_CSS_CLASS_TW right after BSPK_NORMALIZE_CSS_CUBE, so both the render and the Tailwind manifest see the same merged result.
- No pose: immediate return, no database access.
StylePresets.contributions()lists every cell brought by every pose, sorted from general to precise: the most precise writes come last and win.- A property is applied only if the schema makes it available for that block type and part (
SchemaEngine.cssPropAvailable): what the Layout tab does not show cannot arrive through a preset. For example, a preset captured on a field and posed on atextblock does not pour itsinputpart into it. - Two passes: unconditional properties first, then conditional ones, evaluated against the cube actually obtained (a preset bringing
layout: flexmakes its ownflex*relevant; a refusedlayoutdoes not let them through). - The block's local values are never overwritten.
The dev panel shows inherited values as placeholders (data-preset-value), built from the same contributions(): what the panel announces is what is rendered.
Dev panel operations
| Gesture | Function | Effect |
|---|---|---|
| Pick a preset in the Layout tab selector | setBlockPropertyV21 with {isStylePreset: true; target; breakpoint; variant; value} | writes or removes the pose at that scope only; an empty value removes it; the block's cube is untouched |
| "Enregistrer comme modèle" (save as preset) | saveBlockAsStylePreset | the preset gets the whole block cube; the block's cssProperties is then emptied and the preset posed at bspk/default/default |
| "Appliquer" (freeze) | applyStylePreset | copies what all poses bring into the block's cube, then removes the poses: the block becomes independent |
| Edit a preset property | setStylePresetProperty | writes one property at a scope in the preset cube, with no availability filter, then propagates |
| Create / rename | createStylePreset, renameStylePreset | |
| Delete | deleteStylePreset | if the preset is in use and force is not set, the panel asks for confirmation (action stylePresetUsages); applyFirst: true first freezes this preset into each block; then deletion and propagation |
Behind these gestures, the StylePresets class exposes list, get, create, rename, remove, usages, poses, expandPose, contributions, setPose, cubeFromBlock, applyToBlock, propagate, propagateBlocks, presetUuidFor and scopeForBlock. Results are {success; error} objects; remove and get never throw.
Pitfalls
- After editing a preset from code, call
propagate($uuid). The render picks up the change at once (the cascade runs at render), butoutput.cssonly contains classes the Tailwind manifest scanned. Without propagation, the HTML carries classes that do not exist: the style is silently missing.propagateregenerates the manifest page by page. Never pass a multi-page selection toBSPK_UPDATE_CSS_FILE_TW: it writes everything into the first block's page file and empties the others. - A pose that brings nothing is refused, with the warning
BSPK_stylePresetNothingHere. If you writestylePresetsyourself (API, migration), you bypass that check: verify withexpandPose(...).length > 0. - A posed scope is exact:
presetUuidForonly answers for the exact scope. The selector of a precise scope stays empty when the style comes from a general pose; clearing it there does nothing. Remove the pose where it was set. - Deleting a preset leaves dead references on blocks, unless it was frozen first. They are ignored at render: the block silently loses the preset's look.
applyToBlockalso removes dead poses. - The usages listed cover page blocks (
BSPK_WEB_CONTENT). Before deleting or editing a preset, also check the blocks of your models that might use it. - After a delivery or a content exchange, check the look of blocks that use style presets on the target database. When in doubt, freeze the preset ("Appliquer") before delivering.
- Never modify a preset's or a block's
cssPropertiesin place:OB Copy, modify, then reassign (assetStylePresetPropertyandapplyToBlockdo). 4D does not always detect an in-place change of an object field atsave().
See also
- Styling: CSS cube and Tailwind — the cube, units, Tailwind extraction
- The dev panel — the single write path
setBlockPropertyV21 - Content reconciliation — what the exchange carries

