Skip to content

Form Field

An enterprise-grade form field component based on BrConfigProvider for global theme configuration. It supports multi-control integration, state linkage, and customizable layouts, making it seamless to integrate with inline forms like BrForm and BrTable.

Component Features

  • 🎨 Theme Configuration: Inherits global theme settings (colors, rounded corners, sizes) via BrConfigProvider.
  • 🔄 State Linkage: Automatically links label, border, and message colors based on the field's state (e.g., error, success).
  • 📐 Flexible Layout: Supports positioning labels on the top, left, or right, along with customizable label widths.
  • 🛠️ Customization: Easy to override default styles using TailwindCSS or custom class names.

Basic Usage

Displays a basic form field containing a label, control, and description.

This is your public display name.

Example

Error State

Shows the coordinated color change effect of the label, border, and hint text when validation fails.

Please enter a valid email address.
Example

Custom Layout

Supports displaying the label on the left or right side, and customizing the label width.

Receive updates via email.

Example

State Linkage

Demonstrates disabled, readonly, and loading states. The label and description will automatically adjust their styles to match the state.

This field and its label are disabled.

This field cannot be modified.

Verifying availability...

Example

API Reference

BrFormField

PropTypeDefaultDescription
namestring-Field name, used for validation binding
labelstring-Label text
descriptionstring-Description message
errorstring-Error message. Setting this will automatically enter the error state
state'default' | 'error' | 'success' | 'warning''default'Custom state
disabledbooleanfalseWhether the field is disabled
readonlybooleanfalseWhether the field is readonly
requiredbooleanfalseWhether the field is required (shows an asterisk)
hideRequiredAsteriskbooleanfalseWhether to hide the required asterisk
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl''md'Field size, inherited from ConfigProvider
labelPosition'top' | 'left' | 'right''top'Label position
labelWidthstring | number-Label width (only effective when position is left or right)
loadingbooleanfalseWhether to show a loading placeholder
isolatedbooleanfalseEnable Shadow DOM for style isolation
zIndexnumber-Layer index, automatically assigned by FormFieldManager by default

BrFormFieldLabel / BrFormFieldDescription / BrFormFieldMessage

Common attributes: Supports passing class for style overriding, and automatically injects state from formFieldContext.

FormFieldManager (Utility)

A singleton utility for managing global form field layering.

ts
import { formFieldManager } from '@breeze-ui/vue/form-field'

// Get the next auto-incremented z-index
const zIndex = formFieldManager.nextZIndex()

// Reset the z-index base
formFieldManager.resetZIndex()