Skip to main content

Starwind UI v3.0 is now available! Migration guide

Installation

Usage

---
import { Input } from "@/components/starwind/input";
---
<Input placeholder="Type something..." />

Sizes

Disabled

Input Types

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Input

Inherits input attributes. Omits `children`, `defaultValue`, `size`, and `value`.

Contains the following additional props:

Prop Type Default Toggle details
defaultValue string | number | string[] —
Description
Sets the initial value when the component is uncontrolled.
Classification
Primitive override
Type imports
React import type { InputValue } from "@starwind-ui/react";
Primitive prop
input.Root.defaultValue
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant
value string | number | string[] —
Description
Controls or identifies the component value.
Classification
Primitive override
Type imports
React import type { InputValue } from "@starwind-ui/react";
Primitive prop
input.Root.value

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Input.

Primitive API

Runtime API

Input primitive
createInput from @starwind-ui/runtime/input

Changelog

View version history v2.1.0 10 releases

v2.1.0

  • In Svelte, a defined value that you pass when Input mounts now stays under your control, as in React and Vue. To change it, use bind: or update your state in the change callback. A form reset keeps it. If you pass undefined at mount, Input keeps its own state. Input also follows push() and splice() on a $state array.
  • Fixed Input writing an unchanged value back into the field. In some browsers this moved the caret or ended an IME composition.
  • Vue Input now keeps the caret during a normal edit, puts the old text back when the parent refuses a change, and follows a v-model that starts as undefined.

v2.0.2

  • Kept the input working when its elements are replaced or it moves to another form.

v2.0.1

  • In React, you can cancel a change before it applies. The component then keeps its previous state, and it shows only the changes that apply.

v2.0.0

  • Input now gets its behavior from Starwind Runtime. Runtime keeps the value up to date. Native input attributes still work.
  • See the Input Primitive for the unstyled parts and the behavior API.

v1.3.3

  • The Tailwind variants now live in their own variants.ts file in the component folder.

v1.3.1

  • add aria-invalid styling

v1.3.0

  • style and focus state updates

v1.2.0

  • Add data-slot attribute to enable global styling updates

v1.1.1

  • Add eslint disable comment for allowing the label to not have an associated control (this is user responsibility)
  • Adjust component to use type VariantProps from tailwind-variants. This provides greater type safety and cleans up component frontmatter.

v1.1.0

  • tailwind-variants now implemented. This uses tailwind-merge under the hood to merge Tailwind classes without style conflicts, allowing you to override any existing classes using the “class” prop.