Skip to content

Building Arabic layouts with Tailwind

Build Arabic navigation, cards, forms and tables with Tailwind, then test font loading, text growth, field direction and narrow-screen layouts.

By , Founder of Ritla

Guide14 min read

An Arabic page can have the right reading direction and still fail as a layout. A navigation label wraps outside a fixed-height header. A course description pushes its registration link beyond a clipped card. A session table makes the whole phone viewport scroll sideways instead of containing that movement locally.

Those failures need different repairs. Mirroring the page again will not give a card more height or let a grid child shrink. Tailwind provides the CSS controls, but the component still needs a clear rule for what happens when its content no longer fits.

This guide builds a rooftop-gardening program page with navigation, a course grid, a registration form and a session table. The examples use Tailwind v4 and share one page direction and typography foundation. They are layout examples: connect registration and other application actions to the product's existing behavior.

Decide how each section handles content growth#

Start with the content and interactions, then choose the constraints. A translated page should preserve the useful relationships of the English product, including which information comes first and which actions remain available.

For the gardening page, those relationships are:

SectionRelationship to preserveWhen space runs out
NavigationLinks remain in reading and focus orderWrap onto another line
Course gridA title, description and registration link stay togetherReduce columns and let cards grow
Registration formLabels remain attached to their fieldsStack fields and allow help text to wrap
Session tableHeaders remain associated with comparable rowsScroll the table region horizontally

These are product choices, not universal Arabic layout rules. A larger navigation system might use a menu rather than wrapping. A short schedule might fit without scrolling. Make that choice explicit before copying utilities from another section.

Use real content early: a long course name, an unavailable course, a two-paragraph description and a registration error. Testing only short labels hides the constraints that matter. Also keep an English version of the same records so changes to shared layout can be checked in both languages.

Do not begin by duplicating the whole page for Arabic. Shared components can express most of these relationships. Split implementations when the information architecture or interaction genuinely differs, not simply because the text starts on another side.

Set document direction and typography before measuring boxes#

Declare the Arabic document's language and direction together:

html
<html lang="ar" dir="rtl">

The W3C direction guidance explains the document-level role of dir. A translated heading or a text-right utility cannot replace it. Let normal sections inherit direction, and inspect any library component that establishes an explicit override.

Then choose a font family that can supply the Arabic glyphs. In a v4 stylesheet, a family token can create a named utility:

css
@import "tailwindcss"; @theme {  --font-arabic: "Noto Sans Arabic", Tahoma, Arial, sans-serif;}

Apply the foundation to the page body:

html
<body class="font-arabic text-base leading-relaxed">

The named font must be provided by your font loader or available on the device. Declaring its family does not download it. Use the application's existing font-loading mechanism, and confirm which family actually renders the Arabic text. Tailwind's font-family documentation covers theme tokens and font loading; MDN describes the fallback list.

A computed font-family string only shows the requested list. It does not prove that the first family supplied every glyph. Inspect rendered fonts in the browser and check failed font requests when Arabic looks different from the design. R050 covers Arabic text falling back past the declared family, including a webfont that failed to load.

Set line height deliberately, then test the actual font at body and heading sizes. leading-relaxed is a starting choice, not a guarantee that every Arabic font and diacritic combination fits. CSS line height controls line boxes, while the font determines the shapes drawn inside and around them. Avoid importing a tight English heading treatment into multiline Arabic without inspection.

R052 covers line height below 1.5 on Arabic body text. It does not establish that a larger value suits every heading. Keep the deeper typography decisions in why Arabic text needs different line heights.

Measure layout after the intended font loads, and review the fallback state separately. A navigation bar that fits only after a webfont arrives still needs a usable loading state.

Check headings independently of the body setting. Tailwind's named font-size utilities can supply their own line height, as the font-size reference shows. A heading with text-xl therefore needs inspection even when the body uses leading-relaxed. If it wraps tightly, choose its line-height utility on the heading and recheck the card's height. Confirm the requested font weights are available through the loader too; a screenshot approved with one rendered face does not validate a different face used after deployment.

Remove English display treatments when they do not serve the Arabic text. Letter spacing, forced single-line text and a compressed heading box should each have a reason beyond matching the original English class list. Test Arabic words with marks, ordinary unmarked text and the actual course names used by the page.

Build navigation that can wrap without losing its sequence#

A header with a single-line assumption can fail when the Arabic labels need more space. whitespace-nowrap on the whole navigation and a fixed header height make that constraint harder to escape.

For this small page, allow the links to wrap:

html
<nav aria-label="التنقل الرئيسي"     class="flex flex-wrap items-center gap-x-6 gap-y-3 border-b border-slate-300 py-4">  <a href="#programs" class="py-2">برامج الحديقة</a>  <a href="#registration" class="py-2">التسجيل في برنامج</a>  <a href="#sessions" class="py-2">الجلسات القادمة</a></nav>

The destination IDs are supplied by the sections below. The links remain in DOM order. In RTL, a normal flex row begins from the right; adding flex-row-reverse would make a separate ordering decision that this navigation does not need.

Tailwind's wrapping utilities let another line form, and the row gap supplies space between those lines. Inspect both the horizontal gaps and vertical gaps after wrapping. Side margins copied onto individual links can leave unwanted space at line boundaries.

Keep the surrounding header content-driven as well. A wrapping navigation cannot expand a header that clips everything beyond a fixed height. Check a logo or account control beside it at the same time, since those siblings consume available width even when they have not been translated.

Tab through the links at desktop and phone widths. The focus sequence should follow the intended sequence even when the links occupy more than one line. Do not reorder the markup differently for each language solely to reproduce an English left-to-right screenshot.

If the product needs a collapsed navigation, implement its opening, closing, focus and accessible name as an actual control. Hiding these links behind a decorative menu icon is not a completed mobile navigation. Open the menu in the test; a closed header cannot show whether translated items fit inside it.

Keep direction-sensitive icons separate from their text. A directional arrow may need a counterpart; the garden's logo and a generic account symbol do not. Use what should be mirrored in RTL when that decision is unclear.

Let course cards grow before adding truncation#

A card styled with h-48 overflow-hidden has a fixed amount of vertical space. Increasing Arabic line height or adding a second description paragraph can push content outside that box. Changing text alignment does not repair the height constraint.

Use a responsive grid and cards whose height follows their content:

html
<section id="programs" aria-labelledby="programs-heading" class="space-y-6">  <h2 id="programs-heading" class="text-2xl font-semibold">برامج الحديقة</h2>  <div class="grid gap-6 md:grid-cols-2">    <article class="flex min-w-0 flex-col rounded-lg border border-slate-300 p-6">      <h3 class="text-xl font-semibold">زراعة الأعشاب على الشرفات</h3>      <p class="mt-3">تعلّم اختيار الأوعية والعناية بالأعشاب في المساحات الصغيرة.</p>      <a href="#registration" class="mt-auto pt-6 font-semibold">التسجيل في برنامج الأعشاب</a>    </article>    <article class="flex min-w-0 flex-col rounded-lg border border-slate-300 p-6">      <h3 class="text-xl font-semibold">إكثار النباتات من البذور</h3>      <p class="mt-3">تدرّب على تجهيز التربة ومتابعة الإنبات ونقل الشتلات إلى أوعية أكبر.</p>      <a href="#registration" class="mt-auto pt-6 font-semibold">التسجيل في برنامج البذور</a>    </article>  </div></section>

At the base width there is one column; at the configured medium breakpoint there are two. Tailwind's grid-column utilities define the tracks. Keep the course source order meaningful in both directions instead of reversing the array when the first course appears on the right.

The flex column lets the link use remaining vertical space within its card. The top padding still separates it from the description when there is no spare space. Review the cards with different description lengths; this pattern does not impose one universal height across different grid rows.

min-w-0 allows the grid item to shrink below its automatic minimum when the layout requires it. MDN explains automatic minimum sizes for flex and grid items. It does not make every long token wrap. If a course includes an unbroken attachment name or URL, inspect that text's wrapping separately.

Keep the full title when it is needed to distinguish courses. Truncating every card to two lines may produce a tidy grid while hiding the part that tells participants which program they are choosing. Use deliberate truncation only when the remaining text and another available detail view preserve that distinction.

Test an unavailable course too. Its explanation and disabled or alternative action may be longer than the successful registration link. Allow that state to contribute to the card's height instead of fixing a height from the shortest record.

R042 covers clipped text wider than its box with hidden overflow and no ellipsis. Deliberate truncation can still hide necessary information even when that description does not apply. Review what the participant can learn from the visible card.

Give registration fields their own layout and direction#

Do not make the entire form LTR to accommodate an email address. Keep the Arabic form context and establish direction locally for the technical value.

This form stacks at narrow widths and pairs two short fields when space permits:

html
<form id="registration" aria-labelledby="registration-heading" class="space-y-6">  <h2 id="registration-heading" class="text-2xl font-semibold">التسجيل في برنامج</h2>  <div class="grid gap-5 md:grid-cols-2">    <div class="min-w-0 space-y-2">      <label for="garden-program" class="block font-semibold">البرنامج المطلوب</label>      <select id="garden-program" name="program" class="w-full min-w-0 rounded-md border p-3">        <option value="herbs">زراعة الأعشاب على الشرفات</option>        <option value="seeds">إكثار النباتات من البذور</option>      </select>    </div>    <div class="min-w-0 space-y-2">      <label for="garden-email" class="block font-semibold">البريد الإلكتروني للتواصل</label>      <input id="garden-email" name="email" type="email" dir="ltr"             autocomplete="email" required class="w-full min-w-0 rounded-md border p-3">    </div>    <div class="space-y-2 md:col-span-2">      <label for="garden-notes" class="block font-semibold">ملاحظات عن مساحة الزراعة</label>      <textarea id="garden-notes" name="notes" rows="4" dir="rtl"                class="w-full rounded-md border p-3"></textarea>    </div>  </div>  <button type="submit" class="rounded-md border px-5 py-3 font-semibold">إرسال طلب التسجيل</button></form>

Wire submission to the application's registration flow; this snippet defines the controls and layout. The visible labels remain outside the fields, with explicit associations. The W3C labeling tutorial explains those associations. A placeholder is not a replacement for a label after typing begins.

The email field's direction is explicit because it accepts an email address. The Arabic notes field has a different content contract. If the product permits notes in either language, consider a content-sensitive direction policy and test the empty, Arabic and English states; do not apply that policy automatically to every field. Use Arabic text input direction for the field-specific choices.

R070 covers telephone, email and URL inputs rendered RTL. R072 covers a select rendered LTR with Arabic options. Neither description establishes how the select's expanded native menu or keyboard interaction behaves, so test those directly in supported browsers and devices.

Add application validation messages to the same grid item as the field they describe, and allow that item to grow. An error placed with a negative margin beneath a fixed-height field row can overlap the next label. Keep long Arabic help text in normal flow, and connect it to the control using the application's accessibility pattern.

Do not assume the document language determines native validation-message language. Exercise the required email field in the browser configuration participants use, and test the application's own Arabic error messages separately. The email input reference describes its native validation behavior; Arabic form validation messages covers the localized application layer.

Finally, open the on-screen keyboard on a real phone. Verify the focused control, current error and submit action remain reachable. A narrow desktop viewport is useful for the grid, but it does not reproduce that interaction.

Exercise the pending and successful submission states as well. The Arabic pending label can take more room than the initial button label, and a confirmation message can replace a short control with several lines. Let the button and message container accommodate their text, and verify that the state change does not hide the focused control or separate an error from its field. Preserve entered notes after a recoverable server error so participants can correct the request without retyping it.

Contain the session table's width without reversing its data#

The schedule compares program, location and starting time. Preserve those relationships as a table rather than turning the row into unrelated text boxes simply to fit a narrow screen.

html
<section id="sessions" aria-labelledby="sessions-heading" class="min-w-0 space-y-4">  <h2 id="sessions-heading" class="text-2xl font-semibold">الجلسات القادمة</h2>  <div role="region" aria-labelledby="sessions-heading" tabindex="0"       class="max-w-full overflow-x-auto rounded-lg border border-slate-300">    <table class="w-full min-w-[38rem]">      <thead>        <tr>          <th scope="col" class="p-4 text-start">البرنامج</th>          <th scope="col" class="p-4 text-start">مكان اللقاء</th>          <th scope="col" class="p-4 text-start">وقت البداية</th>        </tr>      </thead>      <tbody>        <tr class="border-t border-slate-300">          <th scope="row" class="p-4 text-start font-normal">زراعة الأعشاب على الشرفات</th>          <td class="p-4 text-start">الحديقة التعليمية</td>          <td class="whitespace-nowrap p-4 text-start"><bdi dir="ltr">18:35</bdi></td>        </tr>      </tbody>    </table>  </div></section>

The first source column belongs at the reading start. Under inherited RTL direction, it is the rightmost column. Do not reverse the data columns in code as a second mirroring step. The W3C direction guidance covers table direction, and its table-header tutorial explains the header associations.

The table's minimum width is a starting constraint for these columns, not an Arabic requirement. Tune it against actual records. Long program names can wrap, while the short time value remains together. Keeping the time's LTR boundary inside the cell preserves the surrounding cell's RTL alignment.

The wrapper owns horizontal scrolling. Tailwind's overflow utilities supply that behavior. The region is named and keyboard-focusable; verify that users can reach and scroll it without getting trapped, and retain a visible focus indicator.

Test the wrapper inside the real page layout. If an ancestor flex or grid item refuses to shrink, the wrapper can expand with the table instead of containing its width. Inspect that ancestor's minimum size and the available width before adding more overflow rules to the table itself.

This is the distinction to preserve: the schedule may scroll locally while the surrounding page stays within the viewport. Adding overflow-x-hidden to the body can hide a page-width defect and leave part of the schedule unreachable. R040 covers document-level horizontal overflow; it does not mean every intentionally scrollable table region is a defect.

With enough records to require scrolling, move to both ends and check the first and last columns. Test touch and keyboard input. A screenshot of the initial edge cannot establish that the rest of the schedule is reachable.

Measure the page and the table region separately while debugging. Compare document.documentElement.scrollWidth with its clientWidth, then inspect the wrapper's corresponding dimensions. MDN defines scrollWidth as the content width including horizontal content outside the visible area. A wider table region can be intentional; a wider document identifies a different containment problem. If the document remains too wide after temporarily removing the table, continue looking at navigation, cards and positioned content instead of repeatedly changing the table's minimum width.

Size reused sections against their available space#

The course grid above uses viewport breakpoints because it sits in the main page column. If the same section later appears beside a registration summary or inside a narrow panel, a wide viewport may activate two columns even though the section itself has little room.

For that reuse, consider a container query. Add @container to an outer wrapper and use a container variant such as @md:grid-cols-2 on the inner grid. The wrapper must be an ancestor of the grid being styled. Tailwind's responsive-design guide explains container queries alongside viewport variants.

Choose the container threshold from the card content, not from the matching letters in the breakpoint name. md: and @md: refer to different measurements and can have different configured thresholds. Replace the viewport rule when adopting the container rule; leaving both active can preserve the unwanted two-column state.

Check this at a fixed browser width while opening and closing the neighboring panel. The cards should adapt to the space they receive. Then repeat with the form and table present: an unexpectedly wide child can affect the available layout before a container query has any chance to solve the content constraint. Container queries select styles; they do not remove an oversized minimum width or make an unbroken token wrap.

Use logical spacing at the section boundaries#

The examples use symmetric padding where both edges have the same role. When a section needs an asymmetric relationship, express the role directly: ps-* for starting padding, pe-* for ending padding, and ms-* or me-* for corresponding margins.

For example, an explanatory note can have an accent at its starting edge with border-s-4 ps-5. If an existing English implementation uses a left accent for that purpose, the logical replacement preserves its English side and moves it for Arabic. Remove the old physical border and padding instead of retaining both implementations.

Do not convert every physical coordinate. A marker on a rooftop-plan image must remain attached to the same point on that image when the surrounding registration page changes language. The interface's reading direction and the plan's coordinate system serve different purposes.

Keep full utility mappings in CSS logical properties for RTL. On this page, review the relationship between sections: heading alignment, card padding, field spacing and the table's scroll boundary. A consistent property name matters less than whether each relationship survives the language switch.

R030 covers direction-sensitive physical properties without an RTL override. Use that finding to inspect the intended edge, including responsive modifiers and shared component defaults. It is not a reason to shift every element to the opposite side.

Test the combined page, including states that change its height#

Assemble the sections inside the application's usual centered page container, with page-level padding and vertical spacing. Then test the combined page rather than approving four isolated screenshots.

A font change can wrap navigation, grow course cards, widen a select and alter table row height in the same release. An error message can move the form's submit button below the initial viewport. Those are cross-section effects even when each section uses the correct direction.

Use a small state matrix:

StateInspect
Font loading slowlyNavigation and controls remain usable before the final font arrives
Long course descriptionFull text and the registration link remain reachable
Unavailable courseExplanation and alternative action fit the card
Registration errorHelp text stays with its field and the next label remains visible
Expanded menu or selectOptions, focus and placement work in the actual environment
Narrow scheduleOnly the table region scrolls horizontally

Test immediately below and above the application's column-change breakpoint. Also test the narrowest supported viewport and increased text size. Do not shrink Arabic text merely to preserve the number of columns from the English design.

Keep the stress cases as named test records rather than editing a short sample ad hoc during each review. A long program name should remain long after the next content refresh; an unavailable-course fixture should still exercise its alternative action. Record the viewport, font-loading state and whether an overlay was open with each screenshot. That makes a changed line break or missing button reproducible, and prevents the next test run from passing simply because it selected an easier record.

For repeatable settled screenshots, wait for the visible application state and then for document.fonts.ready. MDN documents that promise. It waits for font-loading and associated layout work; it does not establish that the intended family supplied the Arabic glyphs or that a later-opened dialog has finished loading its own content.

Compare the English page after shared CSS changes. Keep the same records, widths and interaction states, then evaluate the intended reading-relative differences. A moved first column can be correct; an unreachable registration action is not.

When reporting a failure, name the section and the constraint: a clipped description inside a fixed-height card, a select's width forcing a grid item wider, or a table wrapper inheriting an overlarge minimum size. That gives the developer a layout relationship to inspect instead of a vague instruction to “fix RTL.”

A free Ritla scan of the assembled Arabic page can surface document-level horizontal overflow or clipped text that matches the relevant check description; use the section tests above to locate the constraint behind it. Continue with testing RTL across breakpoints, or Arabic text getting cut off in CSS when the final font exposes clipping that the initial layout concealed.

Checks in this guide

See what your Arabic pages are hiding

Paste a URL. Ritla renders the page on desktop and mobile, runs every check, and shows the top issues with screenshot evidence.

Scan a page freeBrowse the checks