HTML first
HTML first
HTML first means new UI is plain HTML. A page is a template made of ordinary elements. Layout is CSS flex and grid, styling is Tailwind classes that read the shared theme tokens, and richer pieces are Spartan helm components.
One template
Plain elements, Tailwind classes and a helm card.
<section hlmCard class="max-w-md">
<div hlmCardHeader>
<div hlmCardTitle>One template</div>
<p hlmCardDescription>Plain elements, Tailwind classes and a helm card.</p>
</div>
<div hlmCardContent class="flex flex-col gap-3">
<div class="flex flex-row gap-2">
<span hlmBadge>HTML</span>
<span hlmBadge variant="secondary">Tailwind</span>
<span hlmBadge variant="outline">Spartan</span>
</div>
<button hlmBtn>Read more</button>
</div>
</section>The four layers
- Elements.
div,p,h1toh6,ul,li,a,span,img,button. On the web they are the browser's own. On a device, MasonKit registers native elements under the same tag names with@nativescript/angular. - Layout. CSS flex and grid. See Layout with flex and grid.
- Styling. Tailwind utility classes using token names such as
bg-background,text-foregroundandbg-primary text-primary-foreground. See Theming. - Components. Spartan helm, as attributes and small components. See Components.
Which tag for which job
If you are coming from NativeScript tags, this is the HTML-first replacement for each one. The links go to each tag's page, which shows the same mapping with a live example.
| NativeScript tag | HTML first |
|---|---|
StackLayout | div with flex flex-col or flex flex-row |
GridLayout | div with grid, grid-cols-* and grid-rows-* |
FlexboxLayout | div with flex and the justify, items and order classes |
WrapLayout | div with flex flex-wrap |
DockLayout | a grid with an auto 1fr auto template |
AbsoluteLayout | relative container with absolute children |
Label, FormattedString, Span | p, span, strong, em |
Image | img |
ScrollView | div with overflow-auto on the web, <scroll> in the native example app |
ListView, Repeater | @for over ul and li |
Button, TextField | button hlmBtn, input hlmInput |
Shared between web and native
Pages that use only plain elements, token classes and helm can live in packages/shared and render in both apps. See Writing shared HTML features. Anything that needs a platform API stays in apps/web or apps/native. See Web vs native.