Skip to content

Support passing custom style to TabController.TabBarItem #947

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

Merged
merged 1 commit into from
Sep 21, 2020

Conversation

ethanshar
Copy link
Collaborator

Description

Support passing custom style to TabController TabBarItem

Changelog

Support passing custom style prop in TabController.TabBar items

@ethanshar ethanshar merged commit 9fe4fbc into master Sep 21, 2020
@lumotroph
Copy link

Thanks for this change @ethanshar - just checking something with you:

If I now want to change the colours of different tabs (or some other style in the tab bar), how can the style be passed to the TabController component's TabController.TabBar without manually supplying TabBarItems?

I tried to loop through my TabBarItems and define a labelColor there, but I get the warning message:

Please pass the "items" prop to TabController.TabBar instead of children

Any tips?

Thanks!

@ethanshar ethanshar deleted the feat/TabControllerItem_styleProp branch November 30, 2020 09:03
@ethanshar
Copy link
Collaborator Author

items is a prop you pass to TabController and is an array of objects that represent TabBarItem

Try this..

<TabController items={[{label: 'tab1, labelStyle: {...}}, {label: 'tab 2'}]} ....

@bneigher
Copy link
Contributor

@ethanshar

This doesn't allow us to use the TabController.TabBarItem component at all though... right? Why is it in the docs? Also this example seems to have HAD it:
https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/TabControllerScreen/index.tsx#L158

But its commented out and the function doesn't exist.

Please advise, trying to render my own tab icons

@bneigher
Copy link
Contributor

Relying on the limited Item Style doesn't allow us to really customize the look and feel. For example:
Screen Shot 2021-01-26 at 2 40 11 PM

I can't even use my own icons here as RNUI is trying to set the color's active / non active. These are supposed to be my pngs. Are the options to disable this behavior?

@dojoVader
Copy link

@ethanshar

This doesn't allow us to use the TabController.TabBarItem component at all though... right? Why is it in the docs? Also this example seems to have HAD it: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/TabControllerScreen/index.tsx#L158

But its commented out and the function doesn't exist.

Please advise, trying to render my own tab icons

Did you ever get this working ? I can't seem to render SVG only PNG

@bneigher
Copy link
Contributor

I ended up patching the TabController with my own version which allows me to pass in a Component instead of a style. Unfortunately it's a major pain-point as there have been some core changes to the repo and it's not worth sharing. My advice would be to take the current version, write in the ability to pass in a custom component, and handle any component changes yourself.

I do think it would be very nice if this was supported though. Custom component would solve a lot of problems and make the tab item feature a lot more useful.

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

Successfully merging this pull request may close these issues.

4 participants