Problem: Long scrolling tables.
Solution#
<div class="max-h-96 overflow-auto rounded-xl border">
<table class="w-full text-sm">
<thead class="sticky top-0 bg-white"><tr><th class="border-b px-4 py-2 text-left">Col</th></tr></thead>
<tbody class="divide-y">rows…</tbody>
</table>
</div>Why this works#
Sticky thead inside a scroll container.
Variants#
- Responsive: add screen prefixes to the core classes
- Dark: pair each color utility with its dark: twin
- Animated: add
transition+ a state variant for motion
Related recipes#
cookbook/index|Cookbook index · utilities/index|Utilities reference · patterns/index|Layout patterns
