suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Components84
  • Overview
  • Accordion
  • Alert
  • Alert Dialog
  • Alert Sheet
  • Amount Input
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Bottom Bar
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Chip
  • Code Block
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Direction
  • Drawer
  • Dropdown Menu
  • Empty
  • FAB
  • Field
  • Fullscreen Menu
  • Haptics
  • Header
  • Hover Card
  • Icon
  • Input
  • Input Accessory Bar
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Keyboard Scroll View
  • Keypad
  • Label
  • Marker
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Page Indicator
  • Pagination
  • Pin Pad
  • Popover
  • Progress
  • QR Scanner
  • Questionnaire
  • Radio Group
  • Resizable
  • Screen
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature Pad
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Tab Bar
  • Table
  • Tabs
  • Text
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Trace
  • Wheel Picker
  • Widget

suiss/ui · Component

Keyboard Scroll View

A scroll view that keeps the focused text field visible above the on-screen keyboard.

Keyboard Scroll View is an open-source component from suiss/ui for React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.

React Native
Keyboard scroll view demo in React Native, light modeKeyboard scroll view demo in React Native, dark mode
import { View } from "react-native"
import { Input } from "@/components/ui/input"
import { KeyboardScrollView } from "@/components/ui/keyboard-scroll-view"
import { Text } from "@/components/ui/text"

const fields = [
  "First name",
  "Last name",
  "Email",
  "Phone",
  "Street",
  "City",
  "Postal code",
  "Country",
  "Company",
  "Notes",
import { View } from "react-native"
import { Input } from "@/components/ui/input"
import { KeyboardScrollView } from "@/components/ui/keyboard-scroll-view"
import { Text } from "@/components/ui/text"

const fields = [
  "First name",
  "Last name",
  "Email",
  "Phone",
  "Street",
  "City",
  "Postal code",
  "Country",
  "Company",
  "Notes",
import SwiftUI

struct KeyboardScrollViewExample: View {
  var body: some View {
    KeyboardScrollView {
      VStack(alignment: .leading, spacing: 16) {
        Text("Shipping address").textVariant(.h3)
        KeyboardScrollViewFields(labels: KeyboardScrollViewFields.all)
      }
      .padding(16)
    }
  }
}

struct KeyboardScrollViewFields: View {
  static let all = [
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Input
import com.esuiss.ui.components.KeyboardScrollView
import com.esuiss.ui.components.Screen

KeyboardScrollView wraps the React Native ScrollView. When the keyboard opens, it measures how much of the view the keyboard covers, adds matching space at the end of the content and scroll indicator, and scrolls just enough to bring the focused input above the keyboard.

Use it for forms and other screens with text fields that would otherwise end up behind the keyboard.

Installation

$ pnpm dlx shadcn@latest add @esuiss/keyboard-scroll-view

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add keyboard-scroll-view
$ pnpm dlx shadcn@latest add @esuiss/keyboard-scroll-view

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add keyboard-scroll-view --platform swift
$ pnpm dlx shadcn@latest add @esuiss/keyboard-scroll-view

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add keyboard-scroll-view --platform kotlin
  1. Install the following dependencies:
npx expo install cn
  1. Copy the primitives it uses into components/primitives:
uniwind/components/primitives/hooks.ts
import * as React from "react"
import { BackHandler } from "react-native"

function useEffectEvent<TArgs extends readonly unknown[], TResult>(
  callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
  const callbackRef = React.useRef(callback)

  React.useLayoutEffect(() => {
    callbackRef.current = callback
  })

  return React.useCallback(
    (...args: TArgs): TResult => callbackRef.current(...args),
    []
  )
uniwind/components/primitives/keyboard.ts
import * as React from "react"
import {
  Dimensions,
  Keyboard,
  type KeyboardEvent,
  type KeyboardMetrics,
  Platform,
  useWindowDimensions,
} from "react-native"

interface KeyboardFrame {
  height: number
  accessoryHeight: number
  duration: number
}
  1. Copy and paste the following code into components/ui/keyboard-scroll-view.tsx:
uniwind/components/ui/keyboard-scroll-view.tsx
import { cn } from "cn"
import * as React from "react"
import {
  Platform,
  ScrollView,
  type ScrollViewProps,
  TextInput,
  useWindowDimensions,
  View,
} from "react-native"
import { useComposedRefs } from "@/components/primitives/hooks"
import { useKeyboard } from "@/components/primitives/keyboard"

const FOCUS_FRAMES = 30

type KeyboardScrollViewContextValue = {
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install cn
  1. Copy the primitives it uses into components/primitives:
nativewind/components/primitives/hooks.ts
import * as React from "react"
import { BackHandler } from "react-native"

function useEffectEvent<TArgs extends readonly unknown[], TResult>(
  callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
  const callbackRef = React.useRef(callback)

  React.useLayoutEffect(() => {
    callbackRef.current = callback
  })

  return React.useCallback(
    (...args: TArgs): TResult => callbackRef.current(...args),
    []
  )
nativewind/components/primitives/keyboard.ts
import * as React from "react"
import {
  Dimensions,
  Keyboard,
  type KeyboardEvent,
  type KeyboardMetrics,
  Platform,
  useWindowDimensions,
} from "react-native"

interface KeyboardFrame {
  height: number
  accessoryHeight: number
  duration: number
}
  1. Copy and paste the following code into components/ui/keyboard-scroll-view.tsx:
nativewind/components/ui/keyboard-scroll-view.tsx
import { cn } from "cn"
import * as React from "react"
import {
  Platform,
  ScrollView,
  type ScrollViewProps,
  TextInput,
  useWindowDimensions,
  View,
} from "react-native"
import { useComposedRefs } from "@/components/primitives/hooks"
import { useKeyboard } from "@/components/primitives/keyboard"

const FOCUS_FRAMES = 30

type KeyboardScrollViewContextValue = {
  1. Update the import paths to match your project setup.
  1. Copy the primitives it uses into components/primitives:
stylesheet/components/primitives/hooks.ts
import * as React from "react"
import { BackHandler } from "react-native"

function useEffectEvent<TArgs extends readonly unknown[], TResult>(
  callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
  const callbackRef = React.useRef(callback)

  React.useLayoutEffect(() => {
    callbackRef.current = callback
  })

  return React.useCallback(
    (...args: TArgs): TResult => callbackRef.current(...args),
    []
  )
stylesheet/components/primitives/keyboard.ts
import * as React from "react"
import {
  Dimensions,
  Keyboard,
  type KeyboardEvent,
  type KeyboardMetrics,
  Platform,
  useWindowDimensions,
} from "react-native"

interface KeyboardFrame {
  height: number
  accessoryHeight: number
  duration: number
}
  1. Copy and paste the following code into components/ui/keyboard-scroll-view.tsx:
stylesheet/components/ui/keyboard-scroll-view.tsx
import * as React from "react"
import {
  Platform,
  ScrollView,
  type ScrollViewProps,
  TextInput,
  useWindowDimensions,
  View,
} from "react-native"
import { useComposedRefs } from "@/components/primitives/hooks"
import { useKeyboard } from "@/components/primitives/keyboard"

const FOCUS_FRAMES = 30

type KeyboardScrollViewContextValue = {
  scrollToFocused: () => void
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. Copy the theme files every view uses:

swift/Theme/Theme.swift
import CoreText
import SwiftUI
import UIKit

struct RGBA: Sendable {
  let red: CGFloat
  let green: CGFloat
  let blue: CGFloat
  let alpha: CGFloat

  init(_ hex: UInt32, _ alpha: CGFloat = 1) {
    red = CGFloat((hex >> 16) & 0xFF) / 255
    green = CGFloat((hex >> 8) & 0xFF) / 255
    blue = CGFloat(hex & 0xFF) / 255
    self.alpha = alpha
  }
swift/Theme/Tokens.swift
import SwiftUI

public enum EsuissColor {
  public static let background = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
  public static let foreground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let card = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let cardForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let popover = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let popoverForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let primary = Color.adaptive(light: .init(0x0071E3), dark: .init(0x0A84FF))
  public static let primaryForeground = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0xFFFFFF))
  public static let secondary = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
  public static let secondaryForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let muted = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
  public static let mutedForeground = Color.adaptive(light: .init(0x6E6E73), dark: .init(0x86868B))
  public static let accent = Color.adaptive(light: .init(0x000000, 0.06), dark: .init(0xFFFFFF, 0.1))
  1. Copy the source:
swift/Components/KeyboardScrollView.swift
import SwiftUI
import UIKit

public struct KeyboardScrollView<Content: View>: View {
  let showsIndicators: Bool
  let content: Content

  public init(showsIndicators: Bool = true, @ViewBuilder content: () -> Content) {
    self.showsIndicators = showsIndicators
    self.content = content()
  }

  public var body: some View {
    ScrollView(.vertical, showsIndicators: showsIndicators) {
      content
        .frame(maxWidth: .infinity, alignment: .topLeading)
  1. Add the files to your app target.
  1. Apply the Compose compiler plugin, enable Compose, set compileSdk to 37 or higher and minSdk to 24 or higher, and add the dependencies:
build.gradle.kts
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
  1. Copy the theme files every view uses:
kotlin/theme/Theme.kt
package com.esuiss.ui.theme

import android.content.res.AssetManager
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.dropShadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.shadow.Shadow as DropShadow
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
kotlin/theme/Tokens.kt
package com.esuiss.ui.theme

import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp

@Immutable
data class Colors(
    val background: Color,
    val foreground: Color,
    val card: Color,
    val cardForeground: Color,
    val popover: Color,
    val popoverForeground: Color,
    val primary: Color,
  1. Copy the source and every file it uses:
kotlin/components/KeyboardScrollView.kt
package com.esuiss.ui.components

import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
kotlin/components/Content.kt
package com.esuiss.ui.components

import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

val LocalContentStyle = compositionLocalOf { TextStyle.Default }

val LocalContentColor = compositionLocalOf { Color.Unspecified }

val LocalIconSize = compositionLocalOf { 20.dp }
kotlin/components/Screen.kt
package com.esuiss.ui.components

import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import android.os.Build
import android.view.View
import android.view.Window
import android.view.WindowInsetsController
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.ColumnScope
  1. Update the com.esuiss.ui package names to match your project.

Usage

import { View } from "react-native"
import { Input } from "@/components/ui/input"
import { KeyboardScrollView } from "@/components/ui/keyboard-scroll-view"
import { Text } from "@/components/ui/text"

const fields = [
  "First name",
  "Last name",
  "Email",
  "Phone",
  "Street",
  "City",
  "Postal code",
  "Country",
  "Company",
  "Notes",
]

function Fields() {
  return fields.map((label) => (
    <View key={label} className="gap-1.5">
      <Text variant="small">{label}</Text>
      <Input placeholder={label} />
    </View>
  ))
}

export function KeyboardScrollViewExample() {
  return (
    <KeyboardScrollView className="-m-4" contentContainerClassName="gap-4 p-4">
      <Text variant="h3">Shipping address</Text>
      <Fields />
    </KeyboardScrollView>
  )
}
import { View } from "react-native"
import { Input } from "@/components/ui/input"
import { KeyboardScrollView } from "@/components/ui/keyboard-scroll-view"
import { Text } from "@/components/ui/text"

const fields = [
  "First name",
  "Last name",
  "Email",
  "Phone",
  "Street",
  "City",
  "Postal code",
  "Country",
  "Company",
  "Notes",
]

function Fields() {
  return fields.map((label) => (
    <View key={label} style={{ gap: 6 }}>
      <Text variant="small">{label}</Text>
      <Input placeholder={label} />
    </View>
  ))
}

export function KeyboardScrollViewExample() {
  return (
    <KeyboardScrollView style={{ margin: -16 }} contentContainerStyle={{ gap: 16, padding: 16 }}>
      <Text variant="h3">Shipping address</Text>
      <Fields />
    </KeyboardScrollView>
  )
}
import SwiftUI

struct KeyboardScrollViewExample: View {
  var body: some View {
    KeyboardScrollView {
      VStack(alignment: .leading, spacing: 16) {
        Text("Shipping address").textVariant(.h3)
        KeyboardScrollViewFields(labels: KeyboardScrollViewFields.all)
      }
      .padding(16)
    }
  }
}

struct KeyboardScrollViewFields: View {
  static let all = [
    "First name",
    "Last name",
    "Email",
    "Phone",
    "Street",
    "City",
    "Postal code",
    "Country",
    "Company",
    "Notes",
  ]

  let labels: [String]

  var body: some View {
    ForEach(labels, id: \.self) { label in
      KeyboardScrollViewField(label: label)
    }
  }
}

struct KeyboardScrollViewField: View {
  let label: String

  @State private var text = ""

  var body: some View {
    VStack(alignment: .leading, spacing: 6) {
      Text(label).textVariant(.small)
      TextField(label, text: $text)
        .textFieldStyle(.input)
    }
    .frame(maxWidth: .infinity, alignment: .leading)
  }
}
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Input
import com.esuiss.ui.components.KeyboardScrollView
import com.esuiss.ui.components.Screen
import com.esuiss.ui.components.Text
import com.esuiss.ui.components.TextVariant

val keyboardScrollViewFields = listOf(
    "First name",
    "Last name",
    "Email",
    "Phone",
    "Street",
    "City",
    "Postal code",
    "Country",
    "Company",
    "Notes",
)

@Composable
fun KeyboardScrollViewField(label: String, modifier: Modifier = Modifier) {
    var value by rememberSaveable(label) { mutableStateOf("") }
    Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
        Text(label, variant = TextVariant.Small)
        Input(value, { value = it }, modifier, placeholder = label)
    }
}

@Composable
fun ColumnScope.KeyboardScrollViewFields() {
    keyboardScrollViewFields.forEach { key(it) { KeyboardScrollViewField(it) } }
}

@Composable
fun KeyboardScrollViewDefault() {
    Screen {
        KeyboardScrollView(
            modifier = Modifier.fillMaxSize(),
            contentPadding = PaddingValues(16.dp),
            verticalArrangement = Arrangement.spacedBy(16.dp),
        ) {
            Text("Shipping address", variant = TextVariant.H3)
            KeyboardScrollViewFields()
        }
    }
}

Examples

Larger bottom offset

Set bottomOffset to 64 to keep the focused field 64 points above the keyboard.

React Native
Keyboard scroll view larger bottom offset in React Native, light modeKeyboard scroll view larger bottom offset in React Native, dark mode
import { View } from "react-native"
import { Input } from "@/components/ui/input"
import { KeyboardScrollView } from "@/components/ui/keyboard-scroll-view"
import { Text } from "@/components/ui/text"

const fields = [
  "First name",
  "Last name",
  "Email",
  "Phone",
  "Street",
  "City",
  "Postal code",
  "Country",
  "Company",
  "Notes",
import { View } from "react-native"
import { Input } from "@/components/ui/input"
import { KeyboardScrollView } from "@/components/ui/keyboard-scroll-view"
import { Text } from "@/components/ui/text"

const fields = [
  "First name",
  "Last name",
  "Email",
  "Phone",
  "Street",
  "City",
  "Postal code",
  "Country",
  "Company",
  "Notes",

Focused

The last field is focused on mount and scrolled into view.

React Native
Keyboard scroll view focused in React Native, light modeKeyboard scroll view focused in React Native, dark mode
import { View } from "react-native"
import { Input } from "@/components/ui/input"
import { KeyboardScrollView } from "@/components/ui/keyboard-scroll-view"
import { Text } from "@/components/ui/text"

const fields = [
  "First name",
  "Last name",
  "Email",
  "Phone",
  "Street",
  "City",
  "Postal code",
  "Country",
  "Company",
  "Notes",
import { View } from "react-native"
import { Input } from "@/components/ui/input"
import { KeyboardScrollView } from "@/components/ui/keyboard-scroll-view"
import { Text } from "@/components/ui/text"

const fields = [
  "First name",
  "Last name",
  "Email",
  "Phone",
  "Street",
  "City",
  "Postal code",
  "Country",
  "Company",
  "Notes",
import SwiftUI

struct KeyboardScrollViewFields: View {
  static let all = [
    "First name",
    "Last name",
    "Email",
    "Phone",
    "Street",
    "City",
    "Postal code",
    "Country",
    "Company",
    "Notes",
  ]
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.unit.dp

With bottom bar

A form above a bottom bar with a full-width button.

React Native
Keyboard scroll view with bottom bar in React Native, light modeKeyboard scroll view with bottom bar in React Native, dark mode
import { View } from "react-native"
import { BottomBar, BottomBarContent } from "@/components/ui/bottom-bar"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { KeyboardScrollView } from "@/components/ui/keyboard-scroll-view"
import { Text } from "@/components/ui/text"

const fields = [
  "First name",
  "Last name",
  "Email",
  "Phone",
  "Street",
  "City",
  "Postal code",
  "Country",
import { View } from "react-native"
import { BottomBar, BottomBarContent } from "@/components/ui/bottom-bar"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { KeyboardScrollView } from "@/components/ui/keyboard-scroll-view"
import { Text } from "@/components/ui/text"

const fields = [
  "First name",
  "Last name",
  "Email",
  "Phone",
  "Street",
  "City",
  "Postal code",
  "Country",
import SwiftUI

struct KeyboardScrollViewWithBottomBarExample: View {
  var body: some View {
    VStack(spacing: 0) {
      KeyboardScrollView {
        VStack(alignment: .leading, spacing: 16) {
          Text("Shipping address").textVariant(.h3)
          KeyboardScrollViewFields(labels: KeyboardScrollViewFields.all)
        }
        .padding(16)
      }
      BottomBar(separator: true) {
        BottomBarContent {
          Button("Save address") {}
            .buttonStyle(.variant(size: .lg, block: true))
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.BottomBar
import com.esuiss.ui.components.BottomBarContent

The React Native tab shows 1 more example.

The React Native tab shows 1 more example.

Accessibility

  • The view is a standard ScrollView, so screen reader scrolling works as usual.

API Reference

KeyboardScrollView

PropTypeDefault
bottomOffsetnumber16

Also accepts the props of ScrollViewProps, React.RefAttributes<ScrollView>.

Place inputs anywhere inside the view; no extra setup is needed. bottomOffset is the space kept between the focused input and the keyboard. Only an input inside the visible frame of the scroll view is adjusted; inputs scrolled out of view are left alone. After a touch while the keyboard is open, the view checks the focused input again after a short delay.

All ScrollView props are passed through. By default taps on the content are handled while the keyboard is open (keyboardShouldPersistTaps="handled"), and keyboardDismissMode is interactive on iOS and on-drag on Android. The view fills its parent with flex-1.

KeyboardScrollViewContext exposes scrollToFocused, which children can call to bring the focused input into view again, for example after their layout changes.

KeyboardScrollView

ParameterTypeDefault
showsIndicatorsBooltrue
content() -> Content-

KeyboardScrollView

ParameterTypeDefault
modifierModifierModifier
stateScrollStaterememberScrollState()
contentPaddingPaddingValuesPaddingValues(0.dp)
verticalArrangementArrangement.VerticalArrangement.Top
content@Composable ColumnScope.() -> Unit-
NextKeypadPreviousKbd

On this page

  1. 01Installation
  2. 02Usage
  3. 03Examples
    • Larger bottom offset
    • Focused
    • With bottom bar
  4. 04Accessibility
  5. 05API Reference
    • KeyboardScrollView
    • KeyboardScrollView
    • KeyboardScrollView