Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deactivate :hover classes for the switch component on small screens #3

Closed
Lcarv20 opened this issue May 6, 2024 · 1 comment
Closed

Comments

@Lcarv20
Copy link
Contributor

Lcarv20 commented May 6, 2024

the switch component stays stretched after pressing when deactivated.
the fix should be something like:

pub fn sm() -> Attribute(a) {
  class(
-    "[&+div]:text-sm [&+div]:w-9 [&+div]:h-5 [&+div]:after:h-4 [&+div]:after:w-4 [&:enabled+div]:hover:after:w-5 [&:checked:enabled+div]:hover:after:w-4",
+    "[&+div]:text-sm [&+div]:w-9 [&+div]:h-5 [&+div]:after:h-4 [&+div]:after:w-4 lg:[&:enabled+div]:hover:after:w-5 lg:[&:checked:enabled+div]:hover:after:w-4",

  )
}

pub fn md() -> Attribute(a) {
  class(
-    "[&+div]:text-md [&+div]:w-11 [&+div]:h-6 [&+div]:after:h-5 [&+div]:after:w-5 [&:enabled+div]:hover:after:w-6 [&:checked:enabled+div]:hover:after:w-5",
+    "[&+div]:text-md [&+div]:w-11 [&+div]:h-6 [&+div]:after:h-5 [&+div]:after:w-5 lg:[&:enabled+div]:hover:after:w-6 lg:[&:checked:enabled+div]:hover:after:w-5",

  )
}

pub fn lg() -> Attribute(a) {
  class(
-    "[&+div]:text-lg [&+div]:w-[3.25rem] [&+div]:h-7 [&+div]:after:h-6 [&+div]:after:w-6 [&:enabled+div]:hover:after:w-7 [&:checked:enabled+div]:hover:after:w-6",
+    "[&+div]:text-lg [&+div]:w-[3.25rem] [&+div]:h-7 [&+div]:after:h-6 [&+div]:after:w-6 lg:[&:enabled+div]:hover:after:w-7 lg:[&:checked:enabled+div]:hover:after:w-6",
  )
}
@MAHcodes
Copy link
Owner

The size of a screen doesn't necessarily determine whether it's touch-enabled. This issue will be automatically fixed in TailwindCSS v4 (discussed here: tailwindlabs/tailwindcss#8394). In the meantime, you can enable this behavior with the hoverOnlyWhenSupported future flag:

// tailwind.config.js
module.exports = {
  future: {
    hoverOnlyWhenSupported: true,
  },
  // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants