FieldDef
| Generic types: | TProps |
Base interface for all dynamic form field definitions.
This interface defines the common properties that all field types must implement. Field-specific properties are defined through the generic TProps parameter, providing type safety for field-specific configuration.
Properties
| Name | Type | Description |
|---|---|---|
| className | string | undefined | Additional CSS classes for custom styling. Space-separated string of CSS class names that will be applied to the field container for custom styling. |
Example usage | ||
| col | number | undefined | Column sizing configuration for responsive grid layout. Specifies how many columns this field should span in a 12-column grid system. Supports responsive behavior and field arrangement. |
Example usage | ||
| disabled | boolean | undefined | Whether the field is disabled and cannot be interacted with. When true, the field is rendered in a disabled state and cannot receive user input. The value can still be modified programmatically. @value false |
| key | string | Unique field identifier used for form binding and value tracking. This key is used to associate the field with form values and must be unique within the form. It follows object property naming conventions. |
Example usage | ||
| label | | Human-readable field label displayed to users. Provides accessible labeling for form fields and is typically displayed above or beside the field input. Supports static strings, translation keys, Observables, and Signals for dynamic content. |
Example usage | ||
| props | TProps | undefined | Field-specific properties and configuration options. Contains type-specific configuration that varies based on the field type. The shape is defined by the TProps generic parameter. |
Example usage | ||
| readonly | boolean | undefined | Whether the field is read-only. When true, the field displays its value but cannot be modified by user interaction. Differs from disabled in styling and accessibility. @value false |
| tabIndex | number | undefined | Tab index for keyboard navigation. Controls the order in which fields receive focus when navigating with the Tab key. Follows standard HTML tabindex behavior. |
Example usage | ||
| type | string | Field type identifier for component selection. Determines which component will be rendered for this field. Must match a registered field type name in the field registry. |
Example usage | ||
Example usage
// Basic text input field
const textField: FieldDef <{ placeholder: string }> = {
key: 'email',
type: 'input',
label: 'Email Address',
props: { placeholder: 'Enter your email' },
col: 12
};// Complex field with conditional logic
const conditionalField: FieldDef <SelectProps> = {
key: 'country',
type: 'select',
label: 'Country',
props: {
options: [
{ label: 'United States', value: 'us' },
{ label: 'Canada', value: 'ca' }
]
},
hidden: false,
disabled: false,
col: 6
};