Menu

Running a Hebrew storefront in Next.js: the RTL bugs nobody warns you about
๐Ÿ“ฐ

Running a Hebrew storefront in Next.js: the RTL bugs nobody warns you about

DEV Community: cssยทRAMOยท5 days ago
#rJgK9hbJ
#devtocss#devto#dev#left#model
Reading 0:00
15s threshold

Our store at RAMO sells hardware, plumbing and garden supplies, and most of our customers read Hebrew. That means the whole storefront runs right-to-left. Setting dir="rtl" on the root element is the easy part. It flips the page, and for a day you think you're done.

Then the small bugs show up. None of them are hard, but nobody lists them in one place, so here's ours.

1. Stop writing left and right in CSS

The first round of bugs was always the same: a margin on the wrong side, an icon hugging the wrong edge, a dropdown opening off-screen. Every one came from margin-left , padding-right , left: 0 and friends.

The fix is to use logical properties everywhere:

/* before */ .price-tag { margin-left : 8px ; text-align : left ; }

/* after */ .price-tag { margin-inline-start : 8px ; text-align : start ; }

Enter fullscreen mode

Exit fullscreen mode

inline-start means "the side where text begins", so it follows the direction automatically.โ€ฆ

Continue reading โ€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.