File tree Expand file tree Collapse file tree
resources/views/docs/mobile/3/the-basics Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,6 +128,46 @@ But note that this will overwrite any changes you've made to your copy of this c
128128
129129</aside >
130130
131+ ## Keyboard Visibility
132+
133+ When the on-screen keyboard appears, it can cover inputs, action buttons or other parts of your UI that the user needs
134+ to see or interact with. To help you adapt your layout, NativePHP automatically toggles a ` keyboard-visible ` class on
135+ the ` <body> ` element whenever the software keyboard opens or closes — on both iOS and Android.
136+
137+ You can use this class to hide, move or resize elements while the keyboard is up, using CSS alone:
138+
139+ ``` css
140+ /* Hide a fixed bottom navigation bar while the user is typing */
141+ .bottom-nav {
142+ transition : transform 0.2s ease-out ;
143+ }
144+
145+ body .keyboard-visible .bottom-nav {
146+ transform : translateY (100% );
147+ }
148+ ```
149+
150+ If you're using Tailwind, you can register a ` keyboard-visible ` variant in your CSS file using the ` @custom-variant `
151+ directive:
152+
153+ ``` css
154+ @import " tailwindcss" ;
155+
156+ @custom-variant keyboard-visible (&:where(body.keyboard-visible *));
157+ ```
158+
159+ You can then use it like any built-in variant:
160+
161+ ``` html
162+ <nav class =" fixed bottom-0 left-0 w-full transition-transform
163+ keyboard-visible:translate-y-full" >
164+ ...
165+ </nav >
166+ ```
167+
168+ This pairs well with the [ Safe Areas] ( #safe-areas ) insets, allowing you to build layouts that respond cleanly to both
169+ device geometry and keyboard state without writing any JavaScript.
170+
131171## WebView Compatibility
132172
133173On Android, the web view is powered by the system's built-in WebView component, which varies by device and OS version.
You can’t perform that action at this time.
0 commit comments