TextArrayField

Renders an array of scalar values as a horizontal list of shadcn <Badge> components. Useful for tags, genres, or similar short string arrays.

Installation

pnpm dlx shadcn@latest add @shadmin/text-array-field

Usage

import { TextArrayField } from "@/components/admin";
 
// record: { id: 123, genres: ['Fiction', 'Historical Fiction'] }
<TextArrayField source="genres" />;

Props

PropRequiredTypeDefaultDescription
sourceRequiredstring-Field name
recordOptionalobjectRecord from contextExplicit record
defaultValueOptionalany-Fallback value
emptyOptionalReactNode-Placeholder when value is missing or the array is empty
variantOptional"default" | "outline" | "secondary" | "destructive""outline"Badge style
classNameOptionalstring-Additional CSS classes

Remaining props are forwarded to the wrapping <div>.

source

Name of the array field on the record. Each item is rendered inside its own <Badge>.

<TextArrayField source="tags" />

empty

Rendered when the value is missing or the array is empty. Strings are passed through the translator.

<TextArrayField source="tags" empty="No tags" />

variant

Switches the visual style of the badges. Defaults to "outline".

<TextArrayField source="tags" variant="secondary" />