Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Components / Forms

Input

A text field that keeps native input behavior and supports prefix and suffix slots.

Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.

Interactive showcase

Install

Run in your project
bunx --bun @getweini/cli@latest add input

Start with this example

Import the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.

Vue
<script setup lang="ts">
import { ref } from 'vue'
import Input from './components/ui/input/Input.vue'
import Label from './components/ui/label/Label.vue'

const email = ref('')
</script>

<template>
  <Label for="email">Email</Label>
  <Input id="email" v-model="email" type="email" required />
</template>

Use a visible label. Native attributes such as type, name, required, and autocomplete pass through.

When to use it

Account details

Collect an email address with native email validation and autocomplete.

Structured identifiers

Place a fixed prefix beside an editable workspace name without putting the prefix in its value.

More examples

Email address

Use native input attributes for validation and autofill.

Email address
<script setup lang="ts">
import { ref } from 'vue'
import Input from './components/ui/input/Input.vue'

const email = ref('')
</script>
<template>
  <label for="billing-email">Billing email</label>
  <Input
    id="billing-email"
    v-model="email"
    type="email"
    name="email"
    autocomplete="email"
    required
  />
</template>

Workspace URL

Keep the stored name separate from fixed context.

Workspace URL
<script setup lang="ts">
import { ref } from 'vue'
import Input from './components/ui/input/Input.vue'

const workspace = ref('')
</script>
<template>
  <label for="workspace">Workspace name</label>
  <Input id="workspace" v-model="workspace" name="workspace">
    <template #prefix>weini.app/</template>
  </Input>
</template>

Complete API

Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.

Input

Complete API for Input
NameType or signatureDefaultWhat it does
rootClasspropClassValueNot setClasses applied to the outer component wrapper.
rootStylepropStyleValueNot setStyles applied to the outer component wrapper.
sizepropControlSize | undefined"md"Choose the visual size. Medium is the usual default where available.
invalidpropboolean | undefinedNot setShow the invalid state; also provide a visible error message.
modelValuemodelstring | number | undefinedNot setCurrent value. Use v-model to keep it in sync with your page.
modelModifierspropPartial<Record<"number" | "trim" | "lazy", true>> | undefinedNot setControls the model modifiers behavior of Input.
update:modelValueevent[value: string | number | undefined]—Requests a new model value from the parent.
prefixslot(() => unknown) | undefinedOptionalContent shown before the main label or value.
suffixslot(() => unknown) | undefinedOptionalContent shown after the main label or value.
errorslot((props: { message: string; messages: string[]; }) => unknown) | undefinedOptionalContent for the error area of Input.
elementexposedHTMLInputElement | null—Reference to the underlying HTML element.
focusexposed() => void | undefined—Move keyboard focus to this control.
Public type definitions
Public types
// packages/frameworks/vue/components/input/types.ts
// ------- IMPORTS -------

import type { ControlSize } from '@getweini/vue/types'
import type { HTMLAttributes } from 'vue'

// ------- TYPES -------

export interface InputProps {
  rootClass?: HTMLAttributes['class']
  rootStyle?: HTMLAttributes['style']
  size?: ControlSize
  invalid?: boolean
}


// packages/frameworks/vue/dist/types/index.d.ts
export type { ButtonOptions, ButtonProps } from './button';
export type ControlSize = 'sm' | 'md' | 'lg';
export interface SelectOption<T = unknown> {
    label: string;
    value: T;
    disabled?: boolean;
}
/** Application-owned copy. Bind translated strings reactively when the locale changes. */
export interface ListboxMessages {
    /** Popup name when no aria-label or aria-labelledby is supplied. */
    listboxLabel: string;
    empty: string;
    clearSelection: string;
}
export interface ListboxProps<T> {
    options: readonly SelectOption<T>[];
    messages: ListboxMessages;
    id?: string;
    disabled?: boolean;
    required?: boolean;
    invalid?: boolean;
    name?: string;
    form?: string;
    placeholder?: string;
    size?: ControlSize;
    clearable?: boolean;
    gap?: number;
    /** Supply stable equality for object values. Values must be unique. */
    by?: (a: T, b: T) => boolean;
    /** Required for meaningful form submission of object values. */
    serialize?: (value: T) => string;
}


// packages/frameworks/vue/dist/types/button.d.ts
import type { Component } from 'vue';
/** Options shared by button implementations across frameworks. */
export interface ButtonOptions<Variant extends string = string, Size extends string = string> {
    variant?: Variant;
    size?: Size;
    disabled?: boolean;
    loading?: boolean;
    type?: 'button' | 'submit' | 'reset';
}
/** Vue-specific target options extend the reusable button contract. */
export interface ButtonProps<Variant extends string = 'default' | 'secondary' | 'outline' | 'ghost' | 'destructive', Size extends string = 'sm' | 'md' | 'lg'> extends ButtonOptions<Variant, Size> {
    as?: 'button' | 'a' | Component;
    asChild?: boolean;
}

Implementation notes

  • rootClass and rootStyle style the visible wrapper; native attributes belong to the input.
  • The model supports .trim, .number and .lazy modifiers.
  • The prefix and suffix are presentation; neither becomes part of the submitted input value.
  • Set width on a surrounding layout. Native attributes such as pattern, name, and autocomplete reach the input.

Accessibility and localization

  • Associate a visible label and connect validation text with aria-describedby. Do not rely on an adornment as the only accessible unit or name.

Source contract and editing guidance