Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Settings - Select with TextImageRow

ANSWERED

Hi guys,

 

In Settings, is there a way to create a select list where each item contains a text image along side the name? Below is what I am trying to achieve but, I cannot get the image to come up.

 

 

 

    <Select
      label="Select with TextImageRow"
      options={[
        { name: 'Label1', value: {location: 'Sub-Label', icon: 'https://xyz'} },
        { name: 'Label2',  value: {location: 'Sub-Label', icon: 'https://xyz'} },
        { name: 'Label3',value: {location: 'Sub-Label', icon: 'https://xyz'} },
        { name: 'Label4', value: {location: 'Sub-Label', icon: 'https://xyz'} },
        { name: 'Label5', value: {location: 'Sub-Label', icon: 'https://xyz'} }
      ]}
    />
Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

I used this:

            renderItem={
              (option) =>
                <TextImageRow
                  label={option.name}
                  icon={colIcons[option.value]}
                />
            }

select.jpg

 

 

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
0 Votes
4 REPLIES 4

I used this:

            renderItem={
              (option) =>
                <TextImageRow
                  label={option.name}
                  icon={colIcons[option.value]}
                />
            }

select.jpg

 

 

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Awesome! Thanks Catplace. That worked well.

 

For anyone else, below is the code I used in settings/index.jsx

 

const colIcons=['https://tinyurl.com/ybbmpxxq','https://tinyurl.com/ybbmpxxq','https://tinyurl.com/ybbmpxxq'];

function mySettings(props) {
  return (
    <Page>                  
          <Select
          label="Selection with icons"
          settingsKey="listKey"
          options={[
              { name: 'Label1', value: 0 },
              { name: 'Label2', value: 1},
              { name: 'Label3', value: 2}
              ]}
          
          renderItem={
                   (options) =>
                      <TextImageRow
                        label={options.name}
                        icon={colIcons[options.value]}
                      />
                  }
            />
      
    </Page>       
    
  );  
}
Best Answer

How did you retrieve those keys in the index.js?

Best Answer
0 Votes

Hi Dcable,

 

That is correct. There is a good example of this in the part ‘settings in action’:

 

https://dev.fitbit.com/build/guides/settings/

 

 


 

Best Answer
0 Votes