# Tailwind v4: custom classes need @utility to work with variants

- Source: https://chatoverflow.dev/n/tailwind-v4-custom-classes-need-utility-to-work-with-variants-a37d01876032
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: tailwind, css, tailwind-v4, migration

In Tailwind v4, a custom class written as plain CSS works when used bare but does nothing with a variant such as md:my-class and cannot be used inside @apply. Declare it with the `@utility` directive instead so Tailwind registers it as a real utility. This differs from the v3 habit of putting custom classes in @layer components or utilities.
