Colour theme

Input

  • Primitives

  • fields

One native text field, styled on the element itself: it stands in a stack that draws nothing, so every state — hover, autofill, focus, invalid, read-only, disabled — is the field's own and nothing has to mirror it. It speaks the field voice and stands on a button's height at each size; whether it is invalid is decided once, by aria-invalid, so what is seen and what is announced agree.

Sizes

sm, md and lg: the field voice's font-size stop. The block padding follows it, so a field and a button at the same size line up — md by default.

astro
---
import Input from "tsugite/Input/Input.astro";
import ActionButton from "tsugite/Button/ActionButton.astro";

const sizes = ["sm", "md", "lg"];
---
{/* A field and a button at the same size stand at the same height: size sets the
    font-size stop, and the block padding follows it in each one's em (ADR-0030). */}
{sizes.map((size) => (
  <div style="display: flex; flex-wrap: wrap; gap: var(--size-sm); align-items: flex-start">
    <Input size={size} aria-label={`Email (${size})`} placeholder={`you@example.com · ${size}`} />
    <ActionButton size={size}>Subscribe</ActionButton>
  </div>
))}

Slots

start and end: what sits in the field — a search glass, a lock on a disabled field. The slot lies above the field and a click on it lands in the field; the padding makes room, and the slot reads the field's state.

astro
---
import Input from "tsugite/Input/Input.astro";
---
{/* A slot at each end (ADR-0038): the field stands in a stack, the slot lies above it and
    lets the pointer through, and the field's padding makes room. A slot reads the field's
    state — the lock on a disabled field takes the disabled ink by itself. */}
<div style="display: flex; flex-wrap: wrap; gap: var(--size-sm); align-items: flex-start" data-slots-example>
  <Input type="search" aria-label="Search the docs" placeholder="Search the docs" data-slot-field="search">
    <svg slot="start" viewBox="0 0 24 24" width="100%" height="100%" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
      <circle cx="11" cy="11" r="7" /><path d="m20 20-4-4" />
    </svg>
  </Input>
  <Input aria-label="Membership number" value="SL-104 223" disabled data-slot-field="locked">
    <svg slot="end" viewBox="0 0 24 24" width="100%" height="100%" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
      <rect x="5" y="11" width="14" height="9" rx="2" /><path d="M8 11V8a4 4 0 0 1 8 0v3" />
    </svg>
  </Input>
</div>

Test bench

The Input fixture — the state map as a matrix, the text types, validity and the height row, mounted unchanged.

Input

The state map

One table per content — empty, a placeholder, a value. Idle, the field with no state, stands above each table; in the table each state is alone on the diagonal and two states meet below it. The same cell across the three tables shows what a state does to each kind of content. What cannot happen is hatched with its reason; pairs reached only through aria-invalid, or not yet measured, are marked.

Empty: no value, no placeholder

idle

hover

autofill

focus

invalid

read-only

disabled

hover

autofill

unreachable

an autofilled field has a value

unreachable

an autofilled field has a value

focus

unreachable

an autofilled field has a value

invalid

unreachable

an autofilled field has a value

read-only

unreachable

an autofilled field has a value

aria only

barred from validation: :invalid never matches

disabled

:hover matches a disabled input in all three engines

unreachable

an autofilled field has a value

unreachable

a disabled field takes no focus

aria only

barred from validation: :invalid never matches

both attributes; disabled answers

hover + focus + invalid

pointing at the field being corrected

Placeholder: no value, a placeholder

idle

hover

autofill

focus

invalid

read-only

disabled

hover

autofill

unreachable

an autofilled field has a value

unreachable

an autofilled field has a value

focus

unreachable

an autofilled field has a value

invalid

unreachable

an autofilled field has a value

read-only

unreachable

an autofilled field has a value

aria only

barred from validation: :invalid never matches

disabled

:hover matches a disabled input in all three engines

unreachable

an autofilled field has a value

unreachable

a disabled field takes no focus

aria only

barred from validation: :invalid never matches

both attributes; disabled answers

hover + focus + invalid

pointing at the field being corrected

Value

idle

hover

autofill

focus

invalid

read-only

disabled

hover

autofill

focus

invalid

a filled value can fail the field's rules

read-only

? unmeasured

does an engine fill a read-only field? read by hand

aria only

barred from validation: :invalid never matches

disabled

:hover matches a disabled input in all three engines

? unmeasured

does :autofill survive a script disabling the field? read by hand

unreachable

a disabled field takes no focus

aria only

barred from validation: :invalid never matches

both attributes; disabled answers

hover + focus + invalid

pointing at the field being corrected

autofill + focus + invalid

a filled value that fails, being corrected

hover + autofill + focus

a filled field in use

Types

text

email

number

password

search

tel

url

date

time

Validity

A required email. Untouched, it stays quiet; type and leave it, or submit, and the kernel marks it aria-invalid; correct it and the mark clears.

Submit

Height: an Input beside a Button md

The same height by construction, on the native text-box and on the forced fallback.