Veil UI
Components

Input

A single-line text field with validation, file and disabled states.

Installation

$ npx veil-ui@latest add input

Usage

import { Input } from "@/components/ui/input";

<Input type="email" placeholder="you@example.com" />;

Always pair an input with a <label> or an aria-label. Placeholder text is not a label.

Examples

Basic

With label and description

We will only use this for account notifications.

Invalid state

Enter a valid email address.

Set aria-invalid and connect the error message with aria-describedby. The border and ring switch to the destructive token automatically.

Disabled

File input

API reference

PropTypeDefaultDescription
typestring"text"Any native input type, including file and search.
aria-invalidboolean—Switches the border and ring to the destructive token.
...propsReact.ComponentProps<"input">—All native input attributes, including disabled and placeholder.

Accessibility

  • The component adds no aria-* attributes of its own; supply a label and description from the surrounding markup.
  • The focus ring is a 3px ring with a border color change, visible on both surfaces.
  • Invalid inputs must also render a text message — color alone is not enough.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add input --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { computed } from "vue";

import { cn } from "@/lib/utils";

const props = withDefaults(
  defineProps<{
    class?: string;
    type?: string;
    modelValue?: string | number;
  }>(),
  { type: "text" },
);

const emit = defineEmits<{ "update:modelValue": [value: string] }>();

const value = computed(() => props.modelValue ?? "");
</script>

<template>
  <input
    :value="value"
    :type="type"
    data-slot="input"
    :class="
      cn(
        'h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none transition-[color,box-shadow,border-color]',
        'placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground',
        'file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground',
        'focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50',
        'aria-invalid:border-destructive aria-invalid:ring-destructive/20',
        'disabled:cursor-not-allowed disabled:opacity-50',
        'dark:bg-input/30',
        props.class,
      )
    "
    @input="emit('update:modelValue', ($event.target as HTMLInputElement).value)"
  />
</template>

On this page