Skip to main content

error

Description

Optional. Defines whether error styling is applied to a select

Usage

error?: boolean;

Parameters

  • true - error styling is applied to a select
  • false - (default) error styling is not applied to a select

Example

<script setup>
const dataset = [
{id: 1, label: "First option"},
{id: 2, label: "Second option"},
{id: 3, label: "Third option"}
]
</script>

<template>
<Select :options="dataset" :value="1" :error="true"/>
</template>

Details

The property is useful during a form validation. If the property is set to true a select gets error styling: the input's borders and the selected option's value become red.

To add a red error label for the control, use the error property of the Field control:

<script setup>
import { Select, Field } from "@svar-ui/vue-core";
</script>

<template>
<Field label="Error message" :error="true">
<Select :error="true"/>
</Field>
</template>

Related article: Styling an option validation error

Related sample: Select