Skip to main content
Version: 2.0.0

Select fields

Simple select field​

Field

You can use a simple select field when you would like allow the selection of a single value among a limited set of options. Each entry will have a key and a label. You can also customise the color of each entry or disable certain options.

Set the enumValues prop to a valid configuration in a string property. You can define those values as an array of EnumValueConfig or simply as an object with key/value pairs:

import { buildProperty } from "firecms";

buildProperty({
dataType: "string",
name: "Category",
enumValues: {
art_design_books: "Art and design books",
backpacks: "Backpacks and bags",
bath: "Bath",
bicycle: "Bicycle",
books: "Books"
}
});

or

import { buildProperty } from "firecms";

buildProperty({
dataType: "string",
name: "Currency",
enumValues: [
{ id: "EUR", label: "Euros", color: "blueDark" },
{ id: "DOL", label: "Dollars", color: "greenLight" }
]
});

The data type is string or number.

Internally the component used is SelectFieldBinding.

Multiple select field​

Field

You can use a multiple select field when you would like allow the selection of a zero or more values among a limited set of options. Each entry will have a key and a label. You can also customise the color of each entry or disable certain options.

Set the enumValues prop to a valid configuration in a string property. You can define those values as an array of EnumValueConfig or simply as an object with key/value pairs:

import { buildProperty } from "firecms";

buildProperty({
name: "Available locales",
dataType: "array",
of: {
dataType: "string",
enumValues: {
"es": "Spanish",
"en": "English",
"fr": {
id: "fr",
label: "French",
disabled: true
}
}
},
defaultValue: ["es"]
});

The data type is array with either string or number properties as the of prop, using enum values.

Internally the component used is SelectFieldBinding.

Customising the colors​

You can pick the colors among a list of predefined values:

/**
* @category Models
*/
export type ChipColorScheme = {
color: string;
text: string;
}

/**
* @category Models
*/
export type ChipColorKey =
| "blueLighter"
| "cyanLighter"
| "tealLighter"
| "greenLighter"
| "yellowLighter"
| "orangeLighter"
| "redLighter"
| "pinkLighter"
| "purpleLighter"
| "grayLighter"

| "blueLight"
| "cyanLight"
| "tealLight"
| "greenLight"
| "yellowLight"
| "orangeLight"
| "redLight"
| "pinkLight"
| "purpleLight"
| "grayLight"

| "blueDark"
| "cyanDark"
| "tealDark"
| "greenDark"
| "yellowDark"
| "orangeDark"
| "redDark"
| "pinkDark"
| "purpleDark"
| "grayDark"

| "blueDarker"
| "cyanDarker"
| "tealDarker"
| "greenDarker"
| "yellowDarker"
| "orangeDarker"
| "redDarker"
| "pinkDarker"
| "purpleDarker"
| "grayDarker";

And you can also define custom colors using the HTML syntax #AAAAAA:

import { buildProperty } from "firecms";

buildProperty({
dataType: "string",
name: "Currency",
enumValues: [
{ id: "EUR", label: "Euros", color: "blueDark" },
{
id: "DOL",
label: "Dollars",
color: {
color: "#FFFFFF",
text: "#333333",
}
}
]
});

Enterprise or start-up?

Learn how to get the most out of your project with the help of our consulting team.
Learn more
Sign up to our newsletter to get the latest news and updates. No spam!