1. Docs
  2. Cookbook

An hourly forecast

The weather now in a big card, and the hours ahead as a strip of cards you scroll sideways.

3 steps · ends in a weather card over an hourly strip

A row that scrolls sideways is how many apps show what comes next: hours, days, stories, categories. In HAM it's an ordinary <row> with scroll="x".

Step 1 of 3

The weather and the hours

What it's like now, as three lines of text, and a <@foreach> over an hour table seeded with the afternoon: each hour's time, an icon name, the temperature and the chance of rain.

app.ham · step 1
<app>    <config primary_color="light-blue"/>    <database name="weather"              version="1">        <model name="hour">            <field name="time"/>            <field name="icon"/>            <field name="temp"                   type="int"/>            <field name="rain"                   type="int"/>            <seed>[{"time": "Now", "icon": "sunny", "temp": 24, "rain": 0}, {"time": "2 pm", "icon": "sunny", "temp": 25, "rain": 0}, {"time": "3 pm", "icon": "partly_cloudy_day", "temp": 25, "rain": 10}, {"time": "4 pm", "icon": "cloud", "temp": 23, "rain": 30}, {"time": "5 pm", "icon": "rainy", "temp": 21, "rain": 70}, {"time": "6 pm", "icon": "rainy", "temp": 20, "rain": 60}, {"time": "7 pm", "icon": "partly_cloudy_night", "temp": 19, "rain": 20}]</seed>        </model>    </database>    <screen>        <app-bar title="Lisbon"/>        <main>            <column style="w-full p-16 gap-16">                <column>                    <text>24°</text>                    <text>Sunny, rain from 5 pm</text>                    <text>High 25° · Low 17°</text>                </column>                <@foreach in="hour"                          order="id"                          as="h">                    <text>                        @{$h.time}: @{$h.temp}°, @{$h.rain}% rain                    </text>                </@foreach>            </column>        </main>    </screen></app>
Step 1 on a phone: The weather and the hours Step 1 on a phone, dark: The weather and the hours
Step 1, drawn by the engine from the snippet beside it.

Step 2 of 3

A strip you scroll sideways

<row scroll="x" spacing="10"> lays the hours side by side, 10 points apart, and scrolls when they're wider than the screen. Each hour is a small card: the time, its weather icon (name="$h.icon …" reads the icon from the row), the temperature and the chance of rain.

app.ham · step 214 new lines
<app>    <config primary_color="light-blue"/>    <database name="weather"              version="1">        <model name="hour">            <field name="time"/>            <field name="icon"/>            <field name="temp"                   type="int"/>            <field name="rain"                   type="int"/>            <seed>[{"time": "Now", "icon": "sunny", "temp": 24, "rain": 0}, {"time": "2 pm", "icon": "sunny", "temp": 25, "rain": 0}, {"time": "3 pm", "icon": "partly_cloudy_day", "temp": 25, "rain": 10}, {"time": "4 pm", "icon": "cloud", "temp": 23, "rain": 30}, {"time": "5 pm", "icon": "rainy", "temp": 21, "rain": 70}, {"time": "6 pm", "icon": "rainy", "temp": 20, "rain": 60}, {"time": "7 pm", "icon": "partly_cloudy_night", "temp": 19, "rain": 20}]</seed>        </model>    </database>    <screen>        <app-bar title="Lisbon"/>        <main>            <column style="w-full p-16 gap-16">                <column>                    <text>24°</text>                    <text>Sunny, rain from 5 pm</text>                    <text>High 25° · Low 17°</text>                </column>                <text style="font-bold">Today</text>                <row scroll="x"                     spacing="10">                    <@foreach in="hour"                              order="id"                              as="h">                        <column style="w-72 py-14 gap-8 items-center rounded-2xl bg-grey-100 dark:bg-grey-900">                            <text style="font-sm muted">@{$h.time}</text>                            <icon name="$h.icon size-28 amber"/>                            <text style="font-bold">@{$h.temp}°</text>                            <text style="font-xs text-light-blue">@{$h.rain}%</text>                        </column>                    </@foreach>                </row>            </column>        </main>    </screen></app>
Step 2 on a phone: A strip you scroll sideways Step 2 on a phone, dark: A strip you scroll sideways
Step 2, drawn by the engine from the snippet beside it.

Step 3 of 3

The big card

The current weather becomes a card that fades from light blue to cyan, with the temperature 64 points tall beside a sun, and the summary and the day's range in white.

app.ham · step 38 new lines
<app>    <config primary_color="light-blue"/>    <database name="weather"              version="1">        <model name="hour">            <field name="time"/>            <field name="icon"/>            <field name="temp"                   type="int"/>            <field name="rain"                   type="int"/>            <seed>[{"time": "Now", "icon": "sunny", "temp": 24, "rain": 0}, {"time": "2 pm", "icon": "sunny", "temp": 25, "rain": 0}, {"time": "3 pm", "icon": "partly_cloudy_day", "temp": 25, "rain": 10}, {"time": "4 pm", "icon": "cloud", "temp": 23, "rain": 30}, {"time": "5 pm", "icon": "rainy", "temp": 21, "rain": 70}, {"time": "6 pm", "icon": "rainy", "temp": 20, "rain": 60}, {"time": "7 pm", "icon": "partly_cloudy_night", "temp": 19, "rain": 20}]</seed>        </model>    </database>    <screen>        <app-bar title="Lisbon"/>        <main>            <column style="w-full p-16 gap-16">                <column style="w-full p-24 gap-4 rounded-3xl gradient-tl-lightblue-cyan-br shadow-lg">                    <row style="w-full items-center">                        <text style="text-white font-size-64 font-bold"                              flex="1">24°</text>                        <icon name="sunny fill size-64 amber"/>                    </row>                    <text style="text-white font-bold">Sunny, rain from 5 pm</text>                    <text style="text-white opacity-80 font-sm">High 25° · Low 17°</text>                </column>                <text style="font-bold">Today</text>                <row scroll="x"                     spacing="10">                    <@foreach in="hour"                              order="id"                              as="h">                        <column style="w-72 py-14 gap-8 items-center rounded-2xl bg-grey-100 dark:bg-grey-900">                            <text style="font-sm muted">@{$h.time}</text>                            <icon name="$h.icon size-28 amber"/>                            <text style="font-bold">@{$h.temp}°</text>                            <text style="font-xs text-light-blue">@{$h.rain}%</text>                        </column>                    </@foreach>                </row>            </column>        </main>    </screen></app>
Step 3 on a phone: The big card Step 3 on a phone, dark: The big card
Step 3, drawn by the engine from the snippet beside it.

This page is also Markdown, and all of HAM is in llms.txt.