@@ -115,7 +115,9 @@ const items = ['Option 1', 'Option 2', 'Option 3']
115115
116116The ` Dropdown ` takes in an ` items ` array and can then be formatted by
117117` itemToElement ` and ` itemToString ` . ` itemToElement ` allows you to wrap each
118- dropdown item in a custom element.
118+ dropdown item in a custom element. The
119+ [ ` itemToString ` prop] ( #dropdown-itemtostring ) can be used with this to provide
120+ the text of the item in the input on selection.
119121
120122<Dropdown
121123 items = { [
@@ -161,6 +163,26 @@ dropdown item in a custom element.
161163If the ` items ` array is not an array of strings, you'll need to use
162164` itemToString ` to grab the text to be used as the ` Dropdown ` item text.
163165
166+ <Dropdown
167+ items = { [
168+ { id: ' option-0' , text: ' Option 0' },
169+ { id: ' option-1' , text: ' Option 1' },
170+ { id: ' option-2' , text: ' Option 2' },
171+ ]}
172+ itemToString = { (item ) => (item ? item .text : ' ' )}
173+ itemToElement = { (item ) =>
174+ item ? (
175+ <span className = " test" style = { { color: ' red' }} >
176+ { item .text } 🔥
177+ </span >
178+ ) : (
179+ ' '
180+ )
181+ }
182+ label = " Select an option..."
183+ id = " item-to-element"
184+ />
185+
164186``` jsx
165187< Dropdown
166188 items= {[
@@ -169,6 +191,17 @@ If the `items` array is not an array of strings, you'll need to use
169191 { id: ' option-2' , text: ' Option 2' },
170192 ]}
171193 itemToString= {(item ) => (item ? item .text : ' ' )}
194+ itemToElement= {(item ) =>
195+ item ? (
196+ < span className= " test" style= {{ color: ' red' }}>
197+ {item .text } 🔥
198+ < / span>
199+ ) : (
200+ ' '
201+ )
202+ }
203+ label= " Select an option..."
204+ id= " item-to-element"
172205/ >
173206```
174207
0 commit comments