Input
---import { Input } from "@/components/starwind/input";---
<Input placeholder="Type something..." />import { Input } from "@/components/starwind/input";
export function Example() { return ( <Input placeholder="Type something..." /> );}<script setup lang="ts">import { Input } from "@/components/starwind/input";</script>
<template> <Input placeholder="Type something..." /></template><script lang="ts"> import { Input } from "@/components/starwind/input";</script>
<div class="w-[400px] max-w-full"> <Input aria-label="Example input" placeholder="Type something..." /></div>Installation
pnpx starwind@latest add input --framework astronpx starwind@latest add input --framework astroyarn dlx starwind@latest add input --framework astropnpx starwind@latest add input --framework reactnpx starwind@latest add input --framework reactyarn dlx starwind@latest add input --framework reactpnpx starwind@latest add input --framework vuenpx starwind@latest add input --framework vueyarn dlx starwind@latest add input --framework vuepnpx starwind@latest add input --framework sveltenpx starwind@latest add input --framework svelteyarn dlx starwind@latest add input --framework svelteUsage
---import { Input } from "@/components/starwind/input";---
<Input placeholder="Type something..." />import { Input } from "@/components/starwind/input";
export function Example() { return ( <Input placeholder="Type something..." /> );}<script setup lang="ts">import { Input } from "@/components/starwind/input";</script>
<template> <Input placeholder="Type something..." /></template><script lang="ts"> import { Input } from "@/components/starwind/input";</script>
<Input placeholder="Type something..." />Sizes
---import { Input } from "@/components/starwind/input";---
<Input size="sm" placeholder="Small input" /><Input size="md" placeholder="Medium input" /><Input size="lg" placeholder="Large input" />import { Input } from "@/components/starwind/input";
export function Example() { return ( <> <Input size="sm" placeholder="Small input" /> <Input size="md" placeholder="Medium input" /> <Input size="lg" placeholder="Large input" /> </> );}<script setup lang="ts">import { Input } from "@/components/starwind/input";</script>
<template> <Input size="sm" placeholder="Small input" /> <Input size="md" placeholder="Medium input" /> <Input size="lg" placeholder="Large input" /></template><script lang="ts"> import { Input } from "@/components/starwind/input";</script>
<Input size="sm" placeholder="Small input" /><Input size="md" placeholder="Medium input" /><Input size="lg" placeholder="Large input" />Disabled
---import { Input } from "@/components/starwind/input";---
<Input disabled placeholder="Disabled input" /><Input disabled value="Disabled with value" />import { Input } from "@/components/starwind/input";
export function Example() { return ( <> <Input disabled placeholder="Disabled input" /> <Input disabled value="Disabled with value" /> </> );}<script setup lang="ts">import { Input } from "@/components/starwind/input";</script>
<template> <Input disabled placeholder="Disabled input" /> <Input disabled default-value="Disabled with value" /></template><script lang="ts"> import { Input } from "@/components/starwind/input";</script>
<Input disabled placeholder="Disabled input" /><Input disabled defaultValue="Disabled with value" />Input Types
---import { Input } from "@/components/starwind/input";---
<Input type="email" placeholder="Email input" /><Input type="password" placeholder="Password input" /><Input type="number" placeholder="Number input" /><Input type="file" />import { Input } from "@/components/starwind/input";
export function Example() { return ( <> <Input type="email" placeholder="Email input" /> <Input type="password" placeholder="Password input" /> <Input type="number" placeholder="Number input" /> <Input type="file" /> </> );}<script setup lang="ts">import { Input } from "@/components/starwind/input";</script>
<template> <Input type="email" placeholder="Email input" /> <Input type="password" placeholder="Password input" /> <Input type="number" placeholder="Number input" /> <Input type="file" /></template><script lang="ts"> import { Input } from "@/components/starwind/input";</script>
<Input type="email" placeholder="Email input" /><Input type="password" placeholder="Password input" /><Input type="number" placeholder="Number input" /><Input type="file" />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
createInputfrom@starwind-ui/runtime/input
Changelog
View version history v2.1.0 10 releases
v2.1.0
- In Svelte, a defined
valuethat you pass when Input mounts now stays under your control, as in React and Vue. To change it, usebind:or update your state in the change callback. A form reset keeps it. If you passundefinedat mount, Input keeps its own state. Input also followspush()andsplice()on a$statearray. - 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-modelthat starts asundefined.
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.tsfile in the component folder.
v1.3.1
- add
aria-invalidstyling
v1.3.0
- style and focus state updates
v1.2.0
- Add
data-slotattribute 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
VariantPropsfromtailwind-variants. This provides greater type safety and cleans up component frontmatter.
v1.1.0
tailwind-variantsnow implemented. This usestailwind-mergeunder the hood to merge Tailwind classes without style conflicts, allowing you to override any existing classes using the “class” prop.