Skip to main content

AppBar

Top-level application bar with configurable variants, sizes, actions, and full theme token support.

Import

import { AppBar } from '@lazy-panda-ui/lazy-panda-ui';

Usage

Basic

function Basic() {
return <AppBar title="Home" />;
}

Variants

function Variants() {
return (
<>
<AppBar title="Primary" variant="primary" />
<AppBar title="Secondary" variant="secondary" />
<AppBar title="Surface" variant="surface" />
<AppBar title="Elevated" variant="elevated" />
<AppBar title="Transparent" variant="transparent" />
</>
);
}

Sizes and alignment

function Sizes() {
return (
<>
<AppBar title="Small" size="small" />
<AppBar title="Medium" size="medium" />
<AppBar title="Large" size="large" titleAlignment="center" />
</>
);
}

Actions (left/right) and loading/disabled

function Actions() {
const left = [
{ icon: <Text></Text>, label: 'Menu', onPress: () => {} },
];
const right = [
{ icon: <Text></Text>, label: 'Sync', onPress: () => {}, loading: true },
{ icon: <Text></Text>, label: 'Fav', onPress: () => {}, disabled: true },
];

return (
<AppBar title="Dashboard" subtitle="Overview" left={left} right={right} />
);
}

Position and scrollable actions

function Positioning() {
const many = new Array(10).fill(0).map((_, i) => ({ icon: <Text></Text>, label: `A${i+1}`, onPress: () => {} }));
return (
<>
<AppBar title="Fixed" position="fixed" />
<AppBar title="Absolute" position="absolute" />
<AppBar title="Relative" position="relative" />
<AppBar title="Scrollable actions" right={many} scrollable />
</>
);
}

Props

PropTypeDefaultDescription
titlestringrequiredTitle text
subtitlestring-Optional subtitle
leftReact.ReactNode | AppBarAction[]-Left content or actions
rightReact.ReactNode | AppBarAction[]-Right content or actions
variant'primary' \'secondary' \'transparent' \
position'fixed' \'absolute' \'relative'
elevationbooleantrueShow shadow/elevation
size'small' \'medium' \'large'
titleAlignment'start' \'center''start'
hideOnScrollbooleanfalseSlide away on scroll (fixed only)
showBorderbooleanfalseBottom hairline border
scrollablebooleanfalseMakes actions area horizontally scrollable
backgroundColorstring-Overrides variant background
statusBarStyle'light' \'dark' \'auto'
styleStyleProp<ViewStyle>-Container styles
titleStyleStyleProp<TextStyle>-Title text styles
subtitleStyleStyleProp<TextStyle>-Subtitle text styles
testIDstring-Test identifier

AppBarAction:

KeyTypeDescription
iconReact.ReactNodeIcon to render
labelstringAccessibility label and optional text
onPress() => voidPress handler
disabledbooleanDisable interaction
loadingbooleanShow ActivityIndicator

Theming

AppBar is theme-driven. Override theme.appBar tokens via ThemeProvider to customize globally.

import { ThemeProvider, createTheme } from '@lazy-panda-ui/lazy-panda-ui';

const customTheme = createTheme({
appBar: {
heights: { small: 44, medium: 56, large: 72 },
paddingX: 20,
action: { borderRadius: 8, spacing: 6 },
title: { fontSize: 18, fontWeight: '600' },
subtitle: { fontSize: 12, opacity: 0.9 },
variants: {
primary: { background: '#111827', foreground: '#F9FAFB', borderColor: '#1F2937', elevation: 4 },
secondary: { background: '#4B5563', foreground: '#F9FAFB', borderColor: '#374151', elevation: 4 },
surface: { background: '#FFFFFF', foreground: '#111827', borderColor: '#E5E7EB', elevation: 0 },
elevated: { background: '#F3F4F6', foreground: '#111827', borderColor: '#E5E7EB', elevation: 2 },
transparent: { background: 'transparent', foreground: '#111827', borderColor: '#E5E7EB', elevation: 0 },
},
},
});

export function App() {
return (
<ThemeProvider theme={customTheme}>
<AppBar title="Themed AppBar" variant="primary" />
</ThemeProvider>
);
}

Notes:

  • Colors, heights, spacing, fonts, and elevation are token-driven; set once to affect all AppBars.
  • Styles and handlers are memoized to reduce re-renders.