ByteEditor Website Builder
Create element
Following these instructions, you can create a new card for your elements gallery. You can recreate this element using the code snippets provided in the guide, or modify the steps to tailor it to your specific needs.
Expected result
In order to create a new card, for example, Card With Icon Centered, we need a back office preview (a Lit custom view registered in an “umbraco-package.json” file), an element type, and a front-end view.
Step 1. Back office preview
- Open the project folder
- Open the “App_Plugins” folder
- Create a folder for custom blocks, for example, name “CustomBlockView”
- Create a file named “card-with-icon-centered.custom-view.js”
- Copy the following code and paste it into the file
6. Create a file named “umbraco-package.json” in the “CustomBlockView” folder. If you followed the Create layout guide, you already have this file: add the new extension to its “extensions” list instead.
7. Add the following JSON to the file:
💡 There is no build step: Umbraco 17 loads these files directly. “forContentTypeAlias” must match the element type alias you create in Step 2. To learn more, see the Umbraco documentation on custom views for blocks.
Step 2. How to create an element in Umbraco
- Run your project locally where the ByteEditor 17.X package is installed.
- Open the “Settings” section.
- Expand “Document Types” → “Blocks”.
- Hover over the “Cards” folder, click '...' and choose “Create”.
- Select “Element Type”.
- Name it “Card With Icon Centered”.
- Click the icon next to the name and pick an icon for the card.
- Next to the name, change the alias from “cardWithIconCentered” to “cardWithIconCenteredBlock”.
- Click “Add group” and name the group “Content”.
- Add a property “Image” with the “Feature - Icon - Media Picker” property editor.
- Add a property “Headline” with the “Textstring” property editor and turn on “Mandatory”.
- Add a property “Rich Text” with the “Features List - Features - Rich Text Editor” property editor and turn on “Mandatory”.
- Add a property “Link” with the “Feature - Link - Multi URL Picker” property editor.
- Add a property “Button Variant” with the “Button - Variant - Radio button list” property editor, and change its alias from “buttonVariant” to “variant”.
- Click “Compositions”, and under “Blocks/Compositions” select “Section Settings” and “Section Custom CSS for elements”.
- Click “Submit”, then “Save”.
Step 3. How to add element to the Block Grid
- Open “Settings” → “Data Types” → “Home - Main Grid - Block Grid”.
- Click “Add block” and choose “Card With Icon Centered”.
- Put it in the “Cards” group.
- Turn off “Allow at root” and keep “Allow in areas” on.
- Under “Available column spans”, select 3, 4 and 6.
- Click “Submit”, then “Save”.
💡 Unlike Umbraco 13, there is no “Custom view” field on the block: the preview is picked up automatically from “umbraco-package.json” by the element type alias.
Step 4. How to create an element view on the front end
- In “Settings”, expand “Partial Views” → “blockgrid”.
- Hover over the “Components” folder, click '...' and choose “Create” → “Empty partial view”.
- Name it “cardWithIconCenteredBlock.cshtml”.
- Copy the following code and paste it into the file
5. Click “Save”
6. Restart the project so ModelsBuilder generates the “CardWithIconCenteredBlock” model
Congratulations!
You have created your first element. Now you can add it to your design.