1. Reference
  2. Data

<attr>

Declares one prop of a tag of your own in full: its name, type and default value.

Data
attr.ham
<tag name="price-tag"
     amount="0.0">
    <attr name="currency"
          type="text"
          default="USD"/>
    <row style="gap-6 items-center">
        <text @text="$amount"
              style="font-bold text-xl"></text>
        <text @text="$currency"
              style="muted"></text>
    </row>
</tag>
<column style="gap-8">
    <price-tag amount="24.5"/>
    <price-tag amount="19.5"
               currency="EUR"/>
</column>
The snippet drawn by Hype Apps on a phone, in light mode The snippet drawn by Hype Apps on a phone, in dark mode
This snippet as Hype Apps draws it on a phone. It follows this page's light or dark theme.

Attributes

NameWhat it doesDefault
bind true makes the attribute two-way: the instance passes a $variable and a write to $name inside the body writes that variable.
boolean
false
default The value when the instance gives none; empty without one.
string
name The attribute's name ($name in the body).
string
type What the attribute takes; a value of the wrong type warns and the default stands.
text, int, number, bool, color, style, url, command
text

Any tag also takes gestures: @on.tap, @on.longpress, @on.doubletap and @on.swipeleft (and right, up and down). @click runs on a tap too.

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