Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/docs/text-align.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,55 @@ Use the `text-justify` utility to justify the text of an element:
### Responsive design

<ResponsiveDesign element="p" property="text-align" defaultClass="text-left" featuredClass="text-center" />

### Using logical properties

Use the `rtl` variant to conditionally add styles for both right-to-left and left-to-right, when building multi-directional layouts:

```html
<!-- [!code classes:rtl:text-right] -->
<p class="text-left rtl:text-right">So I started to walk into the water...</p>
```

Alternatively, you can use the `text-start` and `text-end` logical utilities, to let the browser align the text either the left or right side based on the writing direction:

<Figure>

<Example>
{
<div className="grid grid-cols-2 place-items-center gap-x-4">
<div className="flex flex-col gap-y-4" dir="ltr">
<p className="text-sm font-medium">Left-to-right</p>
<div className="font-mono text-sm font-bold text-start">start</div>
<div className="font-mono text-sm font-bold text-center">center</div>
<div className="font-mono text-sm font-bold text-end">end</div>
</div>
<div className="flex flex-col gap-y-4" dir="rtl">
<p className="text-sm font-medium">Right-to-left</p>
<div className="font-mono text-sm font-bold text-start">start</div>
<div className="font-mono text-sm font-bold text-center">center</div>
<div className="font-mono text-sm font-bold text-end">end</div>
</div>
</div>
}
</Example>

```html
<!-- [!code classes:text-start,text-end] -->
<!-- [!code word:dir="ltr"] -->
<!-- [!code word:dir="rtl"] -->
<div>
<div dir="ltr">
<div class="text-start ...">start</div>
<div class="text-center ...">center</div>
<div class="text-end ...">end</div>
</div>
<div dir="rtl">
<div class="text-start ...">start</div>
<div class="text-center ...">center</div>
<div class="text-end ...">end</div>
</div>
</div>
```

</Figure>