I want to line up the 3 icons in a row which works but I'd like them to start being…
- User
I want to line up the 3 icons in a row which works but I'd like them to start being placed to the right, then expanding to the left if they need to. flexDirection: 'Row-reverse' flips the order too, but I don't want that. ANy other options in reac tnative?
{/* Row reverse to line them up /} <View style={{ flexDirection: 'row-reverse' }}> {/ Need door access /} {data.doorAccess && } {/ Need transportation /} {data.transportation && } {/ Need phone */} {data.phoneNeeded && }
- Assistant
To achieve the alignment where the icons start from the right and expand to the left without reversing the order of the items, you can make use of the
justifyContentproperty along withflexDirection: 'row'. Specifically, usejustifyContent: 'flex-end'to start placing items from the right side.Here's how you can update your code to achieve this:
jsx<View style={{ flexDirection: 'row', justifyContent: 'flex-end' }}> {/* Need door access */} {data.doorAccess && ( <Tooltip enterTouchDelay={2000} leaveTouchDelay={1500} title="Need Door Access"> <MaterialCommunityIcons name="door-sliding-lock" size={24} color="black" /> </Tooltip> )} {/* Need transportation */} {data.transportation && ( <FontAwesome5 name="car" size={24} color="black" /> )} {/* Need phone */} {data.phoneNeeded && ( <SimpleLineIcons name="screen-smartphone" size={24} color="black" /> )} </View>