How

list-inside list-disc whitespace-normal [li&]:pl-6

This article explains what the Tailwind CSS utility-like class string list-inside list-disc whitespace-normal [li&]:pl-6 does, why you might use it, and how to apply it effectively in your projects.

What each part does

  • list-inside: Places list markers (bullets) inside the content box of each list item so markers are part of the flow and wrap with the text.
  • list-disc: Uses a filled circle (disc) as the list marker.
  • whitespace-normal: Ensures normal whitespace handling lines wrap at whitespace and sequences of whitespace collapse.
  • [li&]:pl-6: A bracketed arbitrary variant targeting each li element (the current selector & prepended by li) and applying pl-6 (padding-left: 1.5rem). This increases left padding on list items while using an arbitrary variant to scope the padding specifically to li elements.

Why combine these

  • Putting bullets inside (list-inside) keeps markers aligned with wrapped text, which is useful for compact layouts or when you want bullets to follow the same left edge as the text.
  • list-disc gives a commonly recognized bullet style.
  • whitespace-normal avoids unexpected nowrap behavior that could otherwise prevent bullets from wrapping cleanly.
  • The arbitrary variant [li&]:pl-6 is a targeted way to add consistent indentation to list items without affecting the list container or needing extra utility classes on each li.

Practical examples

    &]:pl-6” data-streamdown=“ordered-list”>

  1. Basic HTML with Tailwind (assumes Tailwind configured to allow arbitrary variants):
html
<ul class=“list-inside list-disc whitespace-normal [li&]:pl-6”><li>Short item</li>  <li>Long item that wraps onto multiple lines to demonstrate how the bullet stays inside and the text maintains consistent indentation across wrapped lines.</li>  <li>Another item</li></ul>
    &]:pl-6” data-streamdown=“ordered-list” start=“2”>

  1. When to prefer list-inside vs list-outside:
  • Use list-inside when you want bullets to flow with text and wrap naturally.
  • Use list-outside when you need bullets visually separated in the margin (common for traditional typographic layouts).

Accessibility and layout notes

  • Ensure sufficient contrast between bullets and background; Tailwind’s text color utilities can adjust this.
  • If using custom indentation, verify focus outlines and keyboard navigation visual cues remain clear.
  • Test wrapping behavior at various viewport widths to ensure readability.

Troubleshooting

  • If the arbitrary variant [li&]:pl-6 doesn’t apply, confirm Tailwind’s JIT mode and that arbitrary variants are enabled in your config.
  • If bullets appear misaligned, check for conflicting padding/margin utilities on parent elements or on li itself.

Summary

list-inside list-disc whitespace-normal [li&]:pl-6 is a concise Tailwind-style utility combination to create wrapped, indented bullet lists with predictable whitespace behavior, all by targeting padding specifically to list items using an arbitrary variant._

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *