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

Tailwind: RadioButton appearing without style #7013

Closed
Neosoulink opened this issue Aug 9, 2024 · 12 comments · Fixed by #7047
Closed

Tailwind: RadioButton appearing without style #7013

Neosoulink opened this issue Aug 9, 2024 · 12 comments · Fixed by #7047
Assignees
Labels
Component: Tailwind Tailwind specific issue good first issue *** Welcome to PrimeReact Family! *** Good issue!
Milestone

Comments

@Neosoulink
Copy link

Neosoulink commented Aug 9, 2024

Describe the bug

Using the latest version of PrimeReact and wanting to use the RadioButton component, I realized that it was returning a default native radio button, unstyled. (see the screenshot)

Screenshot 2024-08-09 at 1 58 46 PM.

This error behavior is happening on version 10.6.x and higher

Reproducer

https://stackblitz.com/edit/u8l8sa?file=src%2FApp.jsx

System Information

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    primereact: latest => 10.8.2 
    react: 18.3.1 => 18.3.1

Steps to reproduce the behavior

I forked the official example and even there it's not working

-> https://stackblitz.com/edit/u8l8sa?file=src%2FApp.jsx

Expected behavior

No response

@Neosoulink Neosoulink added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Aug 9, 2024
@melloware
Copy link
Member

Ahh its working fine with PR theme: https://primereact.org/radiobutton/ Its the TailWind theme that is incorrect.

I will mark this ticket as Tailwind related.

@melloware melloware added Component: Tailwind Tailwind specific issue and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Aug 9, 2024
@melloware melloware changed the title Radio_Button: component appearing without style Tailwind: RadioButton appearing without style Aug 9, 2024
@melloware melloware added the good first issue *** Welcome to PrimeReact Family! *** Good issue! label Aug 9, 2024
@Neosoulink
Copy link
Author

Neosoulink commented Aug 9, 2024

Hum... I'm not sure, but I tried to remove all the styling and style getting the same behavior, is it really Tailwind?

As I mentioned, it's working fine on version 10.5.0

cc: @melloware

@melloware
Copy link
Member

Yes see showcase with a PR theme it works fine: https://primereact.org/radiobutton/ fully themed so something in the TailWind theme is not right.

@melloware
Copy link
Member

AS a note after 10.5.0 the RadioButton was updated and the PR themes were updated but it looks like the TailWind theme was not. I am not a Tailwind guy so a PR is welcome for anyone that wants to figure it out!

@melloware
Copy link
Member

It actually the same as this Checkbox issue and Tailwind: #6423

Checkbox was fixed but Radiobutton wasn't if you want to look at that PR?

@melloware
Copy link
Member

cc @gcko

@Neosoulink
Copy link
Author

Neosoulink commented Aug 9, 2024

Yes It looks quite similar to #6423

And gcko's PR fix was mostly about adding classNames helper to the InputSwitch and CheckBox themes:

-  className: ['cursor-pointer inline-flex relative select-none align-bottom', 'w-6 h-6']
+  className: classNames('cursor-pointer inline-flex relative select-none align-bottom', 'w-6 h-6')

See https://github.com/primefaces/primereact/pull/6347/files#diff-db4f40d8ec882af74250a17beef920a061ae24422330815b84ac128b27761e0aL8-R17

However, the current RadioButton already uses the classNames helper...

radiobutton: ({ context }) => ({
  className: classNames(
    'flex justify-center items-center',
    'border-2 w-6 h-6 text-gray-700 rounded-full transition duration-200 ease-in-out',
    context.checked
      ? 'border-blue-500 bg-blue-500 dark:border-blue-400 dark:bg-blue-400'
      : 'border-gray-300 bg-white dark:border-blue-900/40 dark:bg-gray-900',
    {
      'hover:border-blue-500 dark:hover:border-blue-400 focus:outline-none focus:outline-offset-0 focus:shadow-[0_0_0_0.2rem_rgba(191,219,254,1)] dark:focus:shadow-[inset_0_0_0_0.2rem_rgba(147,197,253,0.5)]': !context.disabled,
      'cursor-default opacity-60': context.disabled
    }
  )
}),

See https://github.com/primefaces/primereact/blob/master/components/doc/radiobutton/theming/tailwinddoc.js#L9

But the checkbox is working on the latest version
Screenshot 2024-08-09 at 3 56 18 PM

@melloware
Copy link
Member

If you look he also added an input section to the Checkbox i believe.

@Neosoulink
Copy link
Author

Yes he did:

input: {
  className: classNames('absolute appearance-none top-0 left-0 size-full p-0 m-0 opacity-0 z-10 outline-none cursor-pointer')
},

@Neosoulink
Copy link
Author

But no matter the changes I'm making, I'm still not able to apply a custom style to the RadioButton in the latest version of Primereact

@melloware
Copy link
Member

@gcko can you take a look at this since you are familiar with Tailwind and the PR structures?

@gcko
Copy link
Contributor

gcko commented Aug 14, 2024

sure i'll take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Tailwind Tailwind specific issue good first issue *** Welcome to PrimeReact Family! *** Good issue!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants