Skip to content

Input

A single-line text field. Supports a label, hint, error, prefixes and suffixes, a character counter, and a clear button (data-ts-clear).

Forms · TaishoDS Core, in plain HTML.

Examples

One working example per case. Each example is the HTML of its preview—copy it as is, and with Core’s CSS and JS loaded, it looks and works the same.

Field with label and placeholder

html

Email with hint

html

With error

html

With a leading icon

html

With a text prefix

https://
html

Clearable

html

Loading

html

Search that waits until you stop typing

html

Class reference

Every value of each modifier, with its HTML ready to copy.

Size

Field height: sm, md, or lg.

html

Variant

The border color for validation: default, success, warning, info, or danger. variant-bare (not shown here) removes the box and the focus, for a field inside another component.

html

Density

The field’s inner spacing.

html

States

is-disabled blocks editing; is-readonly prevents it but keeps the field focusable and selectable; is-loading shows the Spinner without blocking anything.

html

Combinations

Size, variant, and density combined.

html

When to use

  • Capturing short, single-line text, like a name, email, search query, or code.
  • You need a prefix or suffix (a unit, an icon) or a clear button.
  • Use type to switch to email, password, or tel and get the right system keyboard.

When not to use

  • The text can be long or span several lines → textarea.
  • It’s a number with limits and a step → number-input.
  • It’s a date → date-picker.

Do

  • Build it with the field markup for the label and messages.
  • Pick the right type. It improves the mobile keyboard and validation.

Don’t

  • Don’t use the placeholder as a label.
  • Don’t use it to choose from a closed set → select.

TaishoDS Core

Needs Core’s JS, which hooks in through data-ts-* attributes.

It’s a native <input>, plus its own clear button.

Core hooks into it through these attributes. They go in the markup, and there’s nothing to initialize.

  • data-ts-clear
  • data-ts-debounce
  • data-ts-field-spinner
  • data-ts-input

What it does: Keeps the field in sync. On init, the caret of every field with a value moves to the end, so element.focus() from code doesn’t type before the existing text. Tab (which selects everything) and clicking work as usual.

Attribute What it does
data-ts-field-spinnerThe Spinner the example leaves hidden. setInputLoading(root, true | false) marks the field as busy (aria-busy) and shows it. It doesn’t block editing.
data-ts-debounce="ms"On the <input>. Core fires ts:debouncedinput (with detail.value) once the person stops typing. Clearing reports the empty value right away.
data-ts-clearA button that only shows when there’s content. Clicking it clears the field, fires input and change, and returns focus to the field.

From the CDN, without a build, load taisho.input.css along with taisho.base.css. Also load:

  • taisho.button.css
  • taisho.icon.css
  • taisho.kbd.css
  • taisho.spinner.css

For how Core works in general, see Behavior.

Accessibility

  • The label is associated with the input through for/id. The id is written in the HTML and must be unique on the page.
  • The hint text (ts input-hint) and the error message are linked to the field through aria-describedby. An invalid field carries aria-invalid="true".
  • The clear button (data-ts-clear) has its own aria-label, written in the HTML.
  • The container’s is-readonly class (together with readonly on the <input>) makes the background transparent and the cursor default, with no visual escalation on hover. The field stays focusable and selectable, distinguishable from both an editable field and a disabled one. The clear button is always in the HTML, toggled with hidden depending on whether there’s content. data-ts-clear toggles it, and after clearing, focus returns to the field.
  • is-loading does NOT disable the field (unlike the button). The <input> stays editable. setInputLoading(root, true|false) sets is-loading and aria-busy="true" while loading lasts. The class alone isn’t announced. The Spinner itself makes the announcement (role="status" with its aria-label)—it isn’t duplicated with another live text. The Spinner sits next to “Clear field” in ts input-actions.
  • With element.focus() from code (for example, when a form opens), the caret lands at the end of the value, so what’s typed continues the text instead of being inserted before it. With Tab, the browser selects all the content.
  • With data-ts-debounce, the ts:debouncedinput event waits until the person stops typing. It’s meant to trigger is-loading and aria-busy only then, without flooding the screen reader with a “Loading” on every keystroke. The input event stays immediate.

Verification

What was actually tested. Anything that wasn’t tested says so—we’d rather say “not verified” than claim too much.

  • axe WCAG 2.2 A + AA in a real browser, in light and dark mode, before every release.
  • keyboard Adds no keys of its own—it uses the browser’s native behavior.
  • screen reader Not verified with a screen reader. Test it in your own combination of components, not just here, where each one appears alone and on its happy path.