Field
VField places a label, a hint and an error message around any control. Its slot provides fieldProps to bind on the control.
Usage
vue
We send the receipt to this address.
Examples
Native control
Native elements and third-party components take the same fieldProps as library controls.
vue
Error
error shows a message in place of the hint, so the field does not grow, and marks the control invalid. The message is announced when it appears. required adds an asterisk and passes required to the control.
vue
Leave the field to check it.
Label beside the control
labelPosition="start" places the label in its own column. In a narrow field, the label moves back above the control.
vue
Hidden label
hideLabel hides the label visually. It still names the control for screen readers.
vue
API
Props
| Prop | Type | Default |
|---|---|---|
label | string | none |
Label linked to the control through for. | ||
hint | string | none |
Help text below the control, linked through aria-describedby. | ||
error | string | none |
Error message shown in place of the hint. Sets aria-invalid, is linked through aria-describedby and is announced when it appears. | ||
required | boolean | false |
Adds an asterisk after the label and passes required to the control. | ||
hideLabel | boolean | false |
| Hides the label visually while keeping it as the accessible name. | ||
labelPosition | FieldLabelPosition'top' | 'start' | 'top' |
| Places the label above the control or beside it. | ||
Slots
| Slot | Type |
|---|---|
default | { fieldProps: FieldControlProps; } |
The control. Bind fieldProps: id, descriptions, invalid state, required and the attributes set on the field other than class and style. | |
Types
Types used in the API tables. Import exported types from vectis-ui.
export type FieldControlProps = {
id: string
'aria-describedby'?: string
'aria-invalid'?: 'true'
required?: true
} & Record<string, unknown>CSS variables
| Token | Value |
|---|---|
--vectis-control-size-field-label | 10rem |
--vectis-control-size-field-control-min | 16rem |