@@ -27,12 +27,12 @@ export default function ExampleCombobox() {
2727 < Combobox . Popup className = { styles . Popup } >
2828 < Combobox . Empty className = { styles . Empty } > No fruits found.</ Combobox . Empty >
2929 < Combobox . List className = { styles . List } >
30- { ( item : string ) => (
31- < Combobox . Item key = { item } value = { item } className = { styles . Item } >
30+ { ( item : Fruit ) => (
31+ < Combobox . Item key = { item . value } value = { item } className = { styles . Item } >
3232 < Combobox . ItemIndicator className = { styles . ItemIndicator } >
3333 < CheckIcon className = { styles . ItemIndicatorIcon } />
3434 </ Combobox . ItemIndicator >
35- < div className = { styles . ItemText } > { item } </ div >
35+ < div className = { styles . ItemText } > { item . label } </ div >
3636 </ Combobox . Item >
3737 ) }
3838 </ Combobox . List >
@@ -86,30 +86,35 @@ function ChevronDownIcon(props: React.ComponentProps<'svg'>) {
8686 ) ;
8787}
8888
89- const fruits = [
90- 'Apple' ,
91- 'Banana' ,
92- 'Orange' ,
93- 'Pineapple' ,
94- 'Grape' ,
95- 'Mango' ,
96- 'Strawberry' ,
97- 'Blueberry' ,
98- 'Raspberry' ,
99- 'Blackberry' ,
100- 'Cherry' ,
101- 'Peach' ,
102- 'Pear' ,
103- 'Plum' ,
104- 'Kiwi' ,
105- 'Watermelon' ,
106- 'Cantaloupe' ,
107- 'Honeydew' ,
108- 'Papaya' ,
109- 'Guava' ,
110- 'Lychee' ,
111- 'Pomegranate' ,
112- 'Apricot' ,
113- 'Grapefruit' ,
114- 'Passionfruit' ,
89+ interface Fruit {
90+ label : string ;
91+ value : string ;
92+ }
93+
94+ const fruits : Fruit [ ] = [
95+ { label : 'Apple' , value : 'apple' } ,
96+ { label : 'Banana' , value : 'banana' } ,
97+ { label : 'Orange' , value : 'orange' } ,
98+ { label : 'Pineapple' , value : 'pineapple' } ,
99+ { label : 'Grape' , value : 'grape' } ,
100+ { label : 'Mango' , value : 'mango' } ,
101+ { label : 'Strawberry' , value : 'strawberry' } ,
102+ { label : 'Blueberry' , value : 'blueberry' } ,
103+ { label : 'Raspberry' , value : 'raspberry' } ,
104+ { label : 'Blackberry' , value : 'blackberry' } ,
105+ { label : 'Cherry' , value : 'cherry' } ,
106+ { label : 'Peach' , value : 'peach' } ,
107+ { label : 'Pear' , value : 'pear' } ,
108+ { label : 'Plum' , value : 'plum' } ,
109+ { label : 'Kiwi' , value : 'kiwi' } ,
110+ { label : 'Watermelon' , value : 'watermelon' } ,
111+ { label : 'Cantaloupe' , value : 'cantaloupe' } ,
112+ { label : 'Honeydew' , value : 'honeydew' } ,
113+ { label : 'Papaya' , value : 'papaya' } ,
114+ { label : 'Guava' , value : 'guava' } ,
115+ { label : 'Lychee' , value : 'lychee' } ,
116+ { label : 'Pomegranate' , value : 'pomegranate' } ,
117+ { label : 'Apricot' , value : 'apricot' } ,
118+ { label : 'Grapefruit' , value : 'grapefruit' } ,
119+ { label : 'Passionfruit' , value : 'passionfruit' } ,
115120] ;
0 commit comments