<button class="
rounded-lg border-outline-subtle bg-container state-button p-4 text-start
hover:on-bg-on-surface/hover active:on-bg-on-surface/active
">
Last active
October 12, 2025 12:19
-
-
Save janispritzkau/589e2d7961d7ebb2b21886ac6dc9c489 to your computer and use it in GitHub Desktop.
`on-bg` utility for Tailwind CSS emulating Material 3 state layers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @utility on-bg-* { | |
| --tw-gradient-to: --value(--on-bg-color-*, --color-*, [*]); | |
| --tw-gradient-to: color-mix( | |
| in srgb, | |
| --modifier(--on-bg-opacity-*, [*]) --value(--on-bg-color-*, --color-*, [*]), | |
| transparent | |
| ); | |
| --tw-gradient-to: color-mix( | |
| in srgb, | |
| calc(--modifier(integer) * 1%) --value(--on-bg-color-*, --color-*, [*]), | |
| transparent | |
| ); | |
| background-image: linear-gradient(var(--tw-gradient-to) 0 0); | |
| } | |
| @utility state-button { | |
| @apply on-bg-transparent transition-colors active:duration-75 active:ease-out; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment