Skip to main content

ProField API

ProField is the foundational field component used by ProForm, ProTable, and ProDescriptions to render values based on their type.

ProFieldProps

text
React.ReactNode
The value to display or edit.
valueType
ProFieldValueType
default:"text"
Type of the value, determines how it’s rendered.
mode
'read' | 'edit' | 'update'
default:"read"
Display mode.
  • read - Display value (readonly)
  • edit - Show input for editing
  • update - Same as edit
readonly
boolean
default:"false"
Force readonly mode regardless of mode prop.
fieldProps
any
Props passed to the underlying input component.
placeholder
string | string[]
Placeholder text for inputs.
value
any
Current value (for controlled mode).
onChange
function
Callback when value changes.
(value: any) => void

Value Formatting

emptyText
React.ReactNode | false
default:"-"
Text to display when value is empty (only in read mode).Set to false to show nothing.
valueEnum
Record<string, any> | Map<string, any>
Enum mapping for select, radio, checkbox, and other selection components.
request
function
Load remote data for select/cascader/treeSelect fields.
(params?: any) => Promise<{ label: React.ReactNode; value: any; [key: string]: any }[]>
params
any
Parameters passed to the request function.
proFieldKey
React.Key
Unique key for the field (used for request caching).

Custom Rendering

render
function
Custom render function for read mode.
(text: any, props: ProFieldFCRenderProps, dom: React.ReactElement) => React.ReactNode
formItemRender
function
Custom render function for edit mode.
(text: any, props: ProFieldFCRenderProps, dom: React.ReactElement) => React.ReactNode

Field-Specific Props

Money Field

fieldProps.locale
string
default:"en-US"
Locale for currency formatting.
fieldProps.customSymbol
string
Custom currency symbol.
fieldProps.moneySymbol
boolean | string
default:"¥"
Currency symbol. Set to false to hide.

Percent Field

fieldProps.precision
number
default:"2"
Number of decimal places.
fieldProps.showSymbol
boolean
default:"true"
Whether to show the % symbol.

Progress Field

fieldProps.status
'success' | 'exception' | 'normal' | 'active'
Progress status.

Image Field

fieldProps.width
number
Image width.

Code Field

fieldProps.language
string
default:"javascript"
Code language for syntax highlighting.

Light Mode

light
boolean
default:"false"
Enable light mode (compact display for filters).
label
React.ReactNode
Field label (used in light mode).

Available Field Components

ProField exports individual field components that can be used directly:
  • FieldText - Text display and input
  • FieldTextArea - Multi-line text
  • FieldPassword - Password input
  • FieldDigit - Number input
  • FieldDigitRange - Number range
  • FieldMoney - Money with currency
  • FieldPercent - Percentage
  • FieldProgress - Progress bar
  • FieldRate - Star rating
  • FieldSlider - Slider
  • FieldSwitch - Toggle switch
  • FieldSelect - Select dropdown
  • FieldCheckbox - Checkbox
  • FieldRadio - Radio buttons
  • FieldSegmented - Segmented control
  • FieldCascader - Cascading select
  • FieldTreeSelect - Tree select
  • FieldDatePicker - Date picker
  • FieldTimePicker - Time picker
  • FieldRangePicker - Date range picker
  • FieldTimeRangePicker - Time range picker
  • FieldFromNow - Relative time
  • FieldSecond - Seconds formatter
  • FieldImage - Image display
  • FieldAvatar - Avatar
  • FieldCode - Code block
  • FieldColorPicker - Color picker
  • FieldStatus - Status badge
  • FieldOptions - Action options
  • FieldIndexColumn - Index column

Usage Examples

import { ProField } from '@ant-design/pro-components';

// Text
<ProField text="Hello World" valueType="text" mode="read" />

// Money
<ProField
  text={1000}
  valueType="money"
  mode="read"
  fieldProps={{ locale: 'en-US' }}
/>

// Date
<ProField
  text="2024-03-01"
  valueType="date"
  mode="read"
/>

// Progress
<ProField
  text={75}
  valueType="progress"
  mode="read"
/>

ProFieldEmptyText

Type for the empty text configuration:
type ProFieldEmptyText = string | false;
Set to a string to customize the empty text, or false to show nothing when the value is empty.

Build docs developers (and LLMs) love