HTML elements
HtmlHelper exposes 138 typed factories covering the common
HTML elements, from the HTML5 structural set to legacy tags. All of them
produce the same element nodes as the generic
H(tag, props, children) helper, so the two styles mix freely.
using Donkeh.UILab;
using static Donkeh.UILab.HtmlHelper;
using static Donkeh.UILab._;
Div(new() { ClassName = "card" },
H2(new() { ClassName = "card-title" }, Text("Files")),
P(new() { ClassName = "card-copy" }, Text("12 items")),
A(new() { Href = "/files" }, Text("Open")));
Props and attributes
Every helper takes a Props instance. Common attributes are
first-class properties; anything else goes through the
Attributes dictionary.
| Group | Properties |
|---|---|
| Identity | Id, ClassName, Title, Role, Key |
| Links and media | Href, Src, Alt, Target, Rel |
| Forms | Type, Value, Placeholder, Name, Disabled, Checked, TabIndex |
| Anything else | Attributes = new Dictionary<string, string> { ["data-id"] = "42" } |
Boolean properties emit an empty presence attribute when true and disappear
when false or null. Entries in Attributes are applied after the
dedicated properties. A class entry adds tokens to
ClassName; an id entry replaces Id.
Event handlers are props as well. Simple properties such as
OnClick and OnInput receive only the useful value,
while the On…Event variants receive the full event object. See
the event reference for every dispatched
event, its class and its payload.
Button(new()
{
ClassName = "primary",
Disabled = isBusy,
Attributes = new Dictionary<string, string>
{
["data-command"] = "save",
["aria-label"] = "Save changes"
}
}, Text("Save"));
Element reference
The factories below are available from
using static Donkeh.UILab.HtmlHelper;. Block elements default
to display: block, phrasing content to
display: inline, replaced and form content to
inline-block, and unknown tags to inline-block.
| Group | Helpers |
|---|---|
| Document and roots | Html, Head, Body, Title, Meta, Link, Base, Style, Script, Template, Noscript |
| Sectioning and flow | Div, Main, Section, Article, Aside, Header, Footer, Nav, Figure, Figcaption, Blockquote, Address, Details, Summary, Dialog, Center, Hr, Pre, Br, Search, Menu, Dir, Hgroup |
| Text and inline | Span, A, Strong, Em, B, I, U, S, Small, Sub, Sup, Code, Kbd, Samp, Var, Mark, Abbr, Cite, Q, Time, Label, Output, Ruby, Rt, Rp, Rb, Rtc, Bdi, Bdo, Wbr, Del, Ins |
| Headings, text and lists | H1–H6, P, Ul, Ol, Li, Dl, Dt, Dd |
| Forms | Form, Fieldset, Legend, Input, Textarea, Select, Option, Optgroup, Button, Datalist, Progress, Meter, Keygen, Isindex |
| Tables | Table, Caption, Colgroup, Col, Thead, Tbody, Tfoot, Tr, Th, Td |
| Media and embedded | Img, Picture, Source, Video, Audio, Canvas, Iframe, Object, Embed, Applet, Map, Area, Param, Track |
| Legacy and misc | Acronym, Basefont, Bgsound, Big, Blink, Font, Frame, Frameset, Marquee, Menuitem, Nobr, Noembed, Noframes, Plaintext, Spacer, Strike, Tt, Xmp, Slot, Data |
Custom and unknown tags
Any tag name is accepted. Use H when there is no typed helper;
the element participates in CSS like any other box and defaults to
inline-block until a rule changes its display.
H("my-badge", new()
{
ClassName = "badge",
Attributes = new Dictionary<string, string>
{
["data-count"] = "3"
}
}, Text("New"));
Behaviour by element
| Element | Notes |
|---|---|
img | Replaced content with intrinsic sizing, source resolution, object-fit and a shared texture cache. See Image. |
video | Desktop and Android use a LibVLC player whose frames become textures. See Video. |
canvas | Desktop uses batched Silk.NET drawing or raw OpenGL; browser drawing is not wired yet. See Canvas. |
audio | Desktop and Android use the window-side audio player and paint transport controls. It has no visual box when controls is absent. |
input | Text-like types are editable with click-to-place caret, arrow and word navigation, selection, scrolling to the caret and caret-color/::selection support. Checkbox, radio, range, colour and file inputs are host-painted and interactive. Other types still render as controls. |
select, option | The selected option and a dropdown chevron are painted by the host. Arrow keys, Home/End, Enter/Space and type-ahead navigate the option list. Option elements are hidden in the user-agent sheet. |
textarea | Editable multi-line text with click-to-place caret, Up/Down line movement, line-aware Home/End, selection, internal scrolling, caret and placeholder support. |
table family | Table layout, collapse and spacing are supported. Use normal table structure; anonymous table boxes are not synthesised for arbitrary children. |
picture, source | Parsed as elements, but responsive source selection is not implemented. img uses its own src. |
iframe, object, embed | Render a stable 300 × 150 placeholder box. They do not load or embed external documents. |
script, style, link, meta | Hidden by the user-agent sheet. Scripts are never executed and link stylesheets are never fetched; load CSS through [Stylesheet]. |
Fonts and WOFF
The native host discovers installed system fonts by family and falls back by codepoint. A custom host can add a font without installing it system-wide:
var window = new DonkehWindow(settings);
window.Fonts.RegisterFont("Inter", "Assets/Inter.woff2");
window.Run(root, styles);
TTF, OTF, WOFF and WOFF2 files are accepted. WOFF containers are expanded to
sfnt before the normal metrics, glyph atlas and fallback pipeline runs.
RegisterFont wins over system discovery for that family; the
browser host delegates font loading to the browser instead.
The native host also resolves external author stylesheets. Absolute or
relative @import URLs are fetched and inlined, and each
@font-face block downloads its first supported font source and
registers the family automatically. Relative URLs resolve against the
stylesheet that declared them. Failures leave the original rule in place and
keep the fallback font chain.
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.3.1/css/all.css');
.fa-bars {
font-size: 48px;
}