Skip to content

[bug]: shimmer's prefers-reduced-motion override doesn't work with a Tailwind prefix #11363

Description

@Gallevy

Describe the bug

packages/shadcn/src/tailwind.css defines the shimmer utility twice, in two different ways:

  1. Via @utility shimmer { ... }, which Tailwind compiles and correctly respects a configured prefix() (e.g. prefix(tw).tw\:shimmer).
  2. Via a hand-written, non-Tailwind selector at the bottom of the file that disables the animation for accessibility:
@media (prefers-reduced-motion: reduce) {
  .shimmer {
    animation: none;
    background-image: none;
    -webkit-text-fill-color: currentColor;
  }
}

Because rule 2 is plain CSS and not generated through @utility, it is never rewritten by the prefixer. If a project configures a Tailwind prefix, the element actually renders with .tw\:shimmer (or whatever prefix is set), but the reduced-motion override still targets .shimmer and never matches. Result: prefers-reduced-motion: reduce silently stops disabling the shimmer animation for anyone using a prefix.

Reference:

@media (prefers-reduced-motion: reduce) {
.shimmer {
animation: none;
background-image: none;
-webkit-text-fill-color: currentColor;
}

Affected component/components

Shimmer

How to reproduce

  1. Configure a Tailwind v4 prefix, e.g. @import "tailwindcss" prefix(tw);
  2. Apply tw:shimmer to an element.
  3. Enable "reduce motion" in the OS/browser.
  4. The shimmer animation keeps running instead of being disabled — the generated class is .tw\:shimmer, but the reduced-motion rule only targets the unprefixed .shimmer.

Suggested fix

Move the reduced-motion rule inside the existing @utility shimmer { ... } block (same pattern already used there for @variant dark { ... }) instead of as a separate hardcoded selector, so it's compiled by Tailwind and inherits the prefix automatically:

@utility shimmer {
  ...
  @media (prefers-reduced-motion: reduce) {
    animation: none;
    background-image: none;
    -webkit-text-fill-color: currentColor;
  }
}

I've verified this reproduces against the pinned commit above and will open a PR with this fix.

Codesandbox/StackBlitz link

No response

Logs

System Info

Tailwind CSS v4, prefix() option configured

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions