Skip to content

Input

hc-input is applied to the standard <input>, <select>, and <textarea> elements. State (disabled, aria-invalid) lives on the element itself, exactly as in plain HTML.

data-size accepts sm, md (default), and lg.

The aria-invalid="true" attribute switches the border to the error color and changes the focus-ring color. Pair it with a message via hc-field.

data-variant recolors the border as a validation cue — success (green), warning (amber), error (red) — the same vocabulary as select, datepicker, and the other form fields. (textarea takes the same attribute.)

Prefer aria-invalid="true" over data-variant="error" for the error case — it paints the same border and announces the state to assistive tech. success / warning have no native attribute, so the variant is the only way to express them. See the cross-component Variants matrix.

hc-input works with htmx like any other input. The live-search recipe wires the input to send a request as the user types.

<input
class="hc-input"
type="search"
name="q"
placeholder="Search"
data-hx-get="/items"
data-hx-trigger="input changed delay:300ms, search"
data-hx-target="#results"
data-hx-swap="innerHTML">
  • Always associate inputs with a label. Use <label for="..."> linked to the input’s id, or wrap the input in a <label> element.
  • For validation errors, set aria-invalid="true" on the input and reference the message with aria-describedby.
  • Do not remove the focus outline. The component replaces the default outline with a visible border + box-shadow ring driven by --hc-color-focus-ring.
  • Prefer the native disabled attribute when the input must not be interactive. Use aria-disabled="true" only when the control must remain focusable.

Component tokens (in component.tokens.json):

Token pathPurpose
input.height / input.padding-xDefault size.
input.radiusBorder radius.
input.bg / input.fgDefault colors.
input.border / input.focus-borderBorder in normal/focus state.
input.success-border / input.warning-border / input.error-borderBorder for data-variant="success" / "warning" / aria-invalid.
input.placeholderPlaceholder color.
input.disabled-bgBackground when disabled.
input.{sm,lg}.{height,padding-x,font-size}Size-specific overrides.
Show the generated CSS variables
--hc-input-height
--hc-input-padding-x
--hc-input-radius
--hc-input-font-size
--hc-input-bg | -fg | -border | -placeholder
--hc-input-focus-border
--hc-input-success-border | -warning-border | -error-border
--hc-input-disabled-bg
--hc-input-sm-height | -padding-x | -font-size
--hc-input-lg-height | -padding-x | -font-size
--hc-color-focus-ring
--hc-color-error
  • Field — pairs an input with a label and message.
  • live-search recipe — input + htmx debounce + result region.