Vitral 0.2
Form

IconField

An icon inside a field, at the start or the end, with the text padded past it.

Import

main.ts
import { IconField } from '@vitral/vue';

Start and end

<script setup lang="ts">import { IconField, InputIcon, InputText, Label, StackPanel } from '@vitral/vue';import { ref } from 'vue'; const query = ref('');const email = ref('');</script> <template>    <StackPanel orientation="horizontal" spacing="0.75rem" align="start" wrap>        <StackPanel spacing="0.375rem" style="min-width: 16rem">            <Label for="if-search">Search</Label>            <IconField>                <InputIcon icon="search" />                <InputText id="if-search" v-model="query" placeholder="Search" />            </IconField>        </StackPanel>        <StackPanel spacing="0.375rem" style="min-width: 16rem">            <Label for="if-email">Email</Label>            <IconField>                <InputText id="if-email" v-model="email" type="email" />                <InputIcon icon="user" />            </IconField>        </StackPanel>    </StackPanel></template>

Both, with a meaningful icon

<script setup lang="ts">import { IconField, InputIcon, InputText, Label, StackPanel } from '@vitral/vue';</script> <template>    <StackPanel spacing="0.375rem" style="min-width: 16rem">        <Label for="if-both">Username</Label>        <IconField fluid>            <InputIcon icon="user" />            <InputText id="if-both" invalid />            <InputIcon icon="warning" label="Invalid" style="color: var(--vt-danger-color)" />        </IconField>    </StackPanel></template>

Other fields

<script setup lang="ts">import { IconField, InputIcon, InputNumber, InputPassword } from '@vitral/vue';import { ref } from 'vue'; const amount = ref<number | null>(120);</script> <template>    <IconField>        <InputIcon icon="calendar" />        <InputNumber v-model="amount" aria-label="Days" />    </IconField>    <IconField>        <InputIcon icon="spinner" spin />        <InputPassword aria-label="Password" :feedback="false" />    </IconField></template>

API

Read from packages/vue/src/components/IconField/types.ts, so it says what the component actually accepts.

Props

NameTypeDescription
fluidbooleanTake the full width of the container.

Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.

Slots

NameSlot propsDescription
default—An `<InputIcon>` before the field puts the icon at the start; after it, at the end.