Kombai Logo

Tailwind CSS List Style Image

When working with unordered and ordered lists, the list-style-image property in CSS allows you to replace the default bullet or number markers with a custom image. This property comes in handy when designing lists with a custom aesthetic that aligns with a brand's visual guidelines.

In this article, we'll explore the various ways to implement and customize list styles in Tailwind CSS, with step-by-step instructions.

ClassPropertiesExample
list-image-nonelist-style-image: none;<div className="list-image-none"></div>

Overview of List Style Image

Adding the List Style Image

You can use the list-image-* utility classes in Tailwind CSS to assign a custom image to list elements. Tailwind integrates seamlessly with the list-style-image property in to handle custom markers. Here's how to assign an external image as a stylish bullet for a list.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

States and Responsiveness

Hover and Focus States

Tailwind provides state modifiers to conditionally apply custom list markers on states like hover, focus, etc. Here's how to apply custom list marker images:

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Breakpoint Modifiers

Responsive designs require list customizations that adapt to different screen sizes. Tailwind provides you with breakpoint modifiers(sm, md, etc.) to modify the list-style-image property for various devices.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Custom List Style Image

Extending the Theme

To fully integrate custom values, consider modifying Tailwind's theme in the tailwind.config.js file. By extending the theme, you can register custom utilities for the list-style-image property, making it easier to apply consistently across your project.

In the below example, image URL is saved as custom-marker in the theme file. Now, custom marker can be referenced as list-image-custom-marker when needed:

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Arbitrary Values for Flexibility

Use arbitrary values in Tailwind if you need to apply a unique marker that isn't predefined. This approach provides absolute flexibility for one-off designs.

Here, the image URL is passed directly using square brackets. Arbitrary values are especially useful in prototyping or when dealing with unique design specifications.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Real World Examples

Product Features List

A modern product features list using custom image as list markers.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Subscription Benefits

A subscription benefits list of e-commerce platform with custom list image.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Job Requirements

A requirements list of a job listing with custom list image.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Installation Steps

A list of installation steps with custom list image.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Documentation Menu Items

A list of doc menu items with custom list images.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Customization Examples

Nature-themed Checklist

This example creates a nature-themed checklist using leaf images as bullet points.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Tech Documentation Markers

This example uses custom arrow markers for a technical documentation list.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Recipe Ingredients List

This example uses custom food icons for a recipe ingredients list.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Best Practices

Maintain Design Consistency

Extend the Tailwind's theme in tailwind.config.js file to define reusable custom marker styles. For instance, you can create a branded bullet style and apply it uniformly across multiple components. This not only simplifies maintenance but also ensures your list designs remain visually aligned with the rest of your application.

By defining a custom listStyleImage property like primary-icon, you can reference it as a utility class (list-image-primary-icon). This centralizes updates and ensures all instances of the style remain consistent in case of design changes. Always consider the reusability of your markers to avoid unnecessary redundancy.

Balance with Other Layout Properties

Ensuring that list-style-* integrates well with other layout properties prevents unexpected design inconsistencies. For instance, combining list-inside with leading-relaxed creates a visually appealing list format by managing spacing between list items while keeping markers properly aligned with the text.

If working with flex or grid-based layouts, lists should be structured to complement surrounding elements. Additionally, use responsive padding (e.g., sm:pl-3 md:pl-6, etc.) to ensure that list items remain properly spaced and visually distinct across different screen sizes.

Accessibility Considerations

Enhance Readability and Navigability

One of the key considerations when using list-style-image is ensuring that it does not disrupt the logical reading order. By carefully selecting appropriate marker images and combining them with Tailwind’s list-inside utility, you can maintain a structured and accessible layout.

The list-inside ensures that list markers remain within the text flow rather than appearing outside the content block, which can be particularly helpful for screen reader users. Additionally, pairing this utility with appropriate spacing values to control the spacing between list items, preventing them from appearing cluttered or difficult to follow.

Focus on High Contrast

When using list style image, ensure high contrast between list markers and text to maintain readability. Low-contrast markers can blend into the background, making it difficult for users to distinguish individual list items.

One way to achieve high contrast is by choosing list images with distinct colors that stand out against the background. If your list items use a light background, opt for dark or bold-colored markers, and vice versa. Tailwind’s utility classes like invert, brightness-*, and contrast-* can be applied to refine the appearance of custom list markers. These adjustments ensure that markers maintain sufficient visibility even under different UI themes, including dark mode.