For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /guide/elements/index.md.

Elements and layout

AngularLynx templates use Lynx elements, such as <view>, <text> and <image>, instead of HTML tags. Each element becomes a real piece of iOS or Android UI, so your app looks, scrolls and responds like any other app on the phone.

Build a screen from Lynx elements

src/app/profile-card.ts
import { Component } from '@angular/core';
import { LYNX_ELEMENTS } from '@blotch/angular-lynx';

@Component({
  selector: 'app-profile-card',
  imports: [LYNX_ELEMENTS],
  template: `
    <view class="flex flex-row items-center gap-3 rounded-xl bg-card p-4">
      <image
        src="https://avatars.githubusercontent.com/u/1"
        class="h-12 w-12 rounded-full"
      />
      <view class="flex-1">
        <text class="font-semibold text-foreground">Ada Lovelace</text>
        <text class="text-sm text-muted-foreground">Mathematician</text>
      </view>
    </view>
  `,
})
export class ProfileCard {}
  • There's no browser underneath. iOS and Android each have their own UI toolkit, and Lynx turns each element into a piece of it. HTML tags have no meaning there, so Lynx defines its own small set.
  • <view> is the box, like a <div>. <text> holds text and <image> shows a picture. The mapping table lists the rest.
  • Import LYNX_ELEMENTS in every component that uses Lynx elements. The template type checker and ng test need it. The build accepts the tags and their attributes without it, and warns about a component you use but left out of imports, or a mistyped input (see Elements).
  • Common HTML tags render as Lynx elements. A <div> renders as a <view>, and a <p> as a <text>. That gets ported web code on screen. See HTML tags.

Style elements with CSS classes or style, as on the web. Lynx CSS has some gaps, such as no :hover and no ::before. See CSS on Lynx.

Put all text in <text>

<view class="rounded-xl bg-card p-4">
  <text class="text-base text-foreground">
    Your order of
    <text class="font-bold">3 items</text>
    ships
    <text class="text-destructive">tomorrow</text>.
  </text>
</view>
  • Only a <text> draws text. A word placed straight in a <view> still shows, because AngularLynx wraps it in a <text> of its own. That <text> takes the text styles of its ancestors' classes, as the HTML tags do.
  • Nest <text> for inline styles. A <text> inside another <text> flows inline, like a <span>, and picks up text styles such as color from the outer one.
  • Write text across lines naturally. AngularLynx trims the leading and trailing spaces that template indentation leaves, so the text above renders flush.
  • From a <view>, a <text> you write inherits only its font size. A font-size on the <view> reaches it, as on the web, but a color doesn't. Set the other text styles on the <text> itself. Inside another <text>, it inherits more.

Lay out with the default column

<view class="gap-2 p-4">
  <text>First</text>
  <text>Second</text>
  <view class="self-start rounded-full bg-muted px-3 py-1">
    <text class="text-sm">Hugs its content</text>
  </view>
</view>

Every element starts in Lynx's linear layout, display: linear. Children stack top to bottom, like a vertical flex column.

  • Children stretch to the full width. A child with no width fills its parent's cross axis. Add self-start (align-self: flex-start) to make it hug its content, as a badge or pill should.
  • There's no block or inline. Lynx has no text flow outside <text>, so every element is a box.
  • Boxes use border-box, and margins never collapse. Two 16px margins between siblings give 32px of space.

Use flex for rows and alignment

<view class="flex flex-row items-center justify-between p-4">
  <text class="text-foreground">Notifications</text>
  <text class="text-muted-foreground">On</text>
</view>
  • Add flex (display: flex) first. It switches the element to flexbox, which behaves like CSS flexbox on the web. Its default direction is a row, as on the web.
  • flex-row alone does nothing. Linear layout ignores flex-direction, so a view with flex-row but no flex still stacks its children.
  • grid works too. Use display: grid when you need rows and columns.

Scroll with <scroll-view> or <list>

<scroll-view scroll-orientation="vertical" class="h-[300px]">
  @for (item of items(); track item.id) {
    <view class="border-b border-border px-4 py-3">
      <text>{{ item.name }}</text>
    </view>
  }
</scroll-view>
  • overflow: scroll doesn't scroll. Only <scroll-view> and <list> scroll.
  • Give a <scroll-view> a height. Use a fixed height, or h-full inside a parent with a known height. Without one, it grows to fit its content and never scrolls.
  • flex-1 on the scroll view doesn't bound it. To fill leftover space, put flex-1 flex flex-col on a wrapping <view> and h-full w-full on the <scroll-view>.
  • Use <list> for long or endless lists. It only creates the rows on screen and reuses them as you scroll. See <list>.

Float content above the page

Use <overlay> for dialogs, sheets and menus that sit on top of everything. position: fixed doesn't pin to the screen on Lynx: it positions against the app's root element, the page, and scrolls with it. See Dialogs and overlays.

HTML tags

<div class="card">
  <h2>{{ name() }}</h2>
  <p>Joined <strong>today</strong></p>
  <img [src]="avatar()" alt="Avatar" class="h-12 w-12" />
  <button (click)="follow()">Follow</button>
</div>

A template written for the browser renders: AngularLynx creates the Lynx element each common HTML tag stands for.

  • <view>: div, section, article, aside, header, footer, main, nav, ul, ol, li, dl, dt, dd, form, fieldset, figure, figcaption, blockquote, address, hgroup, search, menu and hr.
  • <text>: span, p, h1–h6, a, button, label, strong, b, em, i, small, code, s, u, mark, sub, sup, abbr, cite, q, time, del, ins, kbd, samp, var and dfn.
  • <image auto-size>: img.
  • Already Lynx elements: input, textarea, video, canvas and svg.

What carries over:

  • Text tags hold text. Text shows inside them, and a tag inside one runs inline, so <p>Joined <strong>today</strong></p> reads as one line.
  • Text and inline tags share a line. In a block tag or a <view>, text runs on as one line with the inline tags beside it: <div>Hi <b>there</b>, <a>friend</a></div>. Inline tags are span, a, strong and the like, not p or button. In a flex or grid container, each is an item of its own, as on the web.
  • A space alone between two tags is dropped, as in any Angular app. Angular's compiler deletes whitespace-only text by default, so <b>Name:</b> <span>{{ name }}</span> reads "Name:Ada" in a browser too. Write the space as &ngsp; (<b>Name:</b>&ngsp;<span>…</span>), put it inside a tag, or set preserveWhitespaces: true on the component.
  • Text styles inherit. An ancestor's class or stylesheet rule can set color, font-size, font-weight, line-height or text-align. That reaches the text tags and the loose text inside it, as on the web. A <text> you write as a Lynx element takes only its font size this way.
  • Inline styles inherit as rules do. An inline style or [style.x] binding passes text styles down to HTML text tags and loose text. So <div style="color: red"> colors the <p> inside it, and <text style="font-size: 18px"> the <b> inside it.
  • An <img> takes its picture's size, until CSS gives it one. Its alt is what screen readers say.
  • Type selectors still match. p { margin-bottom: 8px; } styles every <p>.
  • hidden hides the element, as [hidden]="!open()" does on the web.
  • DOM events Lynx also sends run. (click) runs on a tap. See Handling taps and events.

What doesn't carry over:

  • An inline tag in a <text> you write matches that <text>. That <text> inherits only its font size, so the tag takes the styles the <text> sets itself, and its size. <text>Total: <b>{{ sum }}</b></text> stays one size, whatever the size around it.
  • An inline tag in a line draws no box. On iOS and Android, a <span> or <code> in the middle of a line shows only its background, behind its letters. It has no padding, borders or rounded corners. A badge on a line of its own keeps them.
  • Inline text tags keep their browser text styles, with a few differences. See Inline tag styles.
  • A <q> draws quotation marks in its language, but some CSS can't change them. See Quotation marks.
  • There are no other browser styles. An <h1> is the size of any other text and a <button> has no border, as with Tailwind's Preflight reset. Style them yourself.
  • There's no browser behavior. <a href> opens nothing (use routerLink), a <form> doesn't submit, and disabled doesn't stop a <button>'s taps.
  • Other tags don't work. A <table>, <select> or <br> renders as a plain <view>, and the build warns about it.

Write Lynx elements in new code. They have their own attributes, such as <image mode>, and $event types with what each event sends.

Inline tag styles

The build gives inline text tags their browser text styles:

  • Bold: <b> and <strong>
  • Italic: <em>, <i>, <cite>, <dfn> and <var>
  • Underlined: <u> and <ins>
  • Struck through: <s> and <del>
  • Monospace: <code>, <kbd> and <samp>
  • Smaller: <small>, plus <sub> and <sup>, which are also lowered or raised
  • Black on yellow: <mark>
  • Underlined in the link color (lighter in dark mode): an <a> with an href
  • Dotted underline: an <abbr> with a title

Your own CSS for them wins, as it would in a browser. The differences:

  • Two lines from one pair. A <u> or <ins> (or a link) inside an <s> or <del>, or the other way round, gets both lines. They come from a rule with two classes, which beats a single class of yours on either tag of the pair.
  • <a routerLink> keeps the text's style. It has no href, so it isn't styled as a link.
  • Raised tags don't add em to pixels. On iOS and Android, a <sup> or <sub> inside a tag you raise by pixels (vertical-align: 10px) rises by its own distance only. Lynx can't add an em distance to pixels.
    • Raise the outer tag by an em distance instead, and the <sup> rises by both.
    • Or give the <sup> a pixel distance of its own (style="vertical-align: 6px"), which adds to the outer tag's.
    • The same goes for a tag with an em distance in its own inline style, inside a tag raised by pixels.
  • Android draws no dotted line under an <abbr>. Lynx Explorer on Android also draws <code> in the default font, not monospace. Your app's own build has it.

Quotation marks

A <q> draws quotation marks in its language, as a browser does:

  • “ ” around its text in English, and ‘ ’ inside another <q>
  • « » in French
  • „ “ in German

Its language is the nearest lang attribute on it or above it. Without one, it's the app's LOCALE_ID (which provideLocale() sets), as a localized web build sets <html lang> to the locale.

CSS quotes changes the marks, as in a browser. Set it in a rule (q { quotes: '«' '»' '‹' '›' }, or none for no marks), on the <q> or inherited from an element above it. An inline style works too.

Some quotes values leave a <q> its language's marks:

  • A rule the runtime can't tell applies to the <q>: a selector with an attribute, a sibling or :first-child, or a rule in a @media
  • A var()

HTML to Lynx mapping

HTMLLynxNotes
<div><view>Generic container
<span>, <p>, <h1>...<h6><text>All text content
<img><image>Needs a size. mode replaces object-fit
<div style="overflow:auto"><scroll-view>Dedicated scrolling element
<ul> / virtual scroll<list> + <list-item>Native virtualization
<input><input>Events use bindinput
<textarea><textarea>Events use bindinput
<button><view> + (bindtap)A <button> renders as a <text>
<a><view> + routerLinkAn <a> renders as a <text>
<dialog>, modal<overlay>Native floating layer
Swipeable page carousel<viewpager> + <viewpager-item>Native horizontal paging
<iframe><frame>Loads Lynx bundles
<iframe> (web content)<webview>Loads URLs or HTML
<video><video>Controlled via UI methods
<svg><svg>Markup in content, or a file in src
backdrop-filter: blur()<blur-view>Also iOS's translucent glass material

For buttons, inputs and other controls with a finished look, use the UI components.

Every element, including the ones with no HTML equivalent, has a reference page under API → Elements.