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

Support icon as component instead of only image #895

Closed
thebergamo opened this issue Aug 15, 2020 · 13 comments
Closed

Support icon as component instead of only image #895

thebergamo opened this issue Aug 15, 2020 · 13 comments
Assignees

Comments

@thebergamo
Copy link

Hi,

First of all, after getting know this lib I fall in love, so cheers guys!

Would you be open to support passing icon in those components as component instead of supporting only images.

For example when we've the Chip component we would use it like this:

import { Chip } from 'react-native-ui-lib';
import Icon from 'react-native-vector-icons/MaterialIcons';

export default (props) => 
<Chip label="3km" icon={<Icon name="map" />} />

I believe it's quite standard using react-native-vector-icons, so we could have a more connected ecosystem.

If you're open to have it as an option into those components, I would create a PR for it :)

@thebergamo thebergamo changed the title Support icon as component instead of image Support icon as component instead of only image Aug 16, 2020
@dhcmega
Copy link

dhcmega commented Apr 13, 2021

Hi, is there any change to have this? thanks!

@ethanshar
Copy link
Collaborator

Added to our board

@lidord-wix
Copy link
Contributor

Hey @thebergamo and @dhcmega,
We can add it to our Chip component, there are other components you would like to have this support in?

@thebergamo
Copy link
Author

I believe all components that have option to pass a image could benefit from being able to pass a component to it :)

@dhcmega
Copy link

dhcmega commented Apr 28, 2021

@lidord-wix hi! Out of the top of my head, I think I would use it as transparent back button for the header, regular buttons, lists and custom touchable buttons for the "home/desktop" of my app. Thanks!

@richardrobberse
Copy link

@lidord-wix @ethanshar I think I'm facing a similar issue - trying to pass an icon coming from @expo/vector-icons to the rightIconSource prop of the Picker component. Kind of expected the render function to work no matter where the icon is coming from? Any ideas?

@lidord-wix
Copy link
Contributor

Hey @richardrobberse,
We're working on a new TextField component with trailingAccessory and leadingAccessory props that doing the functionality you described, this TextField will be used by our Picker component so you'll be able to use it there soon :)

@mlabrum
Copy link

mlabrum commented Jun 4, 2021

TabBar.Item is another candidate for this.

I've even tried using the react-native-vector-icons getImageSource to pass the image directly to it

<TabBar.Item key={label} label={label} onPress={onPress} icon={Icon.getImageSourceSync("account-arrow-left", 20, "red")}/>

@lidord-wix
Copy link
Contributor

@thebergamo, @dhcmega, @richardrobberse, @mlabrum,
I'm closing this issue since we added the required support to most of our main components.
If there's a specific need, please open an issue for that and we'll address it.

@ConnorLanglois
Copy link

Hi, can we get support for this for the Toast component "icon" prop?

@lidord-wix
Copy link
Contributor

Hi @ConnorLanglois,
You can pass your custom content as the Toast children.
Please let me know if it doesn't work for you :)

@MLaidlawScott
Copy link

Hello. Firstly, thanks for this library and the docs and examples. Really enjoying using it.

I’m wondering if there is support or plans to add support for using icons from @expo/vector-icons in the iconSource prop of Button components.

Or, if it is possible to load specific icons using Assets.loadAssetGroup that would allow them to be used in iconSource.

Thanks

@lidord-wix
Copy link
Contributor

Hello @MLaidlawScott,
You can pass any component you wish as a child of our <Button /> component, to have a custom button (example).
Also, you can see here an example for how to use the loadAssetsGroup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants