Back to Tailwindcss

Filter Hue Rotate

src/docs/filter-hue-rotate.mdx

latest7.0 KB
Original Source

import { ApiTable } from "@/components/api-table.tsx"; import { Example } from "@/components/example.tsx"; import { Figure } from "@/components/figure.tsx"; import { ResponsiveDesign, UsingACustomValue } from "@/components/content.tsx";

export const title = "filter: hue-rotate()"; export const description = "Utilities for applying hue-rotate filters to an element.";

<ApiTable rows={[ ["hue-rotate-<number>", "filter: hue-rotate(<number>deg);"], ["-hue-rotate-<number>", "filter: hue-rotate(calc(<number>deg * -1));"], ["hue-rotate-(<custom-property>)", "filter: hue-rotate(var(<custom-property>));"], ["hue-rotate-[<value>]", "filter: hue-rotate(<value>);"], ]} />

Examples

Basic example

Use utilities like hue-rotate-90 and hue-rotate-180 to rotate the hue of an element by degrees:

<Figure> <Example padding={false}> { <div className="flex scroll-p-8 justify-start overflow-scroll sm:block sm:overflow-visible"> <div className="flex shrink-0 items-center justify-around gap-6 p-8 font-mono font-bold sm:gap-4"> <div className="flex shrink-0 flex-col items-center"> <p className="mb-3 text-center font-mono text-xs font-medium text-gray-500 dark:text-gray-400"> hue-rotate-15 </p> <div className="relative hue-rotate-15">
        <div className="absolute inset-0 rounded-lg ring-1 ring-black/10 ring-inset"></div>
      </div>
    </div>
    <div className="flex shrink-0 flex-col items-center">
      <p className="mb-3 text-center font-mono text-xs font-medium text-gray-500 dark:text-gray-400">
        hue-rotate-90
      </p>
      <div className="relative hue-rotate-90">
        
        <div className="absolute inset-0 rounded-lg ring-1 ring-black/10 ring-inset"></div>
      </div>
    </div>
    <div className="flex shrink-0 flex-col items-center">
      <p className="mb-3 text-center font-mono text-xs font-medium text-gray-500 dark:text-gray-400">
        hue-rotate-180
      </p>
      <div className="relative hue-rotate-180">
        
        <div className="absolute inset-0 rounded-lg ring-1 ring-black/10 ring-inset"></div>
      </div>
    </div>
    <div className="flex shrink-0 flex-col items-center">
      <p className="mb-3 text-center font-mono text-xs font-medium text-gray-500 dark:text-gray-400">
        hue-rotate-270
      </p>
      <div className="relative hue-rotate-270">
        
        <div className="absolute inset-0 rounded-lg ring-1 ring-black/10 ring-inset"></div>
      </div>
    </div>
  </div>
</div>

} </Example>

html
<!-- [!code classes:hue-rotate-15,hue-rotate-90,hue-rotate-180,hue-rotate-270] -->




</Figure>

Using negative values

Use utilities like -hue-rotate-15 and -hue-rotate-45 to set a negative hue rotate value:

<Figure> <Example padding={false}> { <div className="flex scroll-p-8 justify-start overflow-scroll sm:block sm:overflow-visible"> <div className="flex shrink-0 items-center justify-around gap-6 p-8 font-mono font-bold sm:gap-4"> <div className="flex shrink-0 flex-col items-center"> <p className="mb-3 text-center font-mono text-xs font-medium text-gray-500 dark:text-gray-400"> -hue-rotate-15 </p> <div className="relative -hue-rotate-15">
        <div className="absolute inset-0 rounded-lg ring-1 ring-black/10 ring-inset"></div>
      </div>
    </div>
    <div className="flex shrink-0 flex-col items-center">
      <p className="mb-3 text-center font-mono text-xs font-medium text-gray-500 dark:text-gray-400">
        -hue-rotate-45
      </p>
      <div className="relative -hue-rotate-45">
        
        <div className="absolute inset-0 rounded-lg ring-1 ring-black/10 ring-inset"></div>
      </div>
    </div>
    <div className="flex shrink-0 flex-col items-center">
      <p className="mb-3 text-center font-mono text-xs font-medium text-gray-500 dark:text-gray-400">
        -hue-rotate-90
      </p>
      <div className="relative -hue-rotate-90">
        
        <div className="absolute inset-0 rounded-lg ring-1 ring-black/10 ring-inset"></div>
      </div>
    </div>
  </div>
</div>

} </Example>

html
<!-- [!code classes:-hue-rotate-15,-hue-rotate-45,-hue-rotate-90] -->



</Figure>

Using a custom value

<UsingACustomValue element="img" elementAttributes={{ src: "/img/mountains.jpg" }} utility="hue-rotate" value="3.142rad" name="hue rotation" />

Responsive design

<ResponsiveDesign element="img" elementAttributes={{ src: "/img/mountains.jpg" }} property="filter: hue-rotate()" defaultClass="hue-rotate-60" featuredClass="hue-rotate-0" />