Skip to main content

ChoicesInput

Collects one value of an enum from a dropdown, with an optional icon per option.

Use it for a fixed set of values that comes with the schema. To pick a record of another resource use SchemaReferenceInput, which loads its options from the backend.

Example​

const statusChoices = [
{value: 'draft', label: 'Draft', color: 'default'},
{value: 'published', label: 'Published', color: 'success'},
{value: 'archived', label: 'Archived', color: 'error'},
];

<ChoicesInput source="status" choices={statusChoices} />

Props​

On top of choices the component accepts the shared input props and React Admin's SelectInput props.

NameTypeDefaultDescription
source (required)string—Name of the field in the form record
choices (required)Choices—Enum values: {value, label, color?, icon?}
labelstring | ReactElement | falselabel from the schemafalse hides the label
validateValidator | Validator[]from the schemaReact Admin validators
iconsKeystring—Key into the iconsMap on SchemaAdmin, used to give each option an icon

The schema layer renders this component directly: choices comes from the field's enum and iconsKey from options.choices.iconsKey.

caution

Unlike ChoicesField, the input ignores the color of an enum entry — the dropdown shows an icon and a label, not a colored chip.

An array of enum values renders as a multi-select instead — see SchemaArrayInput.

Schema mapping​

A field with format: "choices" and an enum:

{"name": "status", "type": "string", "format": "choices",
"enum": [{"value": "draft", "label": "Draft"}, {"value": "published", "label": "Published"}]}
class ProductStatus(models.TextChoices):
DRAFT = "draft", _("Draft")
PUBLISHED = "published", _("Published")
ARCHIVED = "archived", _("Archived")


class Product(models.Model):
status = models.CharField(max_length=16, choices=ProductStatus.choices, default=ProductStatus.DRAFT)

See also​