react-native-select icon indicating copy to clipboard operation
react-native-select copied to clipboard

Is it possible to style the selected item within the modal?

Open mike-stewart-dev opened this issue 1 year ago • 3 comments

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

mike-stewart-dev avatar Sep 23 '24 12:09 mike-stewart-dev

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)}
          />

azeezat avatar Sep 28 '24 07:09 azeezat

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
          />

azeezat avatar Sep 28 '24 07:09 azeezat

@gitn00b1337 Please let me know if this is helpful.

azeezat avatar Sep 28 '24 07:09 azeezat