src/docs/text-overflow.mdx
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"; import dedent from "dedent";
export const title = "text-overflow"; export const description = "Utilities for controlling how the text of an element overflows.";
<ApiTable
rows={[
[
"truncate",
dedent overflow: hidden; text-overflow: ellipsis; white-space: nowrap; ,
],
["text-ellipsis", "text-overflow: ellipsis;"],
["text-clip", "text-overflow: clip;"],
]}
/>
Use the truncate utility to prevent text from wrapping and truncate overflowing text with an ellipsis (…) if needed:
<!-- [!code classes:truncate] -->
<p class="truncate">The longest word in any of the major...</p>
Use the text-ellipsis utility to truncate overflowing text with an ellipsis (…) if needed:
<!-- [!code classes:text-ellipsis] -->
<p class="overflow-hidden text-ellipsis">The longest word in any of the major...</p>
Use the text-clip utility to truncate the text at the limit of the content area:
<!-- [!code classes:text-clip] -->
<p class="overflow-hidden text-clip">The longest word in any of the major...</p>
This is the default browser behavior.