In react I'm trying to change the position of "Détails", a button that contains an icon and text. I cannot modify the HTML structure as it comes from a shared component.
Here is the code where I use this shared component like this:
return (
<>
{data.map((item, index) => (
<div className={`${styles['card-group']} details-button-wrapper`} key={index}>
<DetailModal item={item} title={getItemTitle(item)}>
Détails
</DetailModal>
<CardDetail
key={`${item.make}-${item.groupByCommercialName}-${index}`}
position={index + 1}
title={getItemTitle(item)}
maxYear={item.maxYear || new Date().getFullYear()}
iconTextListProps={getIconTextListProps(item)}
{...getItemMetrics(item)}
/>
</div>
))}
</>
);
I want to right-align only the element "Détails" without affecting CardDetail.
What I've tried:
None of these attempts worked - they either didn't affect the alignment or disrupted the existing layout.
I need a CSS selector that will specifically target the text span without modifying the component's source code. How can I achieve this?
This might work, modify the .details-button-wrapper
container to display as flex
and push the button to the right.
.details-button-wrapper {
display: flex;
justify-content: space-between;
align-items: center;
}