Component · in flow

Form fields

Select, TextField and TextArea: native controls in one look, with a label, a hint and an error that assistive technology reads with them.

As on the invoice.

Used on every document.

Sets the discount.

States

Needed for the price.

Search and suffix

Press × to clear it.

Reported costs only.

Kč

You can change it later.

.example.com
of each month, 00:00 UTC

One caret

The Select's chevron, also on a Popover's or Menu's button with caret. It turns while open.

Anything here.

Astro

---
import Select from '@subfloor/astro/Select.astro'
import TextField from '@subfloor/astro/TextField.astro'
---
<Select id="group" name="group" label="Price group" value="shops"
  options={[
    { value: 'shops', label: 'Shops' },
    { value: 'public', label: 'Public' },
  ]} />

<!-- or your own options and groups -->
<Select id="plan" name="plan" label="Plan">
  <optgroup label="Paid"><option value="pro">Pro</option></optgroup>
</Select>

<TextField id="email" name="email" type="email" label="E-mail"
  hint="We only use it to reply." error={errors.email} required />

<TextField id="q" name="q" type="search" label="Find a service" hideLabel
  placeholder="Find a service" clearLabel="Clear the search" />
<TextField id="budget" name="budget" label="Budget" suffix="Kč" short />

React

import { Select, TextArea, TextField } from '@subfloor/react'

<Select
  label="Price group"
  error={errors.group}
  options={groups}
  {...register('group')} // native props and ref go to the <select>
/>
<TextField label="E-mail" type="email" autoComplete="email" />
<TextArea label="Message" rows={6} />

// Controlled: onValueChange also gets what was entered before React hydrated.
<TextField type="search" label="Find a service" hideLabel
  placeholder="Find a service" value={query} onValueChange={setQuery} />

// The same caret on a button
<Menu label="Actions" menuLabel="Actions" caret items={items} />

Pick one to continue.

Size: none

With a caret on its button.

For each order.

kg

Changes: none

Markup

<div class="sf-field">
  <label class="sf-field__label" for="group">Price group</label>
  <p class="sf-field__hint" id="group-hint">Sets the discount.</p>
  <div class="sf-select">
    <select class="sf-field__control sf-select__control" id="group" name="group"
      aria-describedby="group-hint group-error" aria-invalid="true">…</select>
    <span class="sf-caret" aria-hidden="true"></span>
  </div>
  <p class="sf-field__error" id="group-error" role="alert">Choose a group.</p>
</div>

<!-- Search. The label is hidden on screen. Keep the placeholder, a space if you have none:
     without the attribute, the clear button also shows while the field is empty. -->
<div class="sf-field">
  <label class="sf-field__label" for="q" data-hidden>Find a service</label>
  <div class="sf-field__search">
    <input class="sf-field__control" type="search" id="q" placeholder=" ">
    <button type="button" class="sf-field__clear" aria-label="Clear">×</button>
  </div>
</div>

<!-- A short field (data-short) with a suffix. -->
<div class="sf-field" data-short>
  <label class="sf-field__label" for="budget">Budget</label>
  <div class="sf-field__row">
    <input class="sf-field__control" id="budget" aria-describedby="budget-suffix">
    <span class="sf-field__suffix" id="budget-suffix">Kč</span>
  </div>
</div>

<script type="module">
  import { initClearButtons } from '@subfloor/core'
  // Makes the clear buttons work, and shows them in place of the browser's.
  initClearButtons()
</script>

Behaviour

Without JavaScript

Everything on this page works except the turning caret on Popover and Menu buttons and the clear button of search fields, which need the script. There the browser’s own clear button stays, if it has one. React fields need React to render them.

Customisation

:root {
  --sf-field-border-color: #64748b; /* keep 3:1 against the background */
  --sf-field-short-width: 8rem;
  --sf-caret-size: 1.25rem;
  --sf-caret-color: var(--brand);
}
TokenDefault
--sf-radius-control8px
--sf-color-danger#b91c1c
--sf-field-border-color#71717a
--sf-field-font-size1rem
--sf-field-gapvar(--sf-space-1)
--sf-field-paddingvar(--sf-space-3)
--sf-field-short-width6rem
--sf-field-suffix-gapvar(--sf-space-2)
--sf-caret-size1rem
--sf-caret-gapvar(--sf-space-2)
--sf-caret-colorcurrentcolor

Background

Content 1. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 2. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 3. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 4. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 5. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 6. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 7. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 8. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 9. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 10. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 11. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.

Content 12. Background text that only exists so there is something to scroll. When an overlay is open, this must stay exactly where it is, whatever the wheel, the keyboard or a finger does.