「及時」模式:全新世代的 Tailwind CSS
Tailwind CSS on GitHub

List Style Type

Utilities for controlling the bullet/number style of a list.

Default class reference

Class
屬性
list-nonelist-style-type: none;
list-disclist-style-type: disc;
list-decimallist-style-type: decimal;

Usage

To create bulleted or numeric lists, use the list-disc and list-decimal utilities.

.list-disc

  • Lorem ipsum dolor sit amet, consectetur adipisicing elit
  • Assumenda, quia temporibus eveniet a libero incidunt suscipit
  • Quidem, ipsam illum quis sed voluptatum quae eum fugit earum

.list-decimal

  1. Lorem ipsum dolor sit amet, consectetur adipisicing elit
  2. Assumenda, quia temporibus eveniet a libero incidunt suscipit
  3. Quidem, ipsam illum quis sed voluptatum quae eum fugit earum

.list-none (default)

  • Lorem ipsum dolor sit amet, consectetur adipisicing elit
  • Assumenda, quia temporibus eveniet a libero incidunt suscipit
  • Quidem, ipsam illum quis sed voluptatum quae eum fugit earum

<ul class="list-disc">
  <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit</li>
  ...
</ul>

<ol class="list-decimal">
  <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit</li>
  ...
</ol>

<ul>
  <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit</li>
  ...
</ul>

Responsive

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

<ul class="list-none md:list-disc">
  <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit</li>
  <li>Assumenda, quia temporibus eveniet a libero incidunt suscipit</li>
  <li>Quidem, ipsam illum quis sed voluptatum quae eum fugit earum</li>
</ul>

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

Customizing

By default, Tailwind provides three utilities for the most common list style types. You change, add, or remove these by editing the theme.listStyleType section of your Tailwind config.

  // tailwind.config.js
  module.exports = {
    theme: {
      listStyleType: {
        none: 'none',
-       disc: 'disc',
-       decimal: 'decimal',
+       square: 'square',
+       roman: 'upper-roman',
      }
    }
  }

Variants

默認情況下, 只有 響應式 的 list style type 變化模式 (variants) 會產生。

tailwind.config.jsvariants 區塊中變更 listStyleType 屬性來決定有哪些變化模式會生成。

舉個例子來說,這個設定將會生成 響應式 和 hover 的變化模式。

  // tailwind.config.js
  module.exports = {
    variants: {
      extend: {
        // ...
+       listStyleType: ['responsive', 'hover'],
      }
    }
  }

Disabling

如果你不打算在專案中使用 list style type 功能,可以在你的設定檔裡的 corePlugins 屬性中將 listStyleType 設定為 false 來停用功能:

  // tailwind.config.js
  module.exports = {
    corePlugins: {
      // ...
+     listStyleType: false,
    }
  }