You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+14-12
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# react-navigation-header-buttons
2
2
3
-
This package will help you render buttons in the navigation bar and handle the styling so you don't have to. It mimics the appearance of native navbar buttons and offers a simple and flexible interface for you to interact with.
3
+
This package will help you render buttons in the navigation bar and handle the styling, so you don't have to. It mimics the appearance of native navbar buttons and offers a simple but also flexible interface for you to interact with.
4
4
5
5
✅ DRY library api
6
6
@@ -94,7 +94,7 @@ Version >= 11 requires React Native 0.71 / Expo 48 or newer. Use version 10 if y
94
94
95
95
1.`yarn add react-navigation-header-buttons`
96
96
97
-
2. Wrap your root component in `HeaderButtonsProvider` and pass the `stackType` prop (`'native' | 'js'`), as seen in [example's App.tsx](https://github.com/vonovak/react-navigation-header-buttons/tree/master/example/App.tsx).
97
+
2. Wrap your root component in `HeaderButtonsProvider` and pass the `stackType` prop (`'native' | 'js'`), as seen in [example's App.tsx](https://github.com/vonovak/react-navigation-header-buttons/blob/master/example/src/App.tsx).
98
98
99
99
**IMPORTANT**`HeaderButtonsProvider` must be placed as a descendant of `NavigationContainer`, otherwise this library will not receive the correct theme from React Navigation.
100
100
@@ -110,11 +110,12 @@ In particular, it allows setting `IconComponent`, `size` and `color` once so tha
| HeaderButtonComponent?: `ComponentType<HeaderButtonProps>`| component that renders the buttons, `HeaderButton` by default | Typically, you'll want to provide a component that wraps `HeaderButton` provided by this package, as seen in the [quick example](#quick-example). |
116
-
| children: ReactNode | whatever you want to render inside | Typically, `Item` or your component that renders `Item`, but it can be any React element. |
117
-
| left?: boolean | whether the `HeaderButtons` are on the left from header title | false by default, it only influences styling in a subtle way |
| HeaderButtonComponent?: `ComponentType<HeaderButtonProps>`| component that renders the buttons, `HeaderButton` by default | Typically, you'll want to provide a component that wraps `HeaderButton` provided by this package, as seen in the [quick example](#quick-example). |
116
+
| children: ReactNode | whatever you want to render inside | Typically, `Item` or your component that renders `Item`, but it can be any React element. |
117
+
| left?: boolean | whether the `HeaderButtons` are on the left from header title | false by default, it only influences styling in a subtle way |
118
+
| preset?: 'tabHeader' \| 'stackHeader' | headers are typically rendered in Stack Navigator, however, you can also render them in a Tab Navigator header. Pass 'tabHeader' if button margins are missing. | 'stackHeader' by default |
118
119
119
120
### `Item`
120
121
@@ -159,14 +160,15 @@ You can also use the [react-native-menu](https://github.com/react-native-menu/me
| OverflowIcon: ReactElement \| ComponentType | React element or component for the overflow icon | if you provide a component, it will receive `color` prop as seen in example above |
164
-
| style?: ViewStyle | optional styles for overflow button | there are some default styles set, as seen in `OverflowButton.js`|
165
+
| style?: ViewStyle | optional styles for overflow button | there are some default styles set, as seen in `OverflowButton.tsx`|
165
166
| onPress?: (OnOverflowMenuPressParams) => any | function that is called when overflow menu is pressed. | This will override the default handler. Note the default handler offers (limited) customization. See more in "Recipes". |
166
167
| testID?: string | testID to locate the overflow button in e2e tests | the default is available under `import { OVERFLOW_BUTTON_TEST_ID } from 'react-navigation-header-buttons/e2e'`|
167
168
| accessibilityLabel?: string || 'More options' by default |
168
169
| left?: boolean | whether the `OverflowMenu` is on the left from header title | false by default, it just influences styling. No need to pass this if you already passed it to `HeaderButtons`. |
169
170
| children: ReactNode | the overflow items | typically `HiddenItem`s, please read the note below |
171
+
| preset?: 'tabHeader' \| 'stackHeader' || see [props of headerbuttons](#headerbuttons)|
170
172
| other props | props passed to the nested `PlatformPressable`| pass eg. `pressColor` to control ripple color on Android |
171
173
172
174
##### Important note
@@ -181,7 +183,7 @@ Only `overflowMenuPressHandlerDropdownMenu` supports rendering custom elements,
181
183
182
184
This limitation may look weird, but it should not really bother you in any way: if you need to have state in your items, lift the state up.
183
185
The limitation exists because we need to be able to transform declarative React elements into imperative calls (`ActionSheetIOS.showActionSheetWithOptions` / `UIManager.showPopupMenu`).
184
-
If this is a problem for you for some reason, please raise an issue and we'll see what can be done about it.
186
+
If this is a problem for you for some reason, please raise an issue, and we'll see what can be done about it.
185
187
186
188
If `OverflowMenu` contains no valid child elements, nothing will be rendered at all. (No `OverflowIcon`, no wrapper.)
187
189
@@ -255,7 +257,7 @@ You can fully customize what it renders inside of the `PlatformPressable` using
255
257
256
258
The default handler for overflow menu on iOS is `overflowMenuPressHandlerActionSheet`.
257
259
258
-
One of the usual things you may want to do is override the cancel button label on iOS - see [example](example/screens/UsageWithOverflow.tsx).
260
+
One of the usual things you may want to do is override the cancel button label on iOS - see [example](example/src/screens/UsageWithOverflow.tsx).
259
261
260
262
You can also use the [react-native-menu](https://github.com/react-native-menu/menu) to show the overflow menu, as seen in the example app.
261
263
@@ -265,7 +267,7 @@ Use the `buttonStyle` prop to set [`textTransform`](https://reactnative.dev/docs
265
267
266
268
#### How to integrate in your project
267
269
268
-
This sections covers how you should use the library in your project. Please note that there are numerous [example screens](https://github.com/vonovak/react-navigation-header-buttons/tree/master/example/screens).
270
+
This sections covers how you should use the library in your project. Please note that there are numerous [example screens](https://github.com/vonovak/react-navigation-header-buttons/tree/master/example/src/screens).
269
271
270
272
1 . Define one file where the styling of header buttons is taken care of.
0 commit comments