Select
Import
import { Select } from '@resultadosdigitais/tangram-components'
Properties
children
defaultValue
Type | any |
---|
Description
Sets the value. Used for Uncontrolled component. Initial value of the selected option, or an array of initial values in case of multiple selection.
value
Type | any |
---|
Description
Used for Controlled component.
Value of the selected option, or an array of values in case of multiple selection.
The input value. Set to an empty string (''
) if you don't want any of the available options to be selected.
If is multiple the value need to be an array ([]
).
multiple
Type | bool |
---|---|
Default | false |
Description
Sets multiple selection.
If is multiple the value
or defaultValue
need to be an array.
placeholder
open
disabled
startIcon
success
Type | bool |
---|---|
Default | false |
Description
When is true
, changes the layout to demonstrate that something positive has happened.
error
maxHeight
dropdownComponent
dropdownAnchor
Type | instance of Element |
---|
Description
The custom anchor element for the dropdown.
Useful for component development where Select
is present internally but the dropdown must
be positioned relative to another component of the composition.
inputRef
renderInputValue
Type | func |
---|---|
Param | props Object - Object with information available for rendering the input value. |
Description
Render the selected value in the input.
When using it, you will have to deal with the rule of displaying the placeholder when there is no value.
The layout will come clean, so if you want to keep the existing layout you will
have to encapsulate the result with the component Select.Display
.
<Select
renderInputValue={({ label, placeholder }) => {
return (
<Select.Display showPlaceholder={!label}>
{label || placeholder}
</Select.Display>
);
}}
/>
Receives an React.SyntheticEvent
and a value
as parameter.
Receives an React.SyntheticEvent
.
renderCheck
Type | func |
---|---|
Param | props Object - Object with information available for rendering the selection inidicator. |
Param | rest Object - The rest of the props passed to the Select.Option . |
Description
Render custom selection indicator.
<Select
renderCheck={({ selected, disabled }) => (
<RoundedIcon
fill={`var(${
disabled
? '--neutral-icon-disabled'
: selected
? '--primary-icon'
: '--neutral-icon-low-emphasis'
})`}
size={RoundedIcon.sizes.xs}
>
<Checkmark
title="Checkmark icon"
fill="var(--neutral-icon-inverse)"
/>
</RoundedIcon>
)}
/>
onChange
Type | func |
---|---|
Param | event React.SyntheticEvent - The event source of the callback. |
Param | value * - The new intended value for the Select . |
Param | infos Object - Additional information about the selected option. |
Description
Callback fired when the select changes.
onClose
Type | func |
---|---|
Param | event React.SyntheticEvent - The event source of the callback. |
Description
Callback fired when the select is close.
onOpen
Type | func |
---|---|
Param | event React.SyntheticEvent - The event source of the callback. |
Description
Callback fired when select will open.
renderValue
🗑️
Concerns | 🗑️ Deprecated |
---|---|
Type | func |
Param | value any - The value provided to the component. |
Description
Render the selected value.
When using it, you will have to deal with the rule of displaying the placeholder when there is no value.
The layout will come clean, so if you want to keep the existing layout you will
have to encapsulate the result with the component Select.Display
.
<Select
renderValue={(value) => {
// The value is like { name: '', ... }
const displayText = value?.name;
return (
<Select.Display showPlaceholder={displayText === ""}>
{displayText || "Select an option..."}
</Select.Display>
);
}}
/>
tabIndex
Type | Error to identify property type |
---|---|
Default | 0 |
Description
<SelectDisplay />
Import
import { SelectDisplay } from '@resultadosdigitais/tangram-components'
Properties
showPlaceholder
Type | bool |
---|---|
Default | false |
Description
Add this property when the placeholder is displayed to enable appropriate styles.
<SelectDisplayTag />
Import
import { SelectDisplayTag } from '@resultadosdigitais/tangram-components'
Properties
value
Type | any | arrayOf |
---|
Description
Value of the selected option, or an array of values in case of multiple selection.
label
Type | string | arrayOf |
---|
Description
Label associated with the selected value, or an array of labels in case of multiple selection, with each label in the same position in the array as its associated value.
multiple
placeholder
deselect
Type | func |
---|---|
Param | event React.SyntheticEvent - The event responsible for triggering deselection. |
Param | value * - The value of the option that will be deselected. |
Description
The function that will be used to deselect an option.
<SelectDivider />
Import
import { SelectDivider } from '@resultadosdigitais/tangram-components'
<SelectFooter />
Import
import { SelectFooter } from '@resultadosdigitais/tangram-components'
Properties
children
<SelectGroup />
Import
import { SelectGroup } from '@resultadosdigitais/tangram-components'
Properties
children
label
collapsible
defaultClose
<SelectHeader />
Import
import { SelectHeader } from '@resultadosdigitais/tangram-components'
Properties
children
<SelectOption />
Import
import { SelectOption } from '@resultadosdigitais/tangram-components'
Properties
children
value
disabled
listItemProps
renderCheck
Type | func |
---|---|
Param | props Object - Object with information available for rendering the selection inidicator. |
Param | rest Object - The rest of the props passed to the Select.Option . |
Description
Render custom selection indicator.
It takes precedence over the Select
renderCheck
.
<Select
renderCheck={({ selected, disabled }) => (
<RoundedIcon
fill={`var(${
disabled
? '--neutral-icon-disabled'
: selected
? '--primary-icon'
: '--neutral-icon-low-emphasis'
})`}
size={RoundedIcon.sizes.xs}
>
<Checkmark
title="Checkmark icon"
fill="var(--neutral-icon-inverse)"
/>
</RoundedIcon>
)}
/>
selected
Type | Error to identify property type |
---|---|
Default | false |
Description
<SelectOptionLabel />
Import
import { SelectOptionLabel } from '@resultadosdigitais/tangram-components'