Skip to content

TextField

Displays the textual value of a field inside a <span>.

import { List, DataTable, TextField } from '@/components/admin';
export const UserList = () => (
<List>
<DataTable>
<DataTable.Col source="id" />
<DataTable.Col>
<TextField source="name" empty="resources.users.fields.name.empty" />
</DataTable.Col>
</DataTable>
</List>
);

If the value is null or undefined, it renders nothing unless you provide the empty prop. If empty is a string, it is passed to the translation function.

PropRequiredTypeDefaultDescription
sourceRequiredstring-Field name in the record
defaultValueOptionalany-Fallback when record has no value for source
emptyOptionalReactNode-Placeholder when value is null/undefined
recordOptionalobjectRecord from contextRecord to read (overrides context)

Remaining props are passed to the underlying <span> element (e.g., className).

  • <TextField> is the default child for <DataTable.Col>.
  • <TextField> is the default child for <RecordField>.
  • Non‑string values are converted with toString().
  • To format numbers or dates, prefer <NumberField> or <DateField>.