filter

Các tiện ích để áp dụng bộ lọc cho một phần tử.

ClassStyles
filter-none
filter: none;
filter-(<custom-property>)
filter: var(<custom-property>);
filter-[<value>]
filter: <value>;

Ví dụ

Ví dụ cơ bản

Sử dụng các tiện ích như blur-xsgrayscale để áp dụng các bộ lọc cho một phần tử:

blur-xs

grayscale

combined

<img class="blur-xs" src="/img/mountains.jpg" /><img class="grayscale" src="/img/mountains.jpg" /><img class="blur-xs grayscale" src="/img/mountains.jpg" />

Bạn có thể kết hợp các tiện ích bộ lọc sau: blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, saturate, và sepia.

Loại bỏ bộ lọc

Sử dụng tiện ích filter-none để loại bỏ tất cả các bộ lọc được áp dụng cho một phần tử:

<img class="blur-md brightness-150 invert md:filter-none" src="/img/mountains.jpg" />

Sử dụng giá trị tùy chỉnh

Use the filter-[<value>] syntax to set the filter based on a completely custom value:

<img class="filter-[url('filters.svg#filter-id')] ..." src="/img/mountains.jpg" />

For CSS variables, you can also use the filter-(<custom-property>) syntax:

<img class="filter-(--my-filter) ..." src="/img/mountains.jpg" />

This is just a shorthand for filter-[var(<custom-property>)] that adds the var() function for you automatically.

Áp dụng khi hover

Prefix a filter utility with a variant like hover:* to only apply the utility in that state:

<img class="blur-sm hover:filter-none ..." src="/img/mountains.jpg" />

Learn more about using variants in the variants documentation.

Responsive design

Prefix a filter utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

<img class="blur-sm md:filter-none ..." src="/img/mountains.jpg" />

Learn more about using variants in the variants documentation.

Copyright © 2025 Tailwind Labs Inc.·Chính sách thương hiệu