排版
Utilities for controlling the marker images for list items.
Use the list-image-*
utilities to control the marker image for list items.
Out of the box, list-image-none
is the only available preconfigured list style image utility. And while you can add additional utilities by customizing your theme, you can also use the square bracket notation to generate an arbitrary value on the fly.
<ul class="list-image-[url(checkmark.png)] ...">
<li>5 cups chopped Porcini mushrooms</li>
<!-- ... -->
</ul>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:list-image-[url(checkmark.png)]
to only apply the list-image-[url(checkmark.png)]
utility on hover.
<ul class="list-image-none hover:list-image-[url(checkmark.png)]">
<!-- ... -->
</ul>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:list-image-[url(checkmark.png)]
to apply the list-image-[url(checkmark.png)]
utility at only medium screen sizes and above.
<ul class="list-image-none md:list-image-[url(checkmark.png)]">
<!-- ... -->
</ul>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind only provides the list-image-none
utility. You can customize these values by editing theme.listStyleImage
or theme.extend.listStyleImage
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
listStyleImage: {
checkmark: 'url("/img/checkmark.png")',
},
}
}
}
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off list-style-image
value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<ul class="list-image-[url(checkmark.png)]">
<!-- ... -->
</ul>
Learn more about arbitrary value support in the arbitrary values documentation.