Web components
The UI Library is based on web standards. We build it using Web Components which work in all modern browsers. In short, Web Components allow you to create custom, reusable HTML elements, with tag names specified by you, that you later drop into your markup as you do with all the native divs, spans, inputs, or buttons.
One of the great things about Web Components is the possibility to encapsulate both logic and styles thanks to the use of Shadow DOM. Component styles do not pollute the global styling and vice versa, and each component has a friendly interface that you can use to configure it. Under the hood
On top of that, UI Library components are framework agnostic - you can use them with good old backoffice, you can put them in your web project and they will just work, no matter if you’re using Angular, Vue, vanilla javascript, or React (with a tiny bit of extra effort). You can even develop an entire application that looks and feels like Umbraco if that is your need, without much hassle.
Modern frontend
Under the hood, UI Library components are built with Lit, a lightweight base class that provides reactivity and declarative templating, besides being approachable and giving a good developer experience. They are all written in Typescript, but you don’t need to use Typescript to use the components. They will work perfectly in your Javascript app.
Each component is an ES module, distributed via npm as a separate, independently versioned package. If you add that to the fact that the UI Library is based on web standards and not a particular framework of choice, you get a truly future-proof UI that will work in any browser many years from now.
Why will it make you happy?
Let's take a closer look at the components. Each of them has a custom tag name that consists of the “uui” prefix, a hyphen, and the name of the component. For example, the button component from Umbraco UI Library will have a tag name of uui-button. But before you can use it in your markup, it has to be registered, so the browser knows what the <uui-button> is when it’s parsing your HTML file.
A custom element, and therefore our UI components, have to be registered. This is done by calling the following method on the cutomElements object. The object is a property of the global window object and in the example below, we can see that this method has two parameters. The first one is the tag we want to use for the component, the second one is the class that contains all the component’s logic and styles. After the method is executed, the browser will know how to interpret the <uui-button>.
customElements.define('uui-button', UUIButtonElement);
It is worth noting that all the custom elements are registered globally, on the window object. What that means is that the tag names have to be unique and each element can be registered only once. Otherwise, we will get a nasty error.
An easier life for Umbraco developers
Today, to use a button that suits the style of Umbraco’s backoffice you would need the AngularJS umb-button component, that only works inside the backoffice: