Skip to main content

Starwind UI v3.0 is now available! Migration guide

Input Primitive

Input is a Starwind Runtime primitive in the form-value-control contract family. Astro and React share one semantic component API. React coordinates reactive state through controlled and default props plus callbacks. Astro renders initial state and coordinates later changes through DOM events and Runtime methods. Raw HTML uses Runtime attributes, DOM events, and imperative methods.

Anatomy

Use the Astro primitive adapter to render Input anatomy with the Runtime wiring included.

---
import { Input } from "@starwind-ui/astro/input";
---
<Input.Root placeholder="Email" />

API Reference

Root

The main element that owns the Input Runtime instance.

Default element
input
Discovery hook
data-sw-input
Role
-

Props

Prop Type Default Toggle
value InputValue -
Description
Controls the current Input value.
Kind
control
Targets
-
Full type
InputValue
React

Use value for controlled state and defaultValue for default state, and onValueChange for state changes.

  • value
  • defaultValue
  • onValueChange
Astro

Use value or defaultValue for initial state, listen for starwind:value-change, and call setValue for later updates.

  • value
  • defaultValue
  • starwind:value-change
  • setValue
Runtime / HTML

listen for starwind:value-change and call setValue for later updates.

  • starwind:value-change
  • setValue
defaultValue InputValue -
Description
Sets the initial Input value for uncontrolled usage.
Kind
control
Targets
-
Full type
InputValue
React

Use value for controlled state and defaultValue for default state, and onValueChange for state changes.

  • value
  • defaultValue
  • onValueChange
Astro

Use value or defaultValue for initial state, listen for starwind:value-change, and call setValue for later updates.

  • value
  • defaultValue
  • starwind:value-change
  • setValue
Runtime / HTML

listen for starwind:value-change and call setValue for later updates.

  • starwind:value-change
  • setValue
disabled boolean false
Description
Disables the Root part.
Kind
option
Targets
-
Full type
boolean
name string -
Description
Sets the submitted form field name.
Kind
attribute
Targets
root
Full type
string
required boolean -
Description
Marks the form control as required.
Kind
attribute
Targets
root
Full type
boolean
onValueChange (value: string, details: InputValueChangeDetails) => void -
Description
Runs when the Input value changes.
Kind
callback
Targets
-
Full type
(value: string, details: InputValueChangeDetails) => void
React

Use value for controlled state and defaultValue for default state, and onValueChange for state changes.

  • value
  • defaultValue
  • onValueChange
Astro

Use value or defaultValue for initial state, listen for starwind:value-change, and call setValue for later updates.

  • value
  • defaultValue
  • starwind:value-change
  • setValue
Runtime / HTML

listen for starwind:value-change and call setValue for later updates.

  • starwind:value-change
  • setValue

Events

Event Callback Value Toggle
valueChange onValueChange value: string
Description
Fires when the value changes for Input.
DOM event
starwind:value-change
Details type
InputValueChangeDetails
Timing
-
Cancelable
No

State

State Type Props Toggle
value InputValue value / defaultValue
Description
Tracks the current Input value.
Initial attribute
-
Runtime getter
getValue
Runtime setter
setValue
React

Use value for controlled state and defaultValue for default state, and onValueChange for state changes.

  • value
  • defaultValue
  • onValueChange
Astro

Use value or defaultValue for initial state, listen for starwind:value-change, and call setValue for later updates.

  • value
  • defaultValue
  • starwind:value-change
  • setValue
Runtime / HTML

listen for starwind:value-change and call setValue for later updates.

  • starwind:value-change
  • setValue

Data Attributes

Runtime hooks
Attribute Value Description
data-sw-input - Marks the Root part so Starwind Runtime can find it.
Metadata
Attribute Value Description
data-disabled - Reflects the disabled prop on the Root part.

Runtime API

Factory
createInput
Import
@starwind-ui/runtime/input
Root hook
root data-sw-input
Option props
defaultValue, disabled, onValueChange, value

Runtime Setters

Method Target Description
setValue state: value Updates the current Input value from Runtime code.
setDisabled prop: disabled Updates whether Input is disabled from Runtime code.

Form Participation

FactValue
Form propsname, required, value
Hidden input-
Field integrationYes
Component Relationship
Input Direct primitive

Changelog

View version history v1.0.0 3 releases

v1.0.0

  • Promoted this Primitive's vendoring version to the stable 1.0.0 baseline. Its existing API and Runtime behavior carry forward from the previous release.

v0.1.1

  • Marked generated React Primitive files as client modules so vendored installs preserve client boundaries in React server frameworks.

v0.1.0

  • Introduced value synchronization and Runtime state while preserving native input attributes and events.