Client CraftClient Craft HubStart free

The block contract: content tabs and the shared settings type

On this page
Updated 24 Nov 20263 min read

How the Visual Builder reads your blocks: content tabs from your element type, base styles from one shared settings field.

Plan: Free Visual Builder package

You design a block's content exactly as you would for Umbraco. The Visual Builder adds nothing to your content type. What it needs for styling is one settings field, visualStyles, which every styled block shares. This article explains that contract so you can design blocks that work well in the builder.

Before you start #

  • You know how Umbraco Block Grid element types, settings types and data types work.

How the inspector is built #

  • Content tabs. The inspector shows the block's content type tabs and groups as you defined them; groups are accordions. Text, rich text, links and images are found on the canvas and edited in place; other fields use their normal Umbraco property editors in the panel.
  • Style tab. Shown when the block's settings type has the visualStyles field. The values are typed (spacing, size, colours from the design library, per screen size and state).
  • Advanced tab. Always there. It holds Save as pattern, Make component, the block type and key, and lists any data-property aliases in your markup that the block doesn't have.
  • Settings on the block bar. Settings such as toggles, dropdowns, radio buttons, colours and numbers are offered on the block's bar on the canvas.

Two ways a block gets base styles #

BlockWhat the opt-in does
Has its own settings typeAdds a Visual styles field (visualStyles, group Visual design) to it. All existing settings fields stay.
Has no settings typeUses the shared Element appearance settings type (ccvbElementSettings) as its settings.

The recommended way is the composer in Opt a site into Visual Builder styles in code, which applies this to every block of the grids you list.

What a block without the contract keeps #

A block whose settings have no visualStyles field still works in the builder: editors can edit its content, insert it, move it, duplicate it, delete it and resize its columns. They don't get margin, padding, width or gap handles, and its Style tab is greyed out with this hover text: "This block doesn't use the Visual Builder style settings, so spacing, styles, animations and visibility can't be set here. A developer can add them to the block (Visual Builder setup guide)."

Adopt a single block explicitly #

To adopt one block in one grid instead of whole grids, an administrator action can call VisualCustomBlockInstaller.AdoptAsync. It points the block at the shared settings type, or composes the style settings into the block's own settings type. It requires the shared settings type to exist (run the composer opt-in once first) and a signed-in Umbraco administrator; it returns false when the block already had a settings type.

csharp
1using Asp.Versioning;
2using ClientCraft.VisualBuilder.Umbraco.Schema;
3using Microsoft.AspNetCore.Authorization;
4using Microsoft.AspNetCore.Mvc;
5using Umbraco.Cms.Api.Management.Controllers;
6using Umbraco.Cms.Api.Management.Routing;
7using Umbraco.Cms.Web.Common.Authorization;
8
9namespace MySite.VisualBuilder;
10
11[ApiVersion("1.0")]
12[VersionedApiBackOfficeRoute("my-site/visual-builder")]
13[ApiExplorerSettings(GroupName = "My site")]
14[Authorize(Policy = AuthorizationPolicies.RequireAdminAccess)]
15public sealed class AdoptBlockController(VisualCustomBlockInstaller installer) : ManagementApiControllerBase
16{
17 // POST /umbraco/management/api/v1/my-site/visual-builder/adopt?contentTypeAlias=quoteBlock&blockGridDataTypeKey=...
18 [HttpPost("adopt")]
19 public async Task<IActionResult> Adopt(string contentTypeAlias, Guid blockGridDataTypeKey)
20 => Ok(new { changed = await installer.AdoptAsync(contentTypeAlias, blockGridDataTypeKey) });
21}

VisualCustomBlockInstaller is registered by the package; you only inject it. Your own content type is never edited.

WarningDon't edit existing block types in place on a live site to "add" the contract by hand. Add new types next to old ones, rebuild the pages, then remove the old types.

What happens next #

Render base styles with <ccvb-block>.

Was this article helpful?