Your first screen
Build a profile screen from the smallest app, one step at a time: a title bar, a photo, a name, some numbers, a cover, and a Follow button that works.
8 steps · ends in a profile with a cover and a working Follow button
Aliases
Reset to canonicalThis tag has more than one name. Every spelling is the same tag, so write whichever feels natural. Pick one and every example on this page uses it.
A HAM app is a document of tags. Each tag names a native component the phone already has: a title bar, a column, a button. You write which ones you want and how they nest, and the app draws them with the platform's own controls. Nothing you write runs as code on the phone.
This guide starts from nothing and grows one snippet into a profile screen. Each step adds one idea. You can copy any step and run it as is.
Step 1 of 8
Start with the smallest app
Every HAM document starts with <app>, which holds the app's settings and its screens. A <screen> is one full page of the app, and <main> holds what's on it. Here that's one line of <text>. This is the smallest app that draws something.
<app> <screen> <main> <text>Hello</text> </main> </screen></app>
Step 2 of 8
Add a title bar and a color
<app-bar> is the bar across the top of the screen, with the page's title. It goes inside <screen>, beside <main>.
<config> holds settings for the whole app. primary_color is the color its controls use: buttons, switches, the selected tab. Pick it now and everything you add from here on wears it. Use a named color like teal, amber or rose; each has shades from 50 to 950, such as teal-600.
<app> <config primary_color="teal"/> <screen> <app-bar title="Profile"/> <main> <text>Hello</text> </main> </screen></app>
Step 3 of 8
Put some content in
The placeholder text goes, and the profile comes in. Build from the outside in: first a <column>, which stacks what's inside it from top to bottom. Then the content: an <avatar> with the person's initials in a named color, and two lines of <text> for their name and what they do.
Don't style anything yet. Getting the content in first shows you the shape of the page, and the styling comes after.
<app> <config primary_color="teal"/> <screen> <app-bar title="Profile"/> <main> <column> <avatar text="MC" size="96" color="teal"/> <text>Maya Chen</text> <text>Product designer in Lisbon</text> </column> </main> </screen></app>
Step 4 of 8
Add a row of numbers
A <row> lays out what's inside it side by side. Here it holds three small columns, each a number over its label. That's the same pattern as the outer column, one level in.
<app> <config primary_color="teal"/> <screen> <app-bar title="Profile"/> <main> <column> <avatar text="MC" size="96" color="teal"/> <text>Maya Chen</text> <text>Product designer in Lisbon</text> <row> <column> <text>48</text> <text>Posts</text> </column> <column> <text>1,204</text> <text>Followers</text> </column> <column> <text>312</text> <text>Following</text> </column> </row> </column> </main> </screen></app>
Step 5 of 8
Add a button
A <button> is the platform's own button. Give it a label and it's ready to tap. It doesn't do anything yet; that comes last.
<app> <config primary_color="teal"/> <screen> <app-bar title="Profile"/> <main> <column> <avatar text="MC" size="96" color="teal"/> <text>Maya Chen</text> <text>Product designer in Lisbon</text> <row> <column> <text>48</text> <text>Posts</text> </column> <column> <text>1,204</text> <text>Followers</text> </column> <column> <text>312</text> <text>Following</text> </column> </row> <button>Follow</button> </column> </main> </screen></app>
Step 6 of 8
Space it out and size the type
Now that the content is in, style it with the style attribute. Its tokens will look familiar if you know Tailwind:
w-full py-24 gap-20 items-centermakes the column the screen's width, pads its top and bottom, puts 20 points between what's in it, and centers it across.font-2xl font-boldmakes the name large and bold, andmuteddims the line under it.justify-aroundspreads the three numbers evenly across the row.- The button sits in a padded column of its own.
variant="filled"fills it with the app's color, andw-full rounded-fullmakes it a full-width pill.
<app> <config primary_color="teal"/> <screen> <app-bar title="Profile"/> <main> <column style="w-full py-24 gap-20 items-center"> <avatar text="MC" size="96" color="teal"/> <column style="gap-4 items-center"> <text style="font-2xl font-bold">Maya Chen</text> <text style="muted">Product designer in Lisbon</text> </column> <row style="w-full px-24 justify-around"> <column style="items-center"> <text style="font-xl font-bold">48</text> <text style="muted font-sm">Posts</text> </column> <column style="items-center"> <text style="font-xl font-bold">1,204</text> <text style="muted font-sm">Followers</text> </column> <column style="items-center"> <text style="font-xl font-bold">312</text> <text style="muted font-sm">Following</text> </column> </row> <column style="w-full px-24"> <button variant="filled" style="w-full rounded-full">Follow</button> </column> </column> </main> </screen></app>
Step 7 of 8
Add a cover
A <stack> draws what's inside it in layers, one over the other. The first layer is a band of color across the top: top-0 left-0 right-0 pins it to the stack's top edge, h-130 makes it 130 tall, and gradient-tl-teal-cyan-br fades it from teal at the top left to cyan at the bottom right.
The avatar is the second layer. align-bottom centers it on the stack's bottom edge, so it overlaps the band, and rounded-full border-4 border-white shadow-lg rings it in white and lifts it off the page.
The column's top padding goes, so the band runs right up to the title bar.
<app> <config primary_color="teal"/> <screen> <app-bar title="Profile"/> <main> <column style="w-full pb-24 gap-20 items-center"> <stack style="w-full h-190"> <box style="top-0 left-0 right-0 h-130 gradient-tl-teal-cyan-br"/> <avatar text="MC" size="112" color="teal" style="align-bottom rounded-full border-4 border-white shadow-lg"/> </stack> <column style="gap-4 items-center"> <text style="font-2xl font-bold">Maya Chen</text> <text style="muted">Product designer in Lisbon</text> </column> <row style="w-full px-24 justify-around"> <column style="items-center"> <text style="font-xl font-bold">48</text> <text style="muted font-sm">Posts</text> </column> <column style="items-center"> <text style="font-xl font-bold">1,204</text> <text style="muted font-sm">Followers</text> </column> <column style="items-center"> <text style="font-xl font-bold">312</text> <text style="muted font-sm">Following</text> </column> </row> <column style="w-full px-24"> <button variant="filled" style="w-full rounded-full">Follow</button> </column> </column> </main> </screen></app>
Step 8 of 8
Make Follow work
Last, the button does something. Variables hold what's on the screen right now:
var-following="false"andvar-followers="1204"give the column two variables,$followingand$followers, with their starting values.@textshows a value and updates whenever it changes.format($followers, 'number')writes it as 1,204.@clickruns when you tap. Follow sets$following, adds one to$followers, gives the count a quick punch with#followers.animate:punch, and a lighthaptictap you can feel.@showshows an element only while its condition is true, so the screen shows one button at a time: Follow, or Following with a check.press:scale-95shrinks a button a little while your finger is on it.
Tap Follow and the count goes up with a punch, and the button turns into Following, right away, with no request to a server. That's your first screen.
<app> <config primary_color="teal"/> <screen> <app-bar title="Profile"/> <main> <column style="w-full pb-24 gap-20 items-center" var-following="false" var-followers="1204"> <stack style="w-full h-190"> <box style="top-0 left-0 right-0 h-130 gradient-tl-teal-cyan-br"/> <avatar text="MC" size="112" color="teal" style="align-bottom rounded-full border-4 border-white shadow-lg"/> </stack> <column style="gap-4 items-center"> <text style="font-2xl font-bold">Maya Chen</text> <text style="muted">Product designer in Lisbon</text> </column> <row style="w-full px-24 justify-around"> <column style="items-center"> <text style="font-xl font-bold">48</text> <text style="muted font-sm">Posts</text> </column> <column style="items-center"> <text id="followers" style="font-xl font-bold" @text="format($followers, 'number')"/> <text style="muted font-sm">Followers</text> </column> <column style="items-center"> <text style="font-xl font-bold">312</text> <text style="muted font-sm">Following</text> </column> </row> <column style="w-full px-24"> <button @show="!$following" @click="$following = true; $followers++; #followers.animate:punch; haptic:light" variant="filled" icon="person_add" style="w-full rounded-full press:scale-95">Follow</button> <button @show="$following" @click="$following = false; $followers--" variant="outlined" icon="check" style="w-full rounded-full press:scale-95">Following</button> </column> </column> </main> </screen></app>