Reference

Input

Text field. With label, hint or error it is a labelled field.

Input(reveal: Bool, bind: State, label: String, …)

Before 5.0

reveal

label

type

text

email

password

number

search

placeholder

We send the invoice here.

Hello, Ada Lovelace

Example

wf

state name = "Ada Lovelace" state email = "" Stack(gap: .md) { Input(bind: name, label: "Full name", placeholder: "Ada Lovelace").text Input(bind: email, label: "Work email", hint: "We send the invoice here.", placeholder: "ada@example.com").email.required Text(if email == "" { "Hello, {name}" } else { "Hello, {name}: we write to {email}" }).muted }

A password with a button that shows it

wf

state password = "" Input(bind: password, label: "Password", hint: "At least 12 characters").password.reveal

With an error message

wf

state handle = "ada lovelace" derived handleError = if handle.includes(" ") { "A handle has no spaces." } else { "" } Input(bind: handle, label: "Handle", error: handleError).text

A number between two ends

wf

state seats = 5 Input(bind: seats, label: "Seats", min: 1, max: 50, step: 1).number Text("{seats} seats")

Disabled

wf

state workspace = "acme-prod" Input(bind: workspace, label: "Workspace", hint: "Ask an owner to rename it.").disabled

Props

Props of Input
PropTypeUnsetMeaning

reveal:

Bool

false

With .password: a Show/Hide button after the field that shows the password as text and hides it again, pressed (aria-pressed) while it shows. Written as a flag, .reveal, or reveal: true.

bind:

State

The state it reads and writes as you type: a String, a Number with .number (null when emptied), a Date with .date, a Time with .time, a DateTime with .datetime

label:

String

none

Visible label; also the control's accessible name

hint:

String

none

Help text under the control, linked to it by aria-describedby

error:

String

none

Error text (a string; empty when there is none): announced as it appears and sets aria-invalid

type:

one of its cases

text

What the field holds, and so the keyboard and picker a browser offers; it also sets what bind: holds. Written as a flag, .text, or by name, type: .text.

  • .text (the default): Plain text
  • .email: An email address
  • .password: A password, its characters hidden
  • .number: A number: bind: holds a Number
  • .search: A search query
  • .tel: A phone number
  • .url: A URL
  • .date: A day, from the browser's date picker: bind: holds a Date
  • .time: A time of day: bind: holds a Time
  • .datetime: A day and a time (datetime-local): bind: holds a DateTime
  • .color: A colour, from the browser's picker, as #rrggbb

placeholder:

String

none

Hint shown while the field is empty

value:

String or Number

empty

The text it starts with, when no state is bound; bind: takes its place

min:

Number or String

none

The lowest value a .number, .date or .time field takes: a number, or a date or time as text ("2026-01-01")

max:

Number or String

none

The highest value a .number, .date or .time field takes: a number, or a date or time as text

step:

Number

the browser's: 1, or 60 for a time

How far the arrow keys and the spinner move a .number value (seconds for .time)

required:

Bool

false

Whether the browser refuses to submit the form while it is empty. Written as a flag, .required, or required: true.

disabled:

Bool

false

Whether the control is inert: it cannot be focused or changed, and a form does not send it. Written as a flag, .disabled, or disabled: true.

size:

one of its cases

md

Its padding and text size. Written as a flag, .sm, or by name, size: .sm.

  • .sm: Less padding, smaller text
  • .md (the default): The default size
  • .lg: More padding, larger text

width:

one of its cases

none: the width of its container

Its width. Written as a flag, .full, or by name, width: .full.

  • .full: The whole width of its container (an input already is, outside a row)

rounded:

Bool

false

Fully rounded ends, a pill shape. Written as a flag, .rounded, or rounded: true.

Attribute families: global, aria, data, input. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

.reveal

.text

.email

.password

.number

.search

.tel

.url

.date

.time

.datetime

.color

.required

.disabled

.sm

.md

.lg

.full

.rounded

Events

The DOM events it is drawn to answer. Any other DOM event works too, in an on … { } handler.

DOM events Input answers
EventSendsMeaning
on inputDOMThe value changed, on every keystroke
on changeDOMThe value was committed
on keydownDOMA key went down; `e.key` names it
on focusDOMThe element received focus
on blurDOMThe element lost focus

Every element also takes the props, the events and the attribute families listed on every element.

Slots

It takes no slots.

Renders with the class wf-input, stable across releases, so a stylesheet may target it.