Skip to content

Commit 6d93f2d

Browse files
Add overflow-clip documentation example
Add dedicated example section demonstrating the overflow-clip utility, showing the visual difference from overflow-hidden and explaining the performance benefits. Fixes #2246
1 parent 7871a7b commit 6d93f2d

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/docs/overflow.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,38 @@ Use the `overflow-hidden` utility to clip any content within an element that ove
9191

9292
</Figure>
9393

94+
### Clipping content that overflows
95+
96+
Use the `overflow-clip` utility to clip any content within an element that overflows the bounds of that element:
97+
98+
<Figure>
99+
100+
<Example>
101+
{
102+
<div className="relative mx-auto flex max-w-sm items-center gap-6 overflow-clip rounded-xl bg-white shadow-lg ring-1 ring-black/5 dark:bg-gray-800">
103+
<img
104+
className="absolute -left-6 h-24 w-24 rounded-full shadow-lg"
105+
src="https://images.unsplash.com/photo-1501196354995-cbb51c65aaea?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=4&w=256&h=256&q=80"
106+
/>
107+
<div className="flex flex-col py-5 pl-24">
108+
<strong className="text-sm font-medium text-gray-900 dark:text-gray-200">Andrew Alfred</strong>
109+
<span className="text-sm font-medium text-gray-500 dark:text-gray-400">Technical advisor</span>
110+
</div>
111+
</div>
112+
}
113+
</Example>
114+
115+
```html
116+
<!-- [!code classes:overflow-clip] -->
117+
<div class="overflow-clip ...">
118+
<!-- ... -->
119+
</div>
120+
```
121+
122+
</Figure>
123+
124+
Unlike `overflow-hidden`, `overflow-clip` doesn't create a new formatting context and may offer better performance in some cases.
125+
94126
### Scrolling if needed
95127

96128
Use the `overflow-auto` utility to add scrollbars to an element in the event that its content overflows the bounds of that element:

0 commit comments

Comments
 (0)