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

Styling an existing component doesn't seem to work in twin.macro/react-twc #248

Open
pksunkara opened this issue Feb 10, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@pksunkara
Copy link

pksunkara commented Feb 10, 2024

What version of prettier-plugin-tailwindcss are you using?

For example: v0.5.3

What version of Tailwind CSS are you using?

For example: v3.4.1

What version of Node.js are you using?

For example: v18.0.0

What package manager are you using?

For example: pnpm

What operating system are you using?

For example: Linux

Reproduction URL

.prettierrc.js

module.exports = {
  plugins: [require('prettier-plugin-tailwindcss')],
  tailwindFunctions: ['tw']
};

Example.tsx

const Btn1 = tw(Button)`border p-1 bg-pink-100`;

const Btn2 = tw(Button).attrs({
  size: 'small',
})`border p-1 bg-pink-100`;

const Btn3 = tw(Button)<React.ComponentProps<typeof Button>>`border p-1 bg-pink-100`;

Describe your issue

Both twin.macro and react-twc allows styling an existing component using the above syntax.

Prettier plugin is not sorting the classes in those syntax usages.

@pksunkara
Copy link
Author

Also, the following doesn't seem to work too:

const Box1 = tw.div.attrs({
  onClick: () => console.log('clicked'),
})`border p-1 border-red-600 bg-slate-100`;

const Anchor = tw.a.attrs<AnchorProps>((props) => {})`p-1 border-2 border-blue-500 bg-white`;

@thecrypticace thecrypticace added the enhancement New feature or request label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants