Lynx

AppBar

A navigation bar component that displays the current screen's title and navigation actions at the top of the screen.

Engine ≥ 3.6
Available since@seed-design/lynx-react@0.2.0, @seed-design/lynx-css@0.2.0
Loading Lynx example…

Installation

npx @seed-design/cli add ui:app-bar

Props

AppBar

Prop

Type

style?CSSProperties | undefined
children?ReactNode
className?string | undefined

AppBarLeft

Prop

Type

bindlayoutchange?EventHandler<LayoutChangeDetailEvent<Target>> | undefined
style?CSSProperties | undefined
children?ReactNode
className?string | undefined

AppBarMain

Prop

Type

style?CSSProperties | undefined
children?ReactNode
className?string | undefined

AppBarRight

Prop

Type

bindlayoutchange?EventHandler<LayoutChangeDetailEvent<Target>> | undefined
style?CSSProperties | undefined
children?ReactNode
className?string | undefined

AppBarSlot

Prop

Type

style?CSSProperties | undefined
children?ReactNode
className?string | undefined

AppBarIconButton

Prop

Type

icon?ReactElement<LynxIconElementProps, string | JSXElementConstructor<any>> | undefined
accessibility-label?string | undefined
accessibility-element?boolean | undefined
accessibility-traits?"text" | "image" | "button" | "link" | "header" | "search" | "selected" | "playable" | "keyboard" | "summary" | "disabled" | "updating" | "adjustable" | "tabbar" | "none" | undefined
className?string | undefined
children?ReactNode
bindtap?EventHandler<BaseTouchEvent<Target>> | undefined
main-thread:bindtap?EventHandler<BaseTouchEvent<Element>> | undefined

AppBarBackButton

Prop

Type

icon?ReactElement<LynxIconElementProps, string | JSXElementConstructor<any>> | undefined
className?string | undefined
bindtap?EventHandler<BaseTouchEvent<Target>> | undefined
main-thread:bindtap?EventHandler<BaseTouchEvent<Element>> | undefined
children?ReactNode
accessibility-label?string | undefined
accessibility-element?boolean | undefined
accessibility-traits?"text" | "image" | "button" | "link" | "header" | "search" | "selected" | "playable" | "keyboard" | "summary" | "disabled" | "updating" | "adjustable" | "tabbar" | "none" | undefined

AppBarCloseButton

Prop

Type

icon?ReactElement<LynxIconElementProps, string | JSXElementConstructor<any>> | undefined
className?string | undefined
bindtap?EventHandler<BaseTouchEvent<Target>> | undefined
main-thread:bindtap?EventHandler<BaseTouchEvent<Element>> | undefined
children?ReactNode
accessibility-label?string | undefined
accessibility-element?boolean | undefined
accessibility-traits?"text" | "image" | "button" | "link" | "header" | "search" | "selected" | "playable" | "keyboard" | "summary" | "disabled" | "updating" | "adjustable" | "tabbar" | "none" | undefined

Usage

The installed snippet exports the Root and main slots as AppBar, AppBarLeft, AppBarMain, AppBarRight. AppBarBackButton and AppBarCloseButton provide only default icons; actual navigation logic is passed directly via bindtap.

import {
  AppBar,
  AppBarBackButton,
  AppBarLeft,
  AppBarMain,
  AppBarRight,
} from "@/components/ui/app-bar";

export function Header({ goBack }: { goBack: () => void }) {
  return (
    <AppBar>
      <AppBarLeft>
        <AppBarBackButton bindtap={goBack} />
      </AppBarLeft>
      <AppBarMain title="Community" />
      <AppBarRight />
    </AppBar>
  );
}

Title / Subtitle

Passing title and subtitle to AppBarMain internally assembles AppBar.Title and AppBar.Subtitle. If subtitle exists, layout="withSubtitle" is automatically applied.

Loading Lynx example…

To directly assemble slots, pass compound components as children to AppBarMain.

import { AppBar, AppBarMain } from "@/components/ui/app-bar";
import { AppBar as SeedAppBar } from "@seed-design/lynx-react";

export function Header() {
  return (
    <AppBar>
      <AppBarMain layout="withSubtitle">
        <SeedAppBar.Title>Title</SeedAppBar.Title>
        <SeedAppBar.Subtitle>Subtitle</SeedAppBar.Subtitle>
      </AppBarMain>
    </AppBar>
  );
}

Left / Right Action

Icon buttons or custom slots can be placed on the left and right. In Cupertino theme, slot widths are read to adjust padding so the center title is not offset.

Both AppBarLeft and AppBarRight adjust left padding if the first child is an icon button, and right padding if the last child is an icon button. With only one button, both sides are adjusted. Negative margins equal to the space between 44px touch area and 24px icon are applied to maintain touch area while aligning screen edge and title spacing to React slot adjustment rules.

Since slots pass edge position via Context, it applies automatically to AppBarBackButton / AppBarCloseButton and custom-made AppBarIconButton. Fragments and conditional children are supported; automatic adjustment is not passed inside AppBarSlot or native layout boxes. Specifying edge="leading" | "trailing" | "both" overrides the automatic adjustment direction.

Loading Lynx example…

To use an icon other than AppBarBackButton / AppBarCloseButton, pass a Lynx icon to the icon prop of AppBarIconButton to construct directly. When placed at the edge, it is automatically aligned the same as above.

import IconBellLine from "@karrotmarket/lynx-monochrome-icon/IconBellLine";
import {
  AppBar,
  AppBarBackButton,
  AppBarIconButton,
  AppBarLeft,
  AppBarMain,
  AppBarRight,
} from "@/components/ui/app-bar";

export function Header({ goBack }: { goBack: () => void }) {
  return (
    <AppBar>
      <AppBarLeft>
        <AppBarBackButton bindtap={goBack} />
      </AppBarLeft>
      <AppBarMain title="Community" />
      <AppBarRight>
        <AppBarIconButton accessibility-label="Notifications" icon={<IconBellLine />} />
      </AppBarRight>
    </AppBar>
  );
}

Multiple / Conditional Actions

When multiple buttons are in the slot, edge padding adjustment is applied only to the first and last buttons. The center button's touch area remains unchanged. With conditional rendering, if only one button remains, both sides auto-adjust padding.

In the example below, the title remains centered even if search and close buttons are hidden or shown again. You can press each icon button to check the last action.

Loading Lynx example…

Custom Slot / Explicit Edge

Custom layout boxes or buttons inside AppBarSlot do not have automatic edge padding applied. Only specify the direction with edge when managing internal layout directly. For typical AppBarLeft / AppBarRight buttons, no specification is needed.

<AppBarRight>
  <AppBarSlot>
    <AppBarCloseButton edge="trailing" bindtap={close} />
  </AppBarSlot>
</AppBarRight>

leading adjusts left padding, trailing adjusts right padding, and both adjusts both sides. Explicitly set values take priority over automatic adjustment, and the button's touch area size doesn't change.

Tone

The default tone="layer" shows the layer background. tone="transparent" makes the background transparent and applies bright colors to the title and icons, so use it over photos or dark backgrounds. Tone transitions based on background and scroll are managed at the call site.

Loading Lynx example…

Accessibility

In Lynx, use Lynx native accessibility attributes instead of HTML ARIA attributes. AppBarIconButton applies accessibility-element={true} and accessibility-traits="button" by default, and accessibility-label must be passed for buttons whose meaning cannot be understood from icons alone.

import IconBellLine from "@karrotmarket/lynx-monochrome-icon/IconBellLine";

<AppBarIconButton accessibility-label="Notifications" icon={<IconBellLine />} />

AppBarBackButton and AppBarCloseButton provide "Back" and "Close" labels as defaults respectively.

Theme

theme can use "cupertino" or "android". If not specified, AppBar reads SystemInfo.platform internally and uses "android" on Android, "cupertino" on other platforms or when no value is present.

<AppBar>
  <AppBarMain title="Auto theme" />
</AppBar>

Manually specified theme takes priority over platform defaults.

Loading Lynx example…

Web Version Differences

Lynx AppBar provides the same roles and variant names as React AppBar, but platform-specific Recipe and screen transition responsibilities differ.

  • Event Handling: Pass Lynx event bindtap instead of onClick.
  • Rendering Elements: Render native <view> / <text> elements instead of HTML elements.
  • Accessibility Labeling: Use Lynx native accessibility-label instead of aria-label.
  • Platform Theme: Does not depend on data-* selectors like the web, but applies "cupertino" / "android" design using recipe variant classNames.
  • Navigation Responsibility: AppBarBackButton and AppBarCloseButton do not automatically execute navigation. Operations like Stackflow pop() are connected at the call site.
  • Edge Icon Alignment: The web uses iconButton:first-child / :last-child selector to adjust bleed, but Lynx doesn't support these pseudo-classes, so AppBarLeft / AppBarRight passes edge position via Context and adjusts via Recipe class of icon button. This applies precisely only to edge icon buttons even in multi-button and custom slot cases.

Unsupported Lynx Features

Currently, Lynx AppBar is provided as a pure UI component and does not include the following features.

FeatureWeb EquivalentAlternative Method
Stackflow activity integrationuseActivity, useActions based back/close handlingDirectly call app's navigation function in bindtap
Swipe-back transition animationStackflow screen transitionHandle in navigation layer that owns screen transition
data-* selector based state stylingWeb recipe selectorUse theme, tone variant className
HTML button attributestype, DOM click eventUse Lynx <view> based AppBarIconButton and bindtap
HTML ARIA labelsaria-labelUse Lynx native accessibility-label

Table of contents