A navigation bar component that displays the current screen's title and navigation actions at the top of the screen.
@seed-design/lynx-react@0.2.0, @seed-design/lynx-css@0.2.0
import "./styles" ;
import IconBellLine from "@karrotmarket/lynx-monochrome-icon/IconBellLine" ;
import { useSeedClassName } from "@seed-design/lynx-react" ;
import {
AppBar,
AppBarBackButton,
AppBarIconButton,
AppBarLeft,
AppBarMain,
AppBarRight,
} from "@/components/ui/app-bar" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-app-bar-root` }>
< view className = "app-bar-preview" >
< AppBar theme = "cupertino" >
< AppBarLeft >
< AppBarBackButton />
</ AppBarLeft >
< AppBarMain title = "동네생활" />
< AppBarRight >
< AppBarIconButton accessibility-label = "알림" icon = {< IconBellLine />} />
</ AppBarRight >
</ AppBar >
< view className = "app-bar-preview__content" >
< text className = "app-bar-preview__status" >화면 콘텐츠</ text >
</ view >
</ view >
</ view >
);
}
npx @seed-design/cli add ui:app-bar pnpm dlx @seed-design/cli add ui:app-bar yarn dlx @seed-design/cli add ui:app-bar bun x @seed-design/cli add ui:app-bar
Install dependencies
npm install @karrotmarket/lynx-monochrome-icon @seed-design/lynx-react yarn add @karrotmarket/lynx-monochrome-icon @seed-design/lynx-react pnpm add @karrotmarket/lynx-monochrome-icon @seed-design/lynx-react bun add @karrotmarket/lynx-monochrome-icon @seed-design/lynx-react Copy the code below and paste it in /**
* @file ui:app-bar
* @requires @seed-design/lynx-react@>=0.1.0 <1.0.0
* @requires @seed-design/lynx-css@>=0.1.0 <1.0.0
**/
import IconChevronLeftLine from "@karrotmarket/lynx-monochrome-icon/IconChevronLeftLine" ;
import IconXmarkLine from "@karrotmarket/lynx-monochrome-icon/IconXmarkLine" ;
import { forwardRef, type ReactNode } from "@lynx-js/react" ;
import { AppBar as SeedAppBar } from "@seed-design/lynx-react" ;
export interface AppBarProps extends SeedAppBar . RootProps {}
/**
* @see https://crispy.carrot-soft.tech/lynx/components/app-bar
*/
export const AppBar = SeedAppBar.Root;
export interface AppBarLeftProps extends SeedAppBar . LeftProps {}
export const AppBarLeft = SeedAppBar.Left;
export interface AppBarRightProps extends SeedAppBar . RightProps {}
export const AppBarRight = SeedAppBar.Right;
export interface AppBarSlotProps extends SeedAppBar . SlotProps {}
export const AppBarSlot = SeedAppBar.Slot;
export interface AppBarMainProps extends SeedAppBar . MainProps {
/**
* The title of the app bar.
* If custom children are provided, this prop will be ignored.
*/
title ?: ReactNode ;
/**
* The subtitle of the app bar.
* If custom children are provided, this prop will be ignored.
*/
subtitle ?: ReactNode ;
}
function shouldRenderCustomMain ( children : ReactNode ) {
return (
children != null &&
typeof children !== "string" &&
typeof children !== "number" &&
typeof children !== "boolean"
);
}
export const AppBarMain = forwardRef < unknown , AppBarMainProps >(
({ title , subtitle , children , ... otherProps }, ref ) => {
if ( shouldRenderCustomMain (children)) {
return (
< SeedAppBar.Main ref = {ref} { ... otherProps}>
{children}
</ SeedAppBar.Main >
);
}
return (
< SeedAppBar.Main ref = {ref} layout = {subtitle ? "withSubtitle" : "titleOnly" } { ... otherProps}>
< SeedAppBar.Title >{children ?? title}</ SeedAppBar.Title >
{subtitle ? < SeedAppBar.Subtitle >{subtitle}</ SeedAppBar.Subtitle > : null }
</ SeedAppBar.Main >
);
},
);
AppBarMain.displayName = "AppBarMain" ;
export interface AppBarIconButtonProps extends SeedAppBar . IconButtonProps {}
export const AppBarIconButton = SeedAppBar.IconButton;
export interface AppBarBackButtonProps extends Omit < AppBarIconButtonProps , "icon" > {
icon ?: AppBarIconButtonProps [ "icon" ];
}
export const AppBarBackButton = forwardRef < unknown , AppBarBackButtonProps >(
(
{
icon = < IconChevronLeftLine />,
"accessibility-label" : accessibilityLabel = "뒤로" ,
... otherProps
},
ref,
) => {
return (
< AppBarIconButton
ref = {ref}
accessibility-label = {accessibilityLabel}
icon = {icon}
{ ... otherProps}
/>
);
},
);
AppBarBackButton.displayName = "AppBarBackButton" ;
export interface AppBarCloseButtonProps extends Omit < AppBarIconButtonProps , "icon" > {
icon ?: AppBarIconButtonProps [ "icon" ];
}
export const AppBarCloseButton = forwardRef < unknown , AppBarCloseButtonProps >(
(
{ icon = < IconXmarkLine />, "accessibility-label" : accessibilityLabel = "닫기" , ... otherProps },
ref,
) => {
return (
< AppBarIconButton
ref = {ref}
accessibility-label = {accessibilityLabel}
icon = {icon}
{ ... otherProps}
/>
);
},
);
AppBarCloseButton.displayName = "AppBarCloseButton" ;
/**
* This file is a snippet from Crispy, helping you get started quickly with @seed-design/* packages.
* You can extend this snippet however you want.
*/
style?CSSProperties | undefined
children?ReactNode
className?string | undefined
bindlayoutchange?EventHandler < LayoutChangeDetailEvent < Target >> | undefined
style?CSSProperties | undefined
children?ReactNode
className?string | undefined
layout?"titleOnly" | "withSubtitle" | undefined
theme?"cupertino" | "android" | undefined
transitionStyle?"slideFromRightIOS" | "fadeFromBottomAndroid" | "fadeIn" | undefined
tone?"layer" | "transparent" | undefined
style?CSSProperties | undefined
children?ReactNode
className?string | undefined
bindlayoutchange?EventHandler < LayoutChangeDetailEvent < Target >> | undefined
style?CSSProperties | undefined
children?ReactNode
className?string | undefined
style?CSSProperties | undefined
children?ReactNode
className?string | undefined
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
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
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
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 >
);
}
Passing title and subtitle to AppBarMain internally assembles AppBar.Title and AppBar.Subtitle. If subtitle exists, layout="withSubtitle" is automatically applied.
import "./styles" ;
import { useSeedClassName } from "@seed-design/lynx-react" ;
import { AppBar, AppBarMain } from "@/components/ui/app-bar" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-app-bar-root` }>
< view className = "app-bar-preview" >
< AppBar theme = "cupertino" >
< AppBarMain title = "관심 목록" subtitle = "3개의 새 소식" />
</ AppBar >
< view className = "app-bar-preview__content" >
< text className = "app-bar-preview__status" >제목과 부제목을 함께 표시한 AppBar</ text >
</ view >
</ view >
</ view >
);
}
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 >
);
}
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.
import "./styles" ;
import { useState } from "@lynx-js/react" ;
import { useSeedClassName } from "@seed-design/lynx-react" ;
import {
AppBar,
AppBarBackButton,
AppBarCloseButton,
AppBarLeft,
AppBarMain,
AppBarRight,
AppBarSlot,
} from "@/components/ui/app-bar" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
const [ lastAction , setLastAction ] = useState ( "없음" );
function handleBack () {
"background only" ;
setLastAction ( "뒤로" );
}
function handleClose () {
"background only" ;
setLastAction ( "닫기" );
}
return (
< view className = { `${ seedClassName } docs-lynx-app-bar-root` }>
< view className = "app-bar-preview" >
< AppBar theme = "cupertino" >
< AppBarLeft >
< AppBarBackButton bindtap = {handleBack} />
</ AppBarLeft >
< AppBarMain title = "작성하기" />
< AppBarRight >
< AppBarSlot >
< text >완료</ text >
</ AppBarSlot >
< AppBarCloseButton bindtap = {handleClose} />
</ AppBarRight >
</ AppBar >
< view className = "app-bar-preview__content" >
< text className = "app-bar-preview__status" >마지막 액션: {lastAction}</ text >
</ view >
</ view >
</ view >
);
}
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 >
);
}
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.
import "./styles" ;
import IconBellLine from "@karrotmarket/lynx-monochrome-icon/IconBellLine" ;
import IconMagnifyingglassLine from "@karrotmarket/lynx-monochrome-icon/IconMagnifyingglassLine" ;
import { useState } from "@lynx-js/react" ;
import { ActionButton, useSeedClassName } from "@seed-design/lynx-react" ;
import {
AppBar,
AppBarBackButton,
AppBarCloseButton,
AppBarIconButton,
AppBarLeft,
AppBarMain,
AppBarRight,
} from "@/components/ui/app-bar" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
const [ showExtraActions , setShowExtraActions ] = useState ( true );
const [ lastAction , setLastAction ] = useState ( "없음" );
function toggleExtraActions () {
"background only" ;
setShowExtraActions (( value ) => ! value);
}
function recordAction ( action : string ) {
"background only" ;
setLastAction (action);
}
return (
< view className = { `${ seedClassName } docs-lynx-app-bar-root` }>
< view className = "app-bar-preview" >
< AppBar theme = "cupertino" >
< AppBarLeft >
< AppBarBackButton bindtap = {() => recordAction ( "뒤로" )} />
</ AppBarLeft >
< AppBarMain title = "동네생활" />
< AppBarRight >
< AppBarIconButton
accessibility-label = "알림"
icon = {< IconBellLine />}
bindtap = {() => recordAction ( "알림" )}
/>
{showExtraActions && (
<>
< AppBarIconButton
accessibility-label = "검색"
icon = {< IconMagnifyingglassLine />}
bindtap = {() => recordAction ( "검색" )}
/>
< AppBarCloseButton bindtap = {() => recordAction ( "닫기" )} />
</>
)}
</ AppBarRight >
</ AppBar >
< view className = "app-bar-preview__content app-bar-preview__controls" >
< ActionButton size = "small" variant = "neutralWeak" bindtap = {toggleExtraActions}>
{showExtraActions ? "검색·닫기 숨기기" : "검색·닫기 표시" }
</ ActionButton >
< text className = "app-bar-preview__status" >마지막 액션: {lastAction}</ text >
</ view >
</ view >
</ view >
);
}
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.
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.
import "./styles" ;
import { useState } from "@lynx-js/react" ;
import { useSeedClassName } from "@seed-design/lynx-react" ;
import {
AppBar,
AppBarBackButton,
AppBarCloseButton,
AppBarLeft,
AppBarMain,
AppBarRight,
} from "@/components/ui/app-bar" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
const [ lastAction , setLastAction ] = useState ( "배경 위에 겹쳐지는 AppBar" );
function handleBack () {
"background only" ;
setLastAction ( "뒤로 버튼을 눌렀습니다" );
}
function handleClose () {
"background only" ;
setLastAction ( "닫기 버튼을 눌렀습니다" );
}
return (
< view className = { `${ seedClassName } docs-lynx-app-bar-root` }>
< view className = "app-bar-preview app-bar-preview--transparent" >
< AppBar theme = "cupertino" tone = "transparent" >
< AppBarLeft >
< AppBarBackButton bindtap = {handleBack} />
</ AppBarLeft >
< AppBarMain title = "사진 보기" />
< AppBarRight >
< AppBarCloseButton bindtap = {handleClose} />
</ AppBarRight >
</ AppBar >
< view className = "app-bar-preview__content" >
< text className = "app-bar-preview__overlay-text" >{lastAction}</ text >
</ view >
</ view >
</ view >
);
}
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 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.
import "./styles" ;
import { useSeedClassName } from "@seed-design/lynx-react" ;
import {
AppBar,
AppBarBackButton,
AppBarCloseButton,
AppBarLeft,
AppBarMain,
AppBarRight,
} from "@/components/ui/app-bar" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-app-bar-root` }>
< view className = "app-bar-preview__platforms" >
< view className = "app-bar-preview__platform" >
< text className = "app-bar-preview__label" >Cupertino</ text >
< view className = "app-bar-preview app-bar-preview--platform" >
< AppBar theme = "cupertino" >
< AppBarLeft >
< AppBarBackButton />
</ AppBarLeft >
< AppBarMain title = "화면 제목" subtitle = "보조 제목" />
< AppBarRight >
< AppBarCloseButton />
</ AppBarRight >
</ AppBar >
</ view >
</ view >
< view className = "app-bar-preview__platform" >
< text className = "app-bar-preview__label" >Android</ text >
< view className = "app-bar-preview app-bar-preview--platform" >
< AppBar theme = "android" >
< AppBarLeft >
< AppBarBackButton />
</ AppBarLeft >
< AppBarMain title = "화면 제목" subtitle = "보조 제목" />
< AppBarRight >
< AppBarCloseButton />
</ AppBarRight >
</ AppBar >
</ view >
</ view >
</ view >
</ view >
);
}
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.
Currently, Lynx AppBar is provided as a pure UI component and does not include the following features.
Feature Web Equivalent Alternative Method Stackflow activity integration useActivity, useActions based back/close handlingDirectly call app's navigation function in bindtap Swipe-back transition animation Stackflow screen transition Handle in navigation layer that owns screen transition data-* selector based state stylingWeb recipe selector Use theme, tone variant className HTML button attributes type, DOM click eventUse Lynx <view> based AppBarIconButton and bindtap HTML ARIA labels aria-labelUse Lynx native accessibility-label