Screen readers should accurately 'read' the text contents of the custom node you return from the callback you pass to trigger as the label for the Dropdown element. However, you can explicitly pass a label string to ariaMenuName to explicitly label the element in case screen readers are not behaving as expected.
<Arrangegap="large">
<Dropdown
ariaMenuName="Button with label override"
triggerCallback={buttonProps=>{
return(
<ArrangetabIndex="0"{...buttonProps}>
<TextfontWeight="bold">This label is invisible to screen readers</Text>
<Iconicon={<SvgChevronDown/>}/>
</Arrange>
)
}}
options={[
{title:'Share'},
{title:'Archive'},
{title:'Disabled',disabled:true},
]}
/>
</Arrange>
Trigger
triggerCallback
A callback function that returns a custom node. The Dropdown component will pass the necessary ARIA attributes to allow screen readers to properly 'read' the custom node returned by your callback.
Providing this prop will override any custom node passed to trigger.
trigger (deprecated - use triggerCallback instead)
Trigger can be any custom node. If the trigger is not a button make sure to add a tabindex attribute to it.
Note on deprecation: This approach is not a11y compliant, as screen readers cannot properly 'read' the dropdown options. Using a screen reader, you can test the buttons below. Only the first should have its menu items read.
For dropdowns with many options that make it difficult to find the intended value, a search input can be added.
By default, the option values are filtered on the inputted value using a loose includes pattern.
triggerCallback={buttonProps=><Button{...buttonProps}>Starts With Search</Button>}
menuMaxHeight={42}
options={[
{title:'A'},
{title:'B'},
{title:'AB'},
{title:'BA'},
{title:'Aa'},
{title:'AA'},
{title:'Bb'},
{title:'BB'},
{title:'ABC'},
{title:'ACB'},
{title:'BAC'},
{title:'BCA'},
{title:'CAB'},
{title:'CBA'},
{title:'a'},
{title:'b'},
]}
search={{
searchPlaceholder:'Search with starts with...',
searchType:'startsWith',
}}
/>
</Arrange>
With ReactElement options
For options that implement a ReactElement as the title of the options property, the element properties must be joined
with React.PropsWithChildren or have the children property. Furthermore, the searchable value of the element must be
included as a child of the element to ensure its value can be parsed.