Back to Tailwindcss

Clear

src/docs/clear.mdx

latest10.5 KB
Original Source

import { ApiTable } from "@/components/api-table.tsx"; import { Example } from "@/components/example.tsx"; import { Figure } from "@/components/figure.tsx"; import { ResponsiveDesign } from "@/components/content.tsx";

export const title = "clear"; export const description = "Utilities for controlling the wrapping of content around an element.";

<ApiTable rows={[ ["clear-left", "clear: left;"], ["clear-right", "clear: right;"], ["clear-both", "clear: both;"], ["clear-start", "clear: inline-start;"], ["clear-end", "clear: inline-end;"], ["clear-none", "clear: none;"], ]} />

Examples

Clearing left

Use the clear-left utility to position an element below any preceding left-floated elements:

<Figure> <Example resizable> { <>
  <p className="clear-left text-justify">
    Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but
    what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding
    drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve
    better? Look. If you think this is about overdue fines and missing books, you'd better think again. This is
    about that kid's right to read a book without getting his mind warped! Or: maybe that turns you on, Seinfeld;
    maybe that's how y'get your kicks. You and your good-time buddies.
  </p>
</>

} </Example>

html
<!-- [!code classes:clear-left] -->
<article>
  
  
  <p class="clear-left ...">Maybe we can live without libraries...</p>
</article>
</Figure>

Clearing right

Use the clear-right utility to position an element below any preceding right-floated elements:

<Figure> <Example resizable> { <>
  <p className="clear-right text-justify">
    Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but
    what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding
    drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve
    better? Look. If you think this is about overdue fines and missing books, you'd better think again. This is
    about that kid's right to read a book without getting his mind warped! Or: maybe that turns you on, Seinfeld;
    maybe that's how y'get your kicks. You and your good-time buddies.
  </p>
</>

} </Example>

html
<!-- [!code classes:clear-right] -->
<article>
  
  
  <p class="clear-right ...">Maybe we can live without libraries...</p>
</article>
</Figure>

Clearing all

Use the clear-both utility to position an element below all preceding floated elements:

<Figure> <Example resizable> { <>
  <p className="clear-both text-justify">
    Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but
    what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding
    drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve
    better? Look. If you think this is about overdue fines and missing books, you'd better think again. This is
    about that kid's right to read a book without getting his mind warped! Or: maybe that turns you on, Seinfeld;
    maybe that's how y'get your kicks. You and your good-time buddies.
  </p>
</>

} </Example>

html
<!-- [!code classes:clear-both] -->
<article>
  
  
  <p class="clear-both ...">Maybe we can live without libraries...</p>
</article>
</Figure>

Using logical properties

Use the clear-start and clear-end utilities, which use logical properties to map to either the left or right side based on the text direction:

<Figure> <Example resizable> { <div dir="rtl">
  <p className="clear-end text-justify">
    ربما يمكننا العيش بدون مكتبات، أشخاص مثلي ومثلك. ربما. بالتأكيد، نحن أكبر من أن نغير العالم، ولكن ماذا عن ذلك
    الطفل الذي يجلس ويفتح كتابًا الآن في أحد فروع المكتبة المحلية ويجد رسومات للتبول والبول على القطة في القبعة
    والإخوة الصينيون الخمسة؟ ألا يستحق الأفضل؟ ينظر. إذا كنت تعتقد أن الأمر يتعلق بالغرامات المتأخرة والكتب
    المفقودة، فمن الأفضل أن تفكر مرة أخرى. يتعلق الأمر بحق ذلك الطفل في قراءة كتاب دون أن يتشوه عقله! أو: ربما يثيرك
    هذا يا سينفيلد؛ ربما هذه هي الطريقة التي تحصل بها على ركلاتك. أنت ورفاقك الطيبين.
  </p>
</div>

} </Example>

html
<!-- [!code word:dir="rtl"] -->
<!-- [!code classes:clear-end] -->
<article dir="rtl">
  
  
  <p class="clear-end ...">...ربما يمكننا العيش بدون مكتبات،</p>
</article>
</Figure>

Disabling clears

Use the clear-none utility to reset any clears that are applied to an element:

<Figure> <Example resizable> { <>
  <p className="text-justify">
    Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but
    what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding
    drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve
    better? Look. If you think this is about overdue fines and missing books, you'd better think again. This is
    about that kid's right to read a book without getting his mind warped! Or: maybe that turns you on, Seinfeld;
    maybe that's how y'get your kicks. You and your good-time buddies.
  </p>
</>

} </Example>

html
<!-- [!code classes:clear-none] -->
<article>
  
  
  <p class="clear-none ...">Maybe we can live without libraries...</p>
</article>
</Figure>

Responsive design

<ResponsiveDesign element="p" property="clear" defaultClass="clear-left" featuredClass="clear-none" />