Skip to content

Field

The s-field component is a versatile input field component from the masc-vue component library. It allows you to create various types of input fields, including text, textarea, boolean, checkbox, select, radio, date, and search fields. This component is designed to be highly customizable and is intended for use in forms and data input scenarios.

Registration

You can register s-field globally or locally in your component.

ts
import { SField } from "masc-vue";
import { SField } from "masc-vue";

Usage

To use the s-field component in your Vue application, you can include it in your template as follows:

vue
<template>
	<s-field v-model="yourModelValue" type="select" label="Field Label" required :options="yourOptions" size="sm" />
</template>
<template>
	<s-field v-model="yourModelValue" type="select" label="Field Label" required :options="yourOptions" size="sm" />
</template>

Props

PropTypeDefaultDescription
modelValueString, Number, Boolean, Array, Object""The data model value for the field.
typeString'text'The type of field. Valid options: 'text', 'textarea', 'boolean', 'checkbox', 'select', 'radio', 'date', 'search'.
labelString""The label for the field.
propString""The prop associated with the field.
labelClassString""Custom class for the label element.
horizontalBooleanfalseDisplay the field horizontally.
helpString""Help text to display below the field.
requiredBooleanfalseIndicates if the field is required.
readonlyBooleanfalseIndicates if the field is read-only.
disabledBooleanfalseIndicates if the field is disabled.
optionsArray[]An array of options (for select, checkbox, radio fields).
sizeString (xs, sm, lg)""The size of the field.
patternString""The pattern for input validation.
patternMessageString""Error message to display if the pattern validation fails.
validatorFunctionnullCustom validation function.

Slots

The s-field component supports a default slot for custom content. This is particularly useful when using the type prop as 'radio'.

This documentation provides you with an overview of the s-field component's usage, props, and slots, enabling you to create dynamic and customizable input fields for your Vue application.

Released under the MIT License.