<BaseInput />
· A user input, an editable field.
<template>
<BaseInput
v-model="value"
rounded="md"
placeholder="Label"
/>
</template>
<script setup lang="ts">
const value = ref('')
</script>
This component is self closing and can be used to create an input field. You can customize the input's visual style by using the available props.
<template>
<BaseInput />
</template>
This component has props that you can use to modify its visual style and behavior.
Model | Type |
---|---|
model-value | string | number |
Prop | Type |
---|---|
id default: - | string The form input identifier. |
type default: "text" | string The type of input. |
placeholder default: - | string The placeholder to display for the input. |
variant default: "default" | "default" | "muted" The variant of the input. |
rounded default: "md" | "none" | "md" | "sm" | "lg" | "full" The radius of the input. |
size default: "md" | "md" | "sm" | "lg" | "xl" The size of the input. |
Your can override the component default CSS variables in your main.css
file.
@theme {
/* Default input variables */
--color-input-default-border: var(--color-muted-300);
--color-input-default-bg: var(--color-white);
--color-input-default-text: var(--color-muted-600);
--color-input-default-placeholder: var(--color-muted-300);
--color-input-default-button-bg: var(--color-muted-100);
--color-input-default-button-bg-active: var(--color-muted-200);
--color-input-default-button-text: var(--color-muted-700);
/* Muted input variables */
--color-input-muted-border: var(--color-muted-300);
--color-input-muted-bg: var(--color-muted-50);
--color-input-muted-text: var(--color-muted-600);
--color-input-muted-placeholder: var(--color-muted-300);
--color-input-muted-button-bg: var(--color-muted-200);
--color-input-muted-button-bg-active: var(--color-muted-300);
--color-input-muted-button-text: var(--color-muted-700);
}
Use the size
prop to change the size of the input.
<template>
<BaseInput
v-model="value"
size="md"
placeholder="Ex: username"
/>
</template>
<script setup lang="ts">
const value = ref('')
</script>
Use the variant
prop to change the contrast of the input.
<template>
<BaseInput
v-model="value"
variant="default"
rounded="md"
placeholder="Ex: username"
/>
<BaseInput
v-model="value"
variant="muted"
rounded="md"
placeholder="Ex: username"
/>
</template>
<script setup lang="ts">
const value = ref('')
</script>
Use the rounded
prop to change the border radius of the input.
<template>
<BaseInput
v-model="value"
rounded="full"
placeholder="Ex: username"
/>
</template>
<script setup lang="ts">
const value = ref('')
</script>
Use the aria-invalid="true"
attribute to display an error state.
<template>
<BaseInput
v-model="value"
variant="default"
rounded="md"
placeholder="Ex: username"
aria-invalid="true"
/>
<BaseInput
v-model="value"
variant="muted"
rounded="md"
placeholder="Ex: username"
aria-invalid="true"
/>
</template>
<script setup lang="ts">
const value = ref('')
</script>
Use the disabled
prop to set the input in a disabled state.
<template>
<BaseInput
v-model="value"
label="Username"
placeholder="Ex: username"
disabled
/>
</template>
<script setup lang="ts">
const value = ref('')
</script>