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
@@ -37,6 +37,56 @@ import toolbar from "./toolbar.lottie.json";
37
37
-**Extended accessibility support** 🔍: Ensures that all users, including those with disabilities, can navigate through inputs effectively.
38
38
-**Full control over the buttons behavior** 🔧: Customize the actions triggered by the next, previous, and done buttons according to your needs.
39
39
-**Extends ViewProps** 📜: Supports all the props that `View` component has.
40
+
-**Compound component pattern** 🔌: Mix and match sub-components for granular control over the toolbar's structure.
41
+
42
+
## Compound Components
43
+
44
+
The new API uses sub-components as children of `KeyboardToolbar`. These allow for precise customization, such as conditional rendering of buttons or injecting custom elements.
45
+
46
+
### `<KeyboardToolbar.Background>`
47
+
48
+
Renders a custom background (e.g., blur effect) that overlays the entire toolbar. Accepts any React node as children.
This property allows to render custom blur effect for the toolbar (by default iOS keyboard is opaque and it blurs the content underneath, so if you want to follow **HIG** ([_Human Interface Guidelines_](https://developer.apple.com/design/human-interface-guidelines/materials)) properly - consider to add this effect).
75
-
76
-
By default it is `null` and will not render any blur effect, because it's not a responsibility of this library to provide a blur effect. Instead it provides a property where you can specify your own blur effect and its provider, i. e. `@react-native-community/blur`, `expo-blur` or maybe even `react-native-skia` (based on your project preferences of course).
77
-
78
-
:::warning
79
-
Please, note, that you need to specify `opacity` prop for this prop to work. Because otherwise you will not see a blur effect.
For more comprehensive usage that covers more complex interactions please check [example](https://github.com/kirillzyusko/react-native-keyboard-controller/tree/main/example) app.
445
452
:::
446
453
454
+
## Migration to compound component
455
+
456
+
To migrate from the legacy prop-based API to the compound API:
457
+
458
+
1. Add elements that you want to render in the toolbar (e.g., `Prev`, `Next`, `Done`, `Content`, `Background`).
459
+
460
+
```tsx
461
+
// Old:
462
+
<KeyboardToolbar />
463
+
464
+
// New:
465
+
<KeyboardToolbar>
466
+
<KeyboardToolbar.Prev />
467
+
<KeyboardToolbar.Next />
468
+
<KeyboardToolbar.Done />
469
+
</KeyboardToolbar>
470
+
```
471
+
472
+
2. Move props like `content`, `blur`, `doneText` into dedicated sub-components:
0 commit comments