Skip to main content

Starwind UI v3.0 beta is now available! Read the migration guide

Input Primitive

Input is a Starwind Runtime primitive in the form-value-control contract family.

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
defaultValue InputValue -
Description
Sets the initial Input value for uncontrolled usage.
Kind
control
Targets
-
Full type
InputValue
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

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
State control support
React supports controlled and default state with value and defaultValue props. Runtime/HTML emits starwind:value-change and updates with setValue. Astro adapters render initial/default state, but do not expose reactive controlled-state props for this state.

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