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

Buttons Icons don't respect styles #2615

Open
2 of 6 tasks
JavanPoirier opened this issue Dec 2, 2024 · 3 comments
Open
2 of 6 tasks

Buttons Icons don't respect styles #2615

JavanPoirier opened this issue Dec 2, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@JavanPoirier
Copy link

JavanPoirier commented Dec 2, 2024

Description

Icon sizing and styling issue

CodeSandbox/Snack link

none

Steps to reproduce

Updated this ticket to cover more styling issues with button icons. The Icon does not take the configured styling, and only works if specified on the component:

image

Original related issue:

Related bug: #1821

The workaround is to use a number value as the size on a Icon component. This works to display the icon correctly (granted not supported by the types), one side effect of this is that certain styles applied are omitted with variants. Margin in my case.

I have the following button:
image

And the following variant:
image

Without size, the Icon will not render correctly however the margin from the variant is applied. If I add the size, the margin is omitted.

Workaround is the apply the margin in line with the component use. No variant support.

gluestack-ui Version

v2

Platform

  • Expo
  • React Native CLI
  • Next
  • Web
  • Android
  • iOS

Other Platform

No response

Additional Information

No response

@JavanPoirier JavanPoirier added the bug Something isn't working label Dec 2, 2024
@JavanPoirier JavanPoirier changed the title Lucid Icons don't respect styles with size Lucid Icons don't respect some styles with size Dec 2, 2024
@JavanPoirier JavanPoirier changed the title Lucid Icons don't respect some styles with size Buttons Icons don't respect styles Dec 3, 2024
@kuroispd
Copy link

Hi.
I found (maybe) same issue on other importing icon components such as InputIcon, CheckboxIcon, and etc...
After init expo server, the screen shows error on index.web.tsx of Icon that const accessClassName returns undefined or null for Object.

@Viraj-10 Viraj-10 assigned rajat693 and unassigned Viraj-10 Dec 13, 2024
@rajat693
Copy link
Collaborator

rajat693 commented Jan 2, 2025

hi @JavanPoirier you can't pass the number value to size prop of Icon component, but if you want to give custom size then you can give height and width in className.

@JavanPoirier
Copy link
Author

JavanPoirier commented Jan 2, 2025

hi @JavanPoirier you can't pass the number value to size prop of Icon component, but if you want to give custom size then you can give height and width in className.

I understand that a number is not "technically" supported by documentation or the types. However it does actually work across platforms and is the only way to workaround #1821 as I mention in this ticket. I believe this to do with the size prop being passed to the underlying SVG.

Here is the workaround I implemented in the Gluestack UI component:
image

I have not dug much deeper, however I suspect it is due to size being passed directly to the SVG, while height & width as specified with nativewind only affect the container. Suggesting a possible issue with the SVG viewport?

#1821 only appears with some icons. I know LayoutListIcon & BatteryFullIcon from lucide-react-native were problems for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

4 participants