React

App Screen

A component that constitutes individual screens in Stackflow navigation. Used to provide screen transition experience like mobile apps.

Available since@seed-design/stackflow@0.0.1, @seed-design/css@0.0.1
Loading...

Installation

npx @seed-design/cli@latest add ui:app-screen

Usage

import {
  AppBar,
  AppBarBackButton,
  AppBarCloseButton,
  AppBarIconButton,
  AppBarLeft,
  AppBarMain,
  AppBarRight,
} from "seed-design/ui/app-bar";
import { AppScreen, AppScreenContent } from "seed-design/ui/app-screen";
<AppScreen theme="cupertino">
  <AppBar>
    <AppBarLeft>
      <AppBarBackButton />
    </AppBarLeft>
    <AppBarMain>Title</AppBarMain>
    <AppBarRight>{/* actions */}</AppBarRight>
  </AppBar>
  <AppScreenContent>{/* content */}</AppScreenContent>
</AppScreen>

Props

App Screen

AppScreen

Prop

Type

preventSwipeBack?boolean | undefined
onSwipeBackStart?(() => void) | undefined
onSwipeBackMove?((props: { displacement: number; displacementRatio: number; }) => void) | undefined
onSwipeBackEnd?((props: { swiped: boolean; }) => void) | undefined

AppScreenContent

Prop

Type

ptr?boolean | undefined
onPtrReady?(() => void) | undefined
onPtrRefresh?(() => Promise<void>) | undefined

App Bar

AppBar

Prop

Type

background?(string & {}) | ScopedColorBg | ScopedColorPalette | ScopedColorBanner | undefined

AppBarLeft

Prop

Type

AppBarMain

Prop

Type

AppBarRight

Prop

Type

AppBarIconButton, AppBarBackButton, AppBarCloseButton

Prop

Type

Examples

Tones

You can use a transparent background by setting the tone property of AppScreen to transparent.

  • The background of AppBar becomes transparent.
  • A gradient is displayed at the top of AppScreen including the mobile OS status bar.
    • You can hide it by setting the gradient property to false.
Loading...

With Intersection Observer

You can dynamically change the tone property of AppBar using Intersection Observer.

Loading...

Layer Offset Top

You can adjust the top offset of AppScreenContent using the layerOffsetTop property.

When using tone="transparent" and gradient, generally set layerOffsetTop="none" together to extend the content area to the mobile OS status bar area.

To properly handle safe areas like display cutouts (notches), use a viewport meta tag that includes viewport-fit=cover.

<meta
  name="viewport"
  content="width=device-width, initial-scale=1, viewport-fit=cover"
/>

Screenshot with layerOffsetTop set to none

Screenshot with layerOffsetTop set to safeArea

Screenshot with layerOffsetTop set to appBar

Customizing App Bar

When tone="layer", you can change the color of AppBar.

You can customize icons by using the Icon component within AppBarIconButton.

Icon

Learn more about the Icon component.

Loading...

Custom Elements in App Bar

When placing custom elements within AppBar that don't correspond to AppBarLeft, AppBarMain, or AppBarRight, use the AppBarSlot component to apply the same screen transition as other elements.

AppBarSlot applies transitions by injecting class to child elements and does not generate additional markup.

Loading...

Preventing Swipe Back

You can prevent swipe back gestures by using the preventSwipeBack property to avoid rendering the edge area in AppScreen where theme="cupertino".

Transition Styles

You can specify the transition to play when AppScreen is pushed to the top or popped from the top using the transitionStyle property.

Top: Refers to AppScreen created by an activity where useActivity().isTop === true.

If not specified separately, transitionStyle has a default value according to theme.

  • theme="cupertino": slideFromRightIOS
  • theme="android": fadeFromBottomAndroid

When the top AppScreen is pushed/popped, non-top AppScreens also play transitions.

Transition Style of Non-Top AppScreen

Up to @seed-design/stackflow@1.1.15

When the top AppScreen is pushed/popped, non-top AppScreens play each AppScreen's unique transitionStyle.

  • For example, if AppScreen 1 with transitionStyle="slideFromLeftIOS" is pushed on top of AppScreen 0 with transitionStyle="fadeFromBottomAndroid", AppScreen 0 plays the fadeFromBottomAndroid transition.
    • AppScreen 0 remains unchanged in position (fadeFromBottomAndroid) and AppScreen 1 slides in from the right (slideFromLeftIOS)

Later versions

When the top AppScreen is pushed/popped, non-top AppScreens play the transitionStyle of the top AppScreen.

  • Provides smooth transitions when multiple transitionStyle coexist within the same stack.
  • For example, if AppScreen 1 with transitionStyle="slideFromLeftIOS" is pushed on top of AppScreen 0 with transitionStyle="fadeFromBottomAndroid", AppScreen 0 plays the slideFromLeftIOS transition.
    • AppScreen 0 is naturally pushed slightly to the left and darkened (slideFromLeftIOS) and AppScreen 1 slides in from the right (slideFromLeftIOS)
Loading...

Table of contents