New Features
ItemTitle
now accepts custom children
The ItemTitle
now accepts a text element as the child, in addition to a string. To use this behavior, you must pass a textValue
prop to the parent Item
.
<DropdownMenu.Item textValue="Cars" key="cars">
<DropdownMenu.ItemTitle>
<Text>
Cars
</Text>
<DropdownMenu.ItemTitle>
</DropdownMenu.Item>
This is useful for rendering custom text nodes on Web. The textValue
prop supplied to Item
will get used on iOS and Android as the title. On Web, it will be used for typeahead.
The previous behavior still works too, wherein you simply pass a string
to ItemTitle
:
<DropdownMenu.Item key="cars">
<DropdownMenu.ItemTitle>
Cars
</DropdownMenu.ItemTitle>
</DropdownMenu.Item>
The textValue
prop is optional in this case. However, you can still set it if you'd like. If you do, it will override the title on iOS and Android. It will also set the label for typeahead purposes on Web.
<DropdownMenu.Item textValue="Red Cars" key="cars">
<DropdownMenu.ItemTitle>
Cars
</DropdownMenu.ItemTitle>
</DropdownMenu.Item>