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
The property that allows to specify custom text for `Done` button.
91
+
#### `onPress`
125
92
126
-
```tsx
127
-
<KeyboardToolbardoneText="Close" />
128
-
```
129
-
130
-
### `icon`
131
-
132
-
`icon` property allows to render custom icons for prev and next buttons.
93
+
A callback that is called when the user presses the **previous** button. The callback receives an instance of `GestureResponderEvent` which can be used to cancel the default action (for advanced use-cases).
An object containing `left` and `right` properties that define the `KeyboardToolbar` padding. This helps prevent overlap with system UI elements, especially in landscape orientation:
114
+
:::tip Prevent Default Action
115
+
To prevent the default action, call `e.preventDefault()` inside the callback:
A callback that is called when the user presses the **done** button. The callback receives an instance of `GestureResponderEvent` which can be used to cancel the default action (for advanced use-cases).
134
+
A callback that is called when the user presses the **next** button. The callback receives an instance of `GestureResponderEvent` which can be used to cancel the default action (for advanced use-cases).
167
135
168
136
```tsx
169
137
import { Platform } from"react-native";
@@ -179,25 +147,42 @@ const haptic = () =>
179
147
180
148
// ...
181
149
182
-
<KeyboardToolbaronDoneCallback={haptic} />;
150
+
<KeyboardToolbar>
151
+
<KeyboardToolbar.NextonPress={haptic} />
152
+
</KeyboardToolbar>;
183
153
```
184
154
185
155
:::tip Prevent Default Action
186
156
To prevent the default action, call `e.preventDefault()` inside the callback:
187
157
188
158
```tsx
189
-
<KeyboardToolbar
190
-
onDoneCallback={(e) => {
191
-
e.preventDefault(); // keyboard will not be dismissed, since we cancelled the default action
192
-
}}
193
-
/>
159
+
<KeyboardToolbar>
160
+
<KeyboardToolbar.Next
161
+
onPress={(e) => {
162
+
// the focus will not be moved to the next input
163
+
e.preventDefault();
164
+
}}
165
+
/>
166
+
</KeyboardToolbar>
194
167
```
195
168
196
169
:::
197
170
198
-
### `onNextCallback`
171
+
### `<KeyboardToolbar.Done>`
199
172
200
-
A callback that is called when the user presses the **next** button. The callback receives an instance of `GestureResponderEvent` which can be used to cancel the default action (for advanced use-cases).
173
+
#### `text`
174
+
175
+
The property that allows to specify custom text for `Done` button.
176
+
177
+
```tsx
178
+
<KeyboardToolbar>
179
+
<KeyboardToolbar.Donetext="Close" />
180
+
</KeyboardToolbar>
181
+
```
182
+
183
+
#### `onPress`
184
+
185
+
A callback that is called when the user presses the **done** button. The callback receives an instance of `GestureResponderEvent` which can be used to cancel the default action (for advanced use-cases).
201
186
202
187
```tsx
203
188
import { Platform } from"react-native";
@@ -213,55 +198,91 @@ const haptic = () =>
213
198
214
199
// ...
215
200
216
-
<KeyboardToolbaronNextCallback={haptic} />;
201
+
<KeyboardToolbar>
202
+
<KeyboardToolbar.DoneonPress={haptic} />
203
+
</KeyboardToolbar>;
217
204
```
218
205
219
206
:::tip Prevent Default Action
220
207
To prevent the default action, call `e.preventDefault()` inside the callback:
221
208
222
209
```tsx
223
-
<KeyboardToolbar
224
-
onNextCallback={(e) => {
225
-
e.preventDefault(); // the focus will not be moved to the next input
226
-
}}
227
-
/>
210
+
<KeyboardToolbar>
211
+
<KeyboardToolbar.Done
212
+
onPress={(e) => {
213
+
// keyboard will not be dismissed, since we cancelled the default action
214
+
e.preventDefault();
215
+
}}
216
+
/>
217
+
</KeyboardToolbar>
228
218
```
229
219
230
220
:::
231
221
232
-
### `onPrevCallback`
222
+
##Props
233
223
234
-
A callback that is called when the user presses the **previous** button. The callback receives an instance of `GestureResponderEvent` which can be used to cancel the default action (for advanced use-cases).
To prevent the default action, call `e.preventDefault()` inside the callback:
253
+
### `icon`
254
+
255
+
`icon` property allows to render custom icons for prev and next buttons.
255
256
256
257
```tsx
257
-
<KeyboardToolbar
258
-
onPrevCallback={(e) => {
259
-
e.preventDefault(); // the focus will not be moved to the prev input
260
-
}}
261
-
/>
258
+
import { Text } from"react-native";
259
+
import {
260
+
KeyboardToolbar,
261
+
KeyboardToolbarProps,
262
+
} from"react-native-keyboard-controller";
263
+
264
+
const Icon:KeyboardToolbarProps["icon"] = ({ type }) => {
265
+
return <Text>{type==="next"?"⬇️":"⬆️"}</Text>;
266
+
};
267
+
268
+
// ...
269
+
270
+
<KeyboardToolbaricon={Icon} />;
262
271
```
263
272
264
-
:::
273
+
### `insets`
274
+
275
+
An object containing `left` and `right` properties that define the `KeyboardToolbar` padding. This helps prevent overlap with system UI elements, especially in landscape orientation:
@@ -271,10 +292,6 @@ This property allows to specify the opacity of the toolbar container. The value
271
292
<KeyboardToolbaropacity="EE" />
272
293
```
273
294
274
-
### `showArrows`
275
-
276
-
A boolean prop indicating whether to show `next` and `prev` buttons. Can be useful to set it to `false` if you have only one input and want to show only `Done` button. Default to `true`.
277
-
278
295
### `theme`
279
296
280
297
Prop allowing you to specify the brand colors of your application for `KeyboardToolbar` component. If you want to re-use already platform specific colors you can import `DefaultKeyboardToolbarTheme` object and override colors only necessary colors:
@@ -473,7 +490,7 @@ To migrate from the legacy prop-based API to the compound API:
0 commit comments