Displays a form input field. Styled with theme tokens like the shadcn input, and fills the width of its container.
<script lang="ts">
import { Input } from "#lib/components/ui/input/index.js";
</script>
<Input type="email" placeholder="Email" />pnx remote0 add https://plainsv.com/r/input.jsonUse bind:value to read and write the value. Event handlers such as oninput and onchange also pass through to the element.
Value: empty
<script lang="ts">
import { Input } from "#lib/components/ui/input/index.js";
let email = $state("");
</script>
<Input type="email" placeholder="Email" bind:value={email} />
<p>Value: {email}</p>Set size to xs, sm, md, or lg. The default is md, the height matches the button of the same size, and the corner radius follows the size.
<Input size="xs" placeholder="Size xs" />
<Input size="sm" placeholder="Size sm" />
<Input size="md" placeholder="Size md" />
<Input size="lg" placeholder="Size lg" />Set type="file" to render a file picker, and use bind:files to read the selected files.
Selected: none
<script lang="ts">
import { Input } from "#lib/components/ui/input/index.js";
let files: FileList | null = $state(null);
</script>
<Input type="file" bind:files />Place an input next to a Button of the same size so their heights line up.
<script lang="ts">
import { Input } from "#lib/components/ui/input/index.js";
import { Button } from "#lib/components/ui/button/index.js";
</script>
<form>
<Input type="email" placeholder="Email" />
<Button type="submit" variant="outline">Subscribe</Button>
</form>Set rounded to xs through 4xl or pill to override the radius from the size.
<Input rounded="sm" placeholder="Rounded sm" />
<Input rounded="pill" placeholder="Rounded pill" />Set disabled to dim the input and block interaction. Set aria-invalid="true" to show the invalid ring, such as for a field that failed validation.
<Input placeholder="Disabled" disabled />
<Input placeholder="Invalid" aria-invalid="true" />The Input props extend the native input attributes, except the numeric size attribute, which is replaced by the shared size scale.
interface Props extends Omit<CompProps<"input">, "size" | "value" | "files"> {
/** Current value (bindable) */
value?: CompProps<"input">["value"];
/** Selected files when `type="file"` (bindable) */
files?: FileList | null;
/** Height, padding, and text size on the shared scale */
size?: UiSize;
/** Corner radius; follows `size` when omitted */
rounded?: UiRounded;
/** Classes merged onto the input */
class?: CompProps<"input">["class"];
}