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'