react-native-select
react-native-select copied to clipboard
Is it possible to style the selected item within the modal?
As per title, I can't spot any way to style the text (and background) of the selected item for just the modal. Is it possible? If not i'll change this to a feature request
For single selection
<DropdownSelect
label="Gender"
placeholder="Select an option..."
options={[
{
name: (
<View style={styles.itemStyle}>
<Image
style={styles.avatarStyle}
source={{
uri: 'https://avatar.iran.liara.run/username?username=Azeezat+Raheem',
}}
/>
<Text style={{color: gender === 1 ? 'green' : 'red'}}>
Male
</Text>
</View>
),
id: 1,
},
{
name: (
<View style={styles.itemStyle}>
<Image
style={styles.avatarStyle}
source={{
uri: 'https://avatar.iran.liara.run/public/boy?username=Ash',
}}
/>
<Text style={{color: gender === 2 ? 'green' : 'red'}}>
Female
</Text>
</View>
),
id: 2,
},
]}
optionLabel={'name'}
optionValue={'id'}
selectedValue={gender}
onValueChange={(itemValue: any) => setGender(itemValue)}
/>
for multiple selections
<DropdownSelect
label="Gender"
placeholder="Select an option..."
options={[
{
name: (
<View style={styles.itemStyle}>
<Image
style={styles.avatarStyle}
source={{
uri: 'https://avatar.iran.liara.run/username?username=Azeezat+Raheem',
}}
/>
<Text
style={{
color: gender.find(item => item === 1)
? 'green'
: 'red',
}}>
Male
</Text>
</View>
),
id: 1,
},
{
name: (
<View style={styles.itemStyle}>
<Image
style={styles.avatarStyle}
source={{
uri: 'https://avatar.iran.liara.run/public/boy?username=Ash',
}}
/>
<Text
style={{
color: gender.find(item => item === 2)
? 'green'
: 'red',
}}>
Female
</Text>
</View>
),
id: 2,
},
]}
optionLabel={'name'}
optionValue={'id'}
selectedValue={gender}
onValueChange={(itemValue: any) => setGender(itemValue)}
isMultiple
/>
@gitn00b1337 Please let me know if this is helpful.