Give your blocks Visual Builder styles
On this page
Add one field to a block's settings type in Umbraco and editors get the Visual Builder Style tab on that block. No C# needed: a settings field plus one tag in…
Plan: Free Visual Builder package
The Visual Builder edits your site's own blocks as they are. To give editors the Style tab (spacing, size, background, typography, border, layout, per screen size) on those blocks, each block needs one extra settings field. You add it by hand in Umbraco's Settings, so you decide exactly which blocks get it. The Visual Builder never changes your types on its own.
Before you start #
- The Visual Builder package is installed. See Install the Visual Builder on its own.
- The package's own schema is installed. Umbraco does this when the package is installed (a package migration). If your site runs package migrations by hand (
PackageMigrationsUnattended=false), run it once from Packages › Installed › Run pending package migrations. You then have a Visual Builder / Visual styles data type and an Element appearance element type. - You are an Umbraco administrator.
Step by step #
- 1Open the block's settings typeGo to Settings › Document Types and open the settings element type of the block, for example "Hero settings".
- 2Add the Visual styles fieldAdd a property: name Visual styles, alias
visualStyles, editor: the existing Visual Builder / Visual styles data type. Put it in its own group, for example Visual design. Save.To cover many blocks at once, add the field to a composition those settings types share.
- 3Blocks without a settings typeOpen the Block Grid data type, select the block and choose Element appearance as its Settings model. Save.
- 4Render the stylesWrap each block view with
<ccvb-block>so the styles reach the page. See Render base styles with<ccvb-block>. - 5Regenerate models and deployIf you use ModelsBuilder in source code mode, regenerate the models for the changed settings types. With uSync, export the schema change and deploy it like any other.
- 6Check it in the builderOpen a page, select one of those blocks and open Style. The controls are now active.
If something goes wrong #
| What you see | Fix |
|---|---|
| The Style tab stays greyed out | The field's alias must be exactly visualStyles and it must use the Visual Builder / Visual styles data type, not a new data type with the same editor. |
| There is no Visual Builder / Visual styles data type | The package migration hasn't run. Run it from Packages › Installed. |
The settings type already has a visualStyles property of its own | Rename yours, or leave that block without Visual Builder styles. |
NoteBlock List data types don't get styles. Blocks in a Block List keep content editing, moving and deleting in the builder.
What happens next #
The block contract: content tabs and the shared settings type.
Was this article helpful?