Using Grommet for HPE?See SelectMultiple examples and guidance.
Custom label to be used by screen readers. When provided, an aria-label will be added to the element.
string"a user friendly label for screen readers"
How to align along the cross axis when contained in a Box or along the column axis when contained in a Grid.
string"start"
"center"
"end"
"stretch"
"baseline"
Function that will be called when each option is rendered.
functionThe function will be passed (option, index, options, state) where option is the option to render, index is the index of that option in the options array, and state is an object with (active, disabled, selected) keys indicating the current state of the option.
(option, index, options, { active, disabled, selected }) => {}Initially selected value.
arrayAn array of strings, objects, or numbers.
["string", ...]
[{...}, {...}][1, 2]
Whether the entire select or individual options should be disabled.
booleantrue
false
arrayAn array of strings, objects, or numbers. An array of numbers indicates the indexes into 'options' of the disabled options. An array of strings or objects work the same way as the 'value' to indicate which options are disabled.
["string", ...]
[{...}, {...}][1, 2]
When the options array contains objects, this property indicates how to determine which options should be disabled.
stringIf a string is provided, it is used as the key for each item object and if that key returns truthy, the option is disabled.
"key"
functionIf a function is provided, it is called with the option and the return value determines if the option is disabled.
() => {}How to align the drop.
object
{
top: "top" | "bottom",
bottom: "top" | "bottom",
right: "left" | "right",
left: "left" | "right"
}
{ top: "bottom", left: "left" }Target where the options drop will be aligned to. This should be a React reference. Typically, this is not required as the drop will be aligned to the SelectMultiple itself by default.
objectref.current
Empty option message to display when no matching results were found
string"No matches found"
node<Text> No results found. <Text/>
Optional help text to display above the options in the drop.
stringhelp text
node<Box background='gray'> help text </Box>
A custom icon to be used when rendering the select. You can use false to not render an icon at all.
booleantrue
false
function() => {}node<Icon />
When the options array contains objects, this property indicates how to retrieve the label for each option. The label is what is displayed to the user in the options list drop down and for the selected option itself.
stringIf a string is provided, it is used as the key to retrieve a property of an option object, which should be a string.
"key"
functionIf a function is provided, it is called with the option and should return a string or a React node.
() => {}The amount of margin around the component.
string"none"
"xxsmall"
"xsmall"
"small"
"medium"
"large"
"xlarge"
objectCan be specified to distinguish horizontal margin, vertical margin, and margin on a particular side.
{
vertical: "...",
horizontal: "...",
top: "...",
bottom: "...",
left: "...",
right: "..."
}
Custom messages.
To affect all SelectMultiple instances, use messages prop on Grommet.
object{ multiple: "string" }Function that will be called when the user selects an option.
function({ value, option }) => {...}Use this to indicate that 'options' doesn't contain all that it could.
functionThe function will be called when the entire list of items has been rendered. This might be used when the total number of items that could be retrieved is more than you'd want to load into the browser. 'onMore' allows you to lazily fetch more from the server only when needed. When 'onMore' is defined the 'Select All' button is removed from the SelectMultiple.
() => {}Function that will be called when the user types in the search input. If this property is not provided, no search field will be rendered. If the 'onMore' prop is being used and the 'options' prop doesn't reflect all the potential options, the 'onSearch' function supports modifying the 'options' based on a search term.
function() => {}The options to choose from.
There are a number of ways to set and change the options based on the 'onChange', 'onSelect', and 'onSearch' functions. As a general rule of guidance when using 'onSearch', define an original list of options that is separate from the currently stored options. Use this definition to reset options in functions.
For examples of defining, setting, and changing options, see our Storybook examples with Select.
array[string]["option1", "option2"]
array[number][1, 2]
array[boolean][true, false]
array[element][<Element />, <Element />]
array[object]If an object is used, use children callback in order to render anything based on the current item.
[{}, {}]Whether to replace previously rendered items with a generic spacing element when they have scrolled out of view. This is more performant but means that in-page searching will not find elements that have been replaced.
booleantrue
false
Placeholder text to use in the search box when the search input is empty.
string"search..."
node<Text>Enter search term</Text>
Whether selections should be displayed at the input level of the component.
booleantrue
false
Whether selections should be sorted with selected items displayed at the top of the list after closing and reopening the drop. Note: code that relies on indexes of the options shouldn't be used when sortSelectedOnClose is true.
booleantrue
false
The currently selected value. When 'valueKey' sets 'reduce', the value(s) here should match what the 'valueKey' would return for the corresponding selected option object. Otherwise, the value should be one or more of the options from the options array.
array[string]["option1", "option2"]
array[number][1, 2]
array[object][{}, {}]When the options array contains objects, this property indicates how to retrieve the value of each option.
stringIf a string is provided, it is used as the key to retrieve a property of an option object.
"key"
objectIf reduce is true, this value will be used for the 'value' delivered via 'onChange'.
{
key: "string",
reduce: boolean
}
functionIf a function is provided, it is called with the option and should return the value.
(option) => {}The background style when hovering.
string"active"
object{ color: "active", opacity: "medium" }The text color when hovering.
stringA hex, name, or rgb value.
"black"
objectAn object with a color for dark and light modes.
{ dark: "white", light: "black" }The maximum number of items to display at the input level when showSelectedInline is true.
number5
Any valid Box prop for the options container.
object{ align: "start", pad: "small" }Any valid Text prop for text used inside the options container.
object{ margin: "none" }Any additional style for the container of the Select component.
stringAny CSS.
css`color: 'blue'`
function(props) => {}Any additional style for the container surrounding the options of the Select component.
stringAny CSS.
css`color: 'blue'`
function(props) => {}Any valid Box prop for the clear button container.
object{ pad: "small", background: "light-2" }Any valid Box prop to adjust the button container style when the clear button is hovered.
object {} Any valid Text prop for text used inside the clear button container.
object{ color: "dark-3" }Any additional style for the Select DropButton when using the controlled open state.
string"CSS"
object{}Any additional style for the control of the Select component.
stringAny CSS.
css`color: 'blue'`
function(props) => {}Any valid Box props for the emptySearchMessage container.
object{ pad: "small"}Any valid Text props for the emptySearchMessage text.
object{ color: "text" }The margin used for Select icons.
string"none"
"xxsmall"
"xsmall"
"small"
"medium"
"large"
"xlarge"
objectCan be specified to distinguish horizontal margin, vertical margin, and margin on a particular side.
{
vertical: "...",
horizontal: "...",
top: "...",
bottom: "...",
left: "...",
right: "..."
}
The color used for Select icons.
stringA hex, name, or rgb value.
"brand"
objectAn object with a color for dark and light modes.
{ dark: "string", light: "string" }