1. Reference
  2. Forms and input

<search-bar>

A search field with a magnifying glass; name= publishes what is typed, Return fires submit.

Forms and input
search-bar.ham
<column style="gap-12">
    <search-bar name="q"
                placeholder="Search recipes"/>
    <text @text="$q == '' ? 'Try pasta or curry' : 'Searching for ' + $q"
          style="muted"></text>
</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
name Variable name for form scoping
string
placeholder Placeholder text
string
Search…
value Initial value
string

Readings

NameWhat it does
error The validation message for the text; empty when valid.
focused Whether the field has the keyboard focus.
length How many characters are in the field, live.
max_length The max-length= in force (a code input: its length=), in characters; empty when none.
valid Whether the text passes the field's rules (required, min-length, pattern …); true with no rules.
value The text in the field, live as it is typed.

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.