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

IconField: icons do not appear inside the visual input area in Tailwind #7042

Closed
jambudipa opened this issue Aug 13, 2024 · 8 comments · Fixed by #7066 · May be fixed by leoo1992/GeradorQRCode#95
Closed

IconField: icons do not appear inside the visual input area in Tailwind #7042

jambudipa opened this issue Aug 13, 2024 · 8 comments · Fixed by #7066 · May be fixed by leoo1992/GeradorQRCode#95
Assignees
Labels
Component: Tailwind Tailwind specific issue
Milestone

Comments

@jambudipa
Copy link

Describe the bug

I am unable to create a Stackblitz because the imports of primereact/inputicon and primereact/iconfield do not appear to work. I think I need help with that initially!

Screenshot 2024-08-13 at 19 50 19

When using IconField, like this:

return (
  <IconField iconPosition="left">
    <InputIcon>
      <FontAwesomeIcon
        icon={faMagnifyingGlass}
        size={'lg'}
        color={'var(--color-highlight-350)'}
      />
    </InputIcon>
    <InputText v-model="value1" placeholder="Search" />
  </IconField>
);

...the icon is rendered outside the box.

Reproducer

No response

System Information

System:
OS: macOS 15.0
CPU: (20) arm64 Apple M1 Ultra
Memory: 974.88 MB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v20.11.1/bin/yarn
npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
pnpm: 9.4.0 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 127.0.6533.100
Safari: 18.0

Steps to reproduce the behavior

Screenshot 2024-08-13 at 19 51 27

...this will be easier when I can get Stackblitz to work

Expected behavior

Icon appears inside the input area

@jambudipa jambudipa 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 13, 2024
@melloware
Copy link
Member

@jambudipa this should get you started: https://stackblitz.com/edit/1tubmv?file=src%2FApp.tsx

@melloware melloware added Status: Needs Reproducer Issue needs a runnable reproducer 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 13, 2024
Copy link

Please fork the Stackblitz project and create a case demonstrating your bug report. This issue will be closed if no activities in 20 days.

@jambudipa
Copy link
Author

Thank you for that @melloware

I have discovered the problem. It appears there is no tailwind passthrough config for the IconField component. Thus these components are not rendering as per the demo.

Essentially, I copied the tailwind passthrough config from the repo and tweaked it for my own styling:

<PrimeReactProvider value={{ unstyled: true, pt: Tailwind }}>
  <RouterProvider router={router} />
</PrimeReactProvider>

Perhaps this is entirely the wrong approach? Or perhaps the config for this / these components was overlooked for tailwind?

@melloware
Copy link
Member

It sounds like a bug and that it needs to be added to the default TailWind config.

@melloware melloware added Component: Tailwind Tailwind specific issue and removed Status: Needs Reproducer Issue needs a runnable reproducer labels Aug 13, 2024
@melloware melloware changed the title IconField: icons do not appear inside the visual input area IconField: icons do not appear inside the visual input area in Tailwind Aug 13, 2024
@jambudipa
Copy link
Author

Aha ok, thanks. Is there anything I need to do?

@melloware
Copy link
Member

well you can submit a PR if you figure out what Tailwind styles need to be applied?

@jambudipa
Copy link
Author

Ok, well I will take a look, try to reproduce the styles of the demo.

@gcko
Copy link
Contributor

gcko commented Aug 21, 2024

Hey @jambudipa @melloware , I created a PR that should fix the lack of Tailwind styling.

The main issue I found is that IconField works by wrapping other components. This means that context from the parent component needs to be passed in some way so that children can properly render their styling.

@melloware Please look at the method I have implemented and confirm if it works. I am not sure if PrimeReact already has an internal library that handles this case, if it does please LMK and I will refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Tailwind Tailwind specific issue
Projects
None yet
3 participants