You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From here, I should have the 1st and 4th Item components with pl-2 (because align === "left") and the 2nd and 3rd Item components with pr-2 (because align !== "left").
But the result is different: the 4th Item component has pr-2 applied.
Hi! I'm facing a weird issue when applying padding to siblings div.
What I'm searching to do
Apply
padding
depending on a prop value (align
in my case), and passing thispadding
throughclassName
to a styled component.The code
I have four
Items
with variousalign
value:textPadding
is set depending onalign
value, and pass viaclassName
toStyledItem
.StyledItem
is a twind/react styled component.From here, I should have the 1st and 4th
Item
components withpl-2
(becausealign === "left"
) and the 2nd and 3rdItem
components withpr-2
(becausealign !== "left"
).But the result is different: the 4th
Item
component haspr-2
applied.(screenshot with padding as blue parts)
Reproduced issue in sandbox
https://codesandbox.io/s/relaxed-lederberg-9euwo?file=/src/App.tsx
What do you think? It's because we add style through
className
to a styled component?Thanks a lot :)
The text was updated successfully, but these errors were encountered: