Skip to content

Tailwind Forms breaks appearance-none class #160

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

Closed
ben519 opened this issue Aug 6, 2024 · 5 comments
Closed

Tailwind Forms breaks appearance-none class #160

ben519 opened this issue Aug 6, 2024 · 5 comments

Comments

@ben519
Copy link

ben519 commented Aug 6, 2024

What version of @tailwindcss/forms are you using?

0.5.7

What version of Node.js are you using?

20.9.0

What browser are you using?

Chrome

What operating system are you using?

macOS

Reproduction repository

https://github.com/ben519/tailwind-select-bug

Describe your issue

I'm using the <Select> component from Catalyst. It includes the appearance-none class.

Without Tailwind Forms Plugin

Without the tailwind forms plugin, things work as expected.

// tailwind.config.js

const headlessuiPlugin = require('@headlessui/tailwindcss')

const config = {
  content: [
    './src/pages/**/*.{js,ts,jsx,tsx,mdx}',
    './src/components/**/*.{js,ts,jsx,tsx,mdx}',
    './src/app/**/*.{js,ts,jsx,tsx,mdx}',
  ],
  theme: {
    extend: {
      fontFamily: {
        sans: ['Inter, sans-serif', { fontFeatureSettings: '"cv11"' }],
      },
    },
  },
  plugins: [headlessuiPlugin],
}
/** @type {import('tailwindcss').Config} */
module.exports = config
Screenshot 2024-08-05 at 9 00 29 PM

With Tailwind Forms Plugin

With the tailwind forms plugin, the down chevron reappears.

// tailwind.config.js

const headlessuiPlugin = require('@headlessui/tailwindcss')
const formsPlugin = require('@tailwindcss/forms')

const config = {
  content: [
    './src/pages/**/*.{js,ts,jsx,tsx,mdx}',
    './src/components/**/*.{js,ts,jsx,tsx,mdx}',
    './src/app/**/*.{js,ts,jsx,tsx,mdx}',
  ],
  theme: {
    extend: {
      fontFamily: {
        sans: ['Inter, sans-serif', { fontFeatureSettings: '"cv11"' }],
      },
    },
  },
  plugins: [headlessuiPlugin, formsPlugin],
}
/** @type {import('tailwindcss').Config} */
module.exports = config
Screenshot 2024-08-05 at 9 01 51 PM
@adamwathan
Copy link
Member

Hey! The forms plugin adds opinionated styles to form elements, including adding a background-image to add a custom chevron to <select> elements. If you look at the styles, the forms plugin actually already applies appearance: none to the <select> element to remove the default icon and replace it with a custom one.

If you want to remove the custom chevron when using the forms plugin on a per-element basis, you have two options:

  1. Use the class strategy so form styles are opt-in, then you don't have to undo any form styles, instead you just don't add the class.
  2. Use the bg-none class to remove the background image.

Most importantly though you should not use the @tailwindcss/forms plugin with Catalyst, it will create conflicts. Catalyst already comes with its own form styles applied to each component, and doesn't depend on that plugin to work.

Hope that helps!

@ben519
Copy link
Author

ben519 commented Aug 6, 2024

Most importantly though you should not use the @tailwindcss/forms plugin with Catalyst

Ah, this is what I missed. Thanks!

FYI, this came about because I was trying to add Catalyst to the Pocket template. In other words, I didn't exactly add the the @tailwindcss/forms plugin; it was already baked into the template. I assume I'm not the only person making this error.

@adamwathan
Copy link
Member

@ben519 Ah that's good to know! Maybe we can update the Pocket template to not depend on the forms plugin then, I don't think there's much going on in that template that really would use it.

@ben519
Copy link
Author

ben519 commented Sep 1, 2024

@adamwathan More victims here and here 😆

@adamwathan
Copy link
Member

adamwathan commented Sep 1, 2024

@adamwathan More victims here and here 😆

Nah those people just forgot to install the forms plugin. (I'm wrong!)

Yep 😄

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