Looking for a way to align a row of items with one item centered in the div and the others positioned on either side while maintaining their original order?
Check out this code snippet:
<div className="flex mx-auto justify-center items-center">
<Circle selected={selected === ActionOptions.NONE} onClick={e => setSelected(ActionOptions.NONE)} title="None" />
<Circle selected={selected === ActionOptions.ICON} onClick={e => setSelected(ActionOptions.ICON)} title="Icon">
{Icon(Icons.CHECK, selected === ActionOptions.ICON ? 'w-20 h-20' : 'w-8 h-8')}
</Circle>
<Circle selected={selected === ActionOptions.EMOJI} onClick={e => setSelected(ActionOptions.EMOJI)} title="Emoji">
{Icon(Icons.SMILE, selected === ActionOptions.EMOJI ? 'w-20 h-20' : 'w-8 h-8')}
</Circle>
<Circle selected={selected === ActionOptions.TIMER} onClick={e => setSelected(ActionOptions.TIMER)} title="Timer">
<ClockIcon className={selected === ActionOptions.TIMER ? 'w-20 h-20' : 'w-8 h-8'} />
</Circle>
</div>
function Circle({
selected,
children,
onClick,
title,
}: PropsWithChildren<{ selected: boolean; onClick: (e) => void; title: string }>) {
return (
<div className="flex flex-col items-center justify-center cursor-pointer">
<div
onClick={onClick}
className={`rounded-full flex justify-center items-center ${
selected ? 'w-32 h-32 border-4' : 'w-14 h-14 border-2'
} mx-2 border-white bg-white/10`}
>
{children}
</div>
<span className="text-xs">{title}</span>
</div>
);
}
Does anyone have suggestions on how to achieve this layout design?