Skip to content

feat: Custom tab header component #86

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

rafabulsing
Copy link
Contributor

Added the option for providing a custom tab header component. It can be provided for the entire tab group, or just to a specific tab.

{/* All `TabScreen`s will use the custom header component */}
<Tabs
  TabHeaderComponent={MyCustomHeader}
>
  <TabScreen />
   <TabScreen />
  <TabScreen />
</Tabs>

{/* Only the first `TabScreen` will use the custom header component */}
<Tabs>
  <TabScreen
    TabHeaderComponent={MyCustomHeader}
  />
  <TabScreen />
  <TabScreen />
</Tabs>

Some changes were made so that the tabs can adapt to different sized custom headers, but the end result for the default header style is unchanged.

Mode Without custom header With custom header
Fixed Screenshot_1746016976 Screenshot_1746016964
Scrollable Screenshot_1746017008 image

And here's a more realistic example of the way this might be used (and my motivation for this PR in the first place):

image

TabHeaderComponent receives the same props as TabsHeaderItem. Note that does make TabsHeaderItem props part of the public API, even though it is not exported. Maybe it would be good to make that official by exporting it? Or at least exporting type TabHeaderComponent = typeof TabsHeaderItem?

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.

1 participant