ReferenceField
Follows a foreign key to another resource and renders a related field.
Installation
pnpm dlx shadcn@latest add @chelone/reference-fieldFollows a foreign key to another resource and renders a related field.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Child field(s) rendered against the referenced record. |
| className | string | — | A class name applied to the link wrapper. |
| empty | ReactNode | — | Rendered when the FK is null/undefined or its record is missing. A string is translated. |
| error | ReactNode | — | Rendered when the reference lookup errors. |
| link | LinkToType | — | A `CreatePathType` (`"show"`/`"edit"`/…) or `false` to disable linking. |
| loading | ReactNode | — | Rendered while the referenced record is loading. |
| record | RecordType | — | The record to read the FK off. Defaults to the ambient record. |
| reference | string | — | The referenced resource the FK points at (e.g. `"authors"`). |
| render | (referenceRecord: UnknownRecord | undefined) => ReactNode | — | Render-prop alternative to `children`: receives the resolved referenced record. Called only after the reference resolves; loading, error and empty states use their respective props. |
| source | string | — | The FK field on the current record (e.g. `"author_id"`). |