79461191

Date: 2025-02-23 12:14:50
Score: 1
Natty:
Report link

I think easiest think is to use style attribute.

const [variantColor, setVariantColor] = useState<string | undefined>(""); const colorOptions=["#00FFFF","#FAEBD7","#DC143C"]

{colorOptions?.map((color) => {
return ( <div key={index}
style={{ borderStyle: "solid", borderColor: variantColor === color ? ${color} : ${color}50, }} > <div onClick={() => setVariantColor(color)} style={{ backgroundColor: variantColor === color ? ${color} : ${color}50, }}
/> ); }) ); })}

Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: jagath botheju