list-inside list-disc whitespace-normal [li&]:pl-6
This article explains the Tailwind CSS utility combination list-inside list-disc whitespace-normal [li&]:pl-6, what each part does, when to use it, and practical examples.
What this combination means
- list-inside — Positions list markers (bullets) inside the content flow so the bullet sits within the element’s padding and is aligned with the text.
- list-disc — Uses a filled circle (disc) as the list marker.
- whitespace-normal — Allows text to wrap normally; collapses consecutive whitespace and breaks lines at normal wrapping points.
- [li&]:pl-6 — A Tailwind arbitrary selector that targets child
lielements and appliespadding-left: 1.5rem(pl-6) to eachli. The selector syntax[li&]scopes the rule so it generates CSS likeli .your-classdepending on context; in this case it ensures padding is applied to list items.
Why use this combination
- Keeps bullets visually aligned with wrapped text while adding extra left padding to list items for better spacing.
- Ensures long list items wrap normally without preserving extra whitespace.
- Useful for lists inside cards, sidebars, or any component where you want compact bullets but clearer indentation on each item.
When to avoid it
- If you need hanging bullets (marker outside the text block), use
list-outsideinstead. - If you require precise control across browsers for marker positioning, consider custom CSS with ::marker and padding/margin adjustments.
Example HTML
html
<ul class=“list-inside list-disc whitespace-normal [li&]:pl-6”><li>Short item</li> <li>Long item that will wrap across multiple lines to demonstrate how the bullet aligns with wrapped text and how additional left padding improves readability.</li> <li>Another item</li></ul>
Notes and compatibility
- &]:pl-6” data-streamdown=“unordered-list”>
- Modern Tailwind versions support arbitrary selectors; ensure your Tailwind config allows them.
- Browser support for list marker positioning and ::marker is broad, but behavior can vary slightly; test in target browsers.
- If
[li&]:pl-6doesn’t produce the expected selector in your build, try alternative selectors likeli:pl-6within a component scope or add a custom CSS rule.
Quick tips
- &]:pl-6” data-streamdown=“unordered-list”>
- Combine with
space-y-2on the parent to add vertical spacing between items. - Use
marker:text-muted-600(Tailwind plugin or custom variable) to style the bullet color when supported. - For accessible lists, ensure clear contrast and readable line length
This combination balances compact markers with readable indentation, making lists clearer in dense UI layouts.
Leave a Reply