Skip to main content

App Bar

A screen header built from composable slots: AppBar.Header, AppBar.Title, AppBar.BackAction, and AppBar.IconButton. Left, center, and right content are detected automatically from the children you pass in. Both icon slots accept any component matching TVajraIconComponent; the examples below use @88khp/vajra-icons, a small set of Lucide icons pre-adapted to that contract.

Basic title​

Screen Title
<AppBar.Header>
<AppBar.Title>Screen Title</AppBar.Title>
</AppBar.Header>

With back action and trailing icon​

Profile
<AppBar.Header>
<AppBar.BackAction icon={ChevronLeftIcon} onPress={() => {}} />
<AppBar.Title>Profile</AppBar.Title>
<AppBar.IconButton icon={SettingsIcon} onPress={() => {}} accessibilityLabel="More" />
</AppBar.Header>

Centered title​

When centered is set on AppBar.Title, it's positioned absolutely so it stays centered regardless of side content width.

Centered
<AppBar.Header>
<AppBar.BackAction icon={ChevronLeftIcon} onPress={() => {}} />
<AppBar.Title centered>Centered</AppBar.Title>
<AppBar.IconButton icon={SettingsIcon} onPress={() => {}} accessibilityLabel="More" />
</AppBar.Header>

Multiple trailing actions​

AppBar.IconButton can be used more than once; every instance is collected into the right-hand slot, in order.

Recipe
<AppBar.Header>
<AppBar.BackAction icon={ChevronLeftIcon} onPress={() => {}} />
<AppBar.Title>Recipe</AppBar.Title>
<AppBar.IconButton icon={SearchIcon} onPress={() => {}} accessibilityLabel="Search" />
<AppBar.IconButton icon={HeartIcon} onPress={() => {}} accessibilityLabel="Save" />
</AppBar.Header>

Custom colors​

bg and tint aren't limited to the default primary/textInverse pairing: any theme color token works, so a bar can match a surface header instead of standing out as a colored band.

Settings
<AppBar.Header bg="surface" tint="text">
<AppBar.BackAction icon={ChevronLeftIcon} onPress={() => {}} />
<AppBar.Title>Settings</AppBar.Title>
<AppBar.IconButton icon={SettingsIcon} onPress={() => {}} accessibilityLabel="More" />
</AppBar.Header>

Props​

AppBar.Header​

PropTypeDefaultDescription
childrenReactNodeRequired. Detects AppBar.BackAction (left), AppBar.IconButton (right), and AppBar.Title (center) automatically.
styleViewStyleStyle applied to the outer container.
contentStyleViewStyleStyle applied to the inner row that holds the slots.
heightnumber56Height of the content row.
useSafeAreabooleantrueAdds top safe-area inset padding.
bgTVajraColorstheme.appBar.bg ('primary')Background color token. Set the default once with createVajraTheme({ appBar: { bg } }).
tintTVajraColorstheme.appBar.tint ('textInverse')Color applied to the title text and icon buttons.

AppBar.Title​

PropTypeDefaultDescription
childrenReactNodeRequired. Title text/content.
centeredbooleanfalseAbsolutely centers the title, ignoring side slot widths.

AppBar.BackAction​

PropTypeDefaultDescription
iconTVajraIconComponentRequired. Icon component receiving size, width, height, color.
onPress() => voidFalls back to the navigation back behaviourPress handler.

AppBar.IconButton​

PropTypeDefaultDescription
iconTVajraIconComponentRequired. Icon component receiving size, width, height, color.
onPress() => voidPress handler.
accessibilityLabelstring'Action'Accessibility label for the pressable.