User Interface (UI)
The user interface (UI) is the layer of an application with which people operate it: pages, forms, buttons, lists. It accepts input and shows results; in a web application, that is HTML, CSS, and what the browser makes of them.
The user interface (UI) is the layer of an application with which people operate it. It accepts input and shows results. In a web application, that is HTML, CSS, and what the browser makes of them.
UIs in .NET
For web user interfaces, .NET has above all Blazor. Blazor builds the user interface from components: a component is an element of the user interface such as a page, a dialog, or an input form. It is a .NET class, usually in a .razor file in which HTML and C# stand side by side:
<p role="status">Current count: @currentCount</p>
<button @onclick="IncrementCount">Next</button>
@code {
private int currentCount = 0;
private void IncrementCount() => currentCount++;
}
Every component has a render mode. It sets where the component is rendered and whether it is interactive: statically on the server (without interactivity), interactively on the server, interactively in the browser through WebAssembly, or switching automatically. The default is static. Other UI technologies in .NET are .NET MAUI for mobile and desktop apps, and WPF and Windows Forms for Windows. For web applications, Blazor is usually enough, and you write the user interface in the same language as the rest.
What belongs to the UI
A UI does not just consist of what looks good:
- Structure: semantic HTML with headings, lists, forms, and labeled fields. It helps screen readers and search engines.
- Design: colors, spacing, fonts. In the course, you write styles as SCSS, which becomes CSS in the build.
- Behavior: What happens on a click, on submitting, on an error?
- States: empty, loading, failed, successful.
The UI is one part of the frontend; the backend supplies the data and rules. Whether a UI is good is decided in the end by the user experience.
Misconceptions
- UI is not UX. The UI is the surface, the UX the whole experience.
- Rules do not belong in the user interface. Whether an appointment slot is free is decided by a rule in the core of the application. The UI only asks it. That way, the rule can be tested without a browser.
- More interactivity is not better. Interactive parts cost a connection or a download. Static HTML is often enough.
An example from the Kladde
The Kladde starts with statically rendered Blazor pages: lists, forms, and the public booking page do without script. Only where it pays off do interactive islands come in, for example on the server or in the browser through WebAssembly. The rule for free times does not live in a component but in the core, which the page only calls.
In the course
You learn the UI with Blazor in K2, module 2.5: The Blazor Web App, Components, and later the interactive islands, for example Interactive islands with WebAssembly. The basics of HTML and CSS are in module 2.1.