List Style Position

Utilities for controlling the position of bullets/numbers in lists.

Class reference

ClassProperties
.list-insidelist-style-position: inside;
.list-outsidelist-style-position: outside;

Usage

Control the position of the markers in a list using the list-inside and list-outside utilities.

List Style Position - 图1

  1. <ul class="list-inside bg-gray-200 ...">
  2. <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit</li>
  3. ...
  4. </ul>
  5. <ul class="list-outside bg-gray-200 ...">
  6. <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit</li>
  7. ...
  8. </ul>

Responsive

To control the list style position of a list element at a specific breakpoint, add a {screen}: prefix to any existing list utility. For example, use .md:list-inside to apply the .list-inside utility at only medium screen sizes and above.

For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.

  1. <ul class="list-inside sm:list-outside md:list-inside lg:list-outside xl:list-inside">
  2. <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit</li>
  3. <li>Assumenda, quia temporibus eveniet a libero incidunt suscipit</li>
  4. <li>Quidem, ipsam illum quis sed voluptatum quae eum fugit earum</li>
  5. </ul>

List Style Position - 图2

Customizing

Responsive and pseudo-class variants

By default, only responsive variants are generated for list style position utilities.

You can control which variants are generated for the list style position utilities by modifying the listStylePosition property in the variants section of your tailwind.config.js file.

For example, this config will also generate hover and focus variants:

  1. // tailwind.config.js
  2. module.exports = {
  3. variants: {
  4. // ...
  5. - listStylePosition: ['responsive'],
  6. + listStylePosition: ['responsive', 'hover', 'focus'],
  7. }
  8. }

Disabling

If you don’t plan to use the list style position utilities in your project, you can disable them entirely by setting the listStylePosition property to false in the corePlugins section of your config file:

  1. // tailwind.config.js
  2. module.exports = {
  3. corePlugins: {
  4. // ...
  5. + listStylePosition: false,
  6. }
  7. }