Now that we have data for our dashboard we might want to make it look prettier. To do this we can use the Umbraco UI library.
Overview
This is the fourth and final part of the guide to building a Custom Dashboard. This part continues work on the dashboard we built in part three: Adding functionality to the Dashboard. But it goes further to showcase how we can use the UI Library in our extension.
The Umbraco UI Library is a set of web components and variables that we can use to build Umbraco User Interfaces. It is already part of the Backoffice, which means you can already start to use it.
By using the variables available from the UI Library, you ensure that your extensions are a consistent size with the rest of the backoffice.
UI Box
Let's start by wrapping uui-box around our render output. This makes our dashboard the same style as the built-in dashboards of Umbraco:
welcome-dashboard.element.ts
render() {returnhtml` <uui-box> // rest of the render code </uui-box> `;}
The uui-box has a headline property as well. Here are two options:
Move the headline into the headline property:
Add an element instead. This element can also be styled and contain other elements.
Let's keep using umb-localize instead of localize.term():
The UI Library also has a lot of variables we can use such as sizes and colors. Let's update our padding to ensure that our element is always consistent with the rest of the backoffice:
This already looks a lot better!
The dashboard in uui-box
See the entire file: welcome-dashboard.element.ts
UI Table
Let's try another uui element. Since we have a lot of information from the users, it could be a good idea to insert it into a proper table.
The Umbraco UI (UUI) Library also includes a uui-table, so let's use it:
Since the uui-table and others are handling the table, we can redo our CSS a bit:
Your dashboard component should now look like this:
Dashboard with uui-table in use
See the entire file: welcome-dashboard.element.ts
Challenge (optional)
Insert the user.state into a uui-tag that uses different values of the propertieslook and color.
The values depend on the state of the user. For example, use look="primary" and color="positive" when the user is Active