# Create a new widget

In this example we are going to create a simple widget were you can edit a heading and select background and text color in the settings section of the widget.

## Create document types

Let's start by creating two document types under `Document Types > Widgets` in the settings section of Umbraco. We will call our widget **Hello World.**

Create a Hello World folder under widgets to keep things organized. Right click on the new folder and select `Document Type without a template`&#x20;

![](https://1747244357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MN83_a4SxUzhnC6dsXE%2F-MORw2tF1MRIV3VU_EmT%2F-MORyA2zJl34OVG2nPom%2Fimage.png?alt=media\&token=8e99b19f-6e71-42fa-8300-0ccd85c0d1dd)

Our first document type will have the heading text.&#x20;

![](https://1747244357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MN83_a4SxUzhnC6dsXE%2F-MORw2tF1MRIV3VU_EmT%2F-MORyvJQuAix6hPMsFc2%2Fimage.png?alt=media\&token=3c0617af-9e85-4199-805a-87ebe8b289c4)

Make sure to check the box **Is an element type** under the permission section.

![](https://1747244357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MN83_a4SxUzhnC6dsXE%2F-MORw2tF1MRIV3VU_EmT%2F-MORzRhtMUJ2sFkvsS_N%2Fimage.png?alt=media\&token=0ca54f2b-79c0-40b2-a9b4-6bddb3c62da4)

Next we create on for Settings in the same way.

![](https://1747244357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MN83_a4SxUzhnC6dsXE%2F-MORw2tF1MRIV3VU_EmT%2F-MORzzEmQtVM5S6g6Awv%2Fimage.png?alt=media\&token=8e40558f-b9df-4542-87c7-4b474a0d74f4)

## Add the document types to the Block List data type

To add our widget to the list of existing ones we need to open the data type `IG - Content - Block List` found under `Data Types > IG - Block List` \
Click the Add button at the bottom of the list.

![](https://1747244357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MN83_a4SxUzhnC6dsXE%2F-MORw2tF1MRIV3VU_EmT%2F-MOS01WvoNwSC6eh-YG4%2Fimage.png?alt=media\&token=7c492990-e143-4adf-bd8a-a568e0d6f19e)

Select our content document type from the list. Once added click on the widget and connect the settings one under `Settings model`

<div align="left"><img src="https://1747244357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MN83_a4SxUzhnC6dsXE%2F-MORw2tF1MRIV3VU_EmT%2F-MOS0zprq76MsEMmpEBk%2Fimage.png?alt=media&#x26;token=5eada7e2-5238-45c0-ad06-d5588b6b186b" alt=""></div>

## Create a partial view for your widget

Now lets create a partial view for our widget. It's important that it has the same name as the alias for our content model. `/Views/Partials/Widgets/HelloWorld.cshtml`

```aspnet
@inherits Umbraco.Web.Mvc.UmbracoViewPage<Umbraco.Core.Models.Blocks.BlockListItem>
@using Umbraco.Core.Models.Blocks;
@using ContentModels = Umbraco.Web.PublishedModels;
@{
    var content = (ContentModels.HelloWorld)Model.Content;
    var settings = (ContentModels.HelloWorldSettings)Model.Settings;

    var textColorClass = settings.TextColor?.ToString() == "white" ? "light-color" : ""; 
    var backgroundColor = settings.BackgroundColor?.ToString();
    var backgroundColorClass = string.IsNullOrWhiteSpace(backgroundColor) ? "white-bg" : backgroundColor + "-bg";
}

<section class="block @backgroundColorClass @textColorClass">
    
   <h1 class="text-center">@content.Heading</h1>

</section>
```

{% hint style="info" %}
For more information about Block List, see the[ Umbraco documentation ](https://our.umbraco.com/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Block-List-Editor/)
{% endhint %}
