Skip to main content

Text

A label, the field and a line of help. The label is linked with for and id, the help text with aria-describedby.

As shown on your invoices.

Hint

A question-mark button next to the label opens a short hint. It uses the same aria-expanded popup as the dropdowns: Esc or a click outside closes it. The hint is also linked to the field with aria-describedby, so screen readers can read it while it is closed.

Optional.

Types

Use the right type so phones show the right keyboard and browsers can autofill.

Sizes

Three sizes: small, medium and large. Medium is the default and matches the height of a medium button.

States

A disabled field is skipped by the keyboard. A read-only field can be focused and copied. Mark required fields with required; the asterisk is hidden from assistive tech because the attribute already says it.

Date and time

Native pickers, so they work with the keyboard and on phones. min and max limit the dates. In dark mode the picker uses the browser's dark colour scheme.

File

type="file" gets a styled file button. Add multiple to allow several files.

PNG or JPG.

You can choose more than one file.

Validation

Add the HTML attributes required, type, pattern, minlength, min and max, and the browser checks the value when the form is sent. error shows a message at once, sets aria-invalid="true", and links the message with aria-describedby, for an error the server returns. Write a message that says how to fix the value.

Use an address like name@example.com.

At least 3 characters: lowercase letters, numbers or underscores.

You must be at least 18.

This username is already taken.