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'