import { AppBar } from "@vortexlabs/vortex-native";
<AppBar
title="Messages"
subtitle="Team inbox"
variant="default"
scrolled={false}
revealTitleOnScroll={false}
/>Features
- Supports start-aligned and centered titles.
- Fits actions beside the title and content below it.
- Collapses a large title or fills a transparent surface as content scrolls.
Title and Subtitle
Set titleAlign="center" to center the compact title and subtitle. A large title starts at the leading edge and shows its subtitle after collapse.
<AppBar title="Inbox" subtitle="12 unread" titleAlign="center" />In Vortex Native 0.5.0, the browser preview can collapse the width of a centered title and subtitle.
Action Slots
Use startSlot for Cancel or Back and bottomSlot for a full-width search field. Use one tertiary Button or up to two icon actions in endSlot.
import { Search } from "@vortexlabs/vortex-icons";
import { AppBar, Button, SearchField, Stack } from "@vortexlabs/vortex-native";
import React from "react";
export const LibrarySearch = () => {
const [searchOpen, setSearchOpen] = React.useState(false);
const [query, setQuery] = React.useState("");
const [submittedQuery, setSubmittedQuery] = React.useState("");
return (
<Stack width={360} maxWidth="100%">
<AppBar
title="Library"
subtitle={submittedQuery ? `Search: ${submittedQuery}` : undefined}
buttonVariant="fill"
startSlot={
searchOpen && (
<Button
variant="tertiary"
size="sm"
onPress={() => setSearchOpen(false)}
>
Cancel
</Button>
)
}
endSlot={
searchOpen ? (
<Button
variant="tertiary"
size="sm"
disabled={!query.trim()}
onPress={() => {
setSubmittedQuery(query.trim());
setSearchOpen(false);
}}
>
Done
</Button>
) : (
<AppBar.Button
icon={Search}
ariaLabel="Show search"
onPress={() => {
setQuery(submittedQuery);
setSearchOpen(true);
}}
/>
)
}
bottomSlot={
searchOpen && (
<SearchField
name="library"
label="Search books"
placeholder="Search by title"
value={query}
onChange={({ value }) => setQuery(value)}
/>
)
}
/>
</Stack>
);
};AppBar.Button
Use AppBar.Button for icon actions. Set buttonVariant="fill" on the bar to put each icon in a filled circle. Set flipRTL on a directional icon such as Back.
import { ChevronLeft, FontCase, StarAlt } from "@vortexlabs/vortex-icons";
import { AppBar, Button, Stack, Text } from "@vortexlabs/vortex-native";
import React from "react";
export const ArticleActions = () => {
const [isOpen, setIsOpen] = React.useState(true);
const [isSaved, setIsSaved] = React.useState(false);
const [isLargeText, setIsLargeText] = React.useState(false);
const [hasFilledButtons, setHasFilledButtons] = React.useState(false);
if (!isOpen) {
return <Button onPress={() => setIsOpen(true)}>Open article</Button>;
}
return (
<Stack width={340} maxWidth="100%" gap={3}>
<AppBar
title="Reading list"
buttonVariant={hasFilledButtons ? "fill" : "plain"}
startSlot={
<AppBar.Button
icon={ChevronLeft}
ariaLabel="Back"
flipRTL
onPress={() => setIsOpen(false)}
/>
}
endSlot={
<>
<AppBar.Button
icon={StarAlt}
ariaLabel={isSaved ? "Remove bookmark" : "Bookmark article"}
onPress={() => setIsSaved(!isSaved)}
/>
<AppBar.Button
icon={FontCase}
ariaLabel={
isLargeText ? "Use standard text size" : "Increase text size"
}
onPress={() => setIsLargeText(!isLargeText)}
/>
</>
}
/>
<Text size={isLargeText ? "heading-sm" : "body-md"}>
{isSaved ? "The bookshop · Bookmarked" : "The bookshop"}
</Text>
<Button
variant="secondary"
onPress={() => setHasFilledButtons(!hasFilledButtons)}
>
{hasFilledButtons ? "Use plain buttons" : "Use filled buttons"}
</Button>
</Stack>
);
};Large Title
Use variant="large" for a title that collapses into the bar. Set scrolled when your screen tracks scroll state.
import { AppBar, ScrollArea, Stack, Text } from "@vortexlabs/vortex-native";
import React from "react";
import { View } from "react-native";
const books = [
"The Left Hand of Darkness",
"Kindred",
"The Dispossessed",
"Parable of the Sower",
"The Fifth Season",
"A Memory Called Empire",
"The Long Way to a Small, Angry Planet",
"Ancillary Justice",
];
export const ScrollableLibrary = () => {
const [scrolled, setScrolled] = React.useState(false);
const scrolledRef = React.useRef(false);
return (
<View style={{ width: 360, maxWidth: "100%", height: 210 }}>
<AppBar
title="Library"
subtitle="Browse books"
variant="large"
scrolled={scrolled}
/>
<ScrollArea
style={{ flex: 1 }}
onScroll={({ y }) => {
const isScrolled = y > 0.2;
if (isScrolled !== scrolledRef.current) {
scrolledRef.current = isScrolled;
setScrolled(isScrolled);
}
}}
>
<Stack padding={4} gap={4}>
{books.map((book) => (
<Text key={book}>{book}</Text>
))}
</Stack>
</ScrollArea>
</View>
);
};Transparent Surface
Use variant="transparent" over a cover image. The bar gains a background when scrolled, and its icon buttons always use the filled style.
import { StarAlt } from "@vortexlabs/vortex-icons";
import { AppBar, Button, Image, Stack } from "@vortexlabs/vortex-native";
import React from "react";
import { View } from "react-native";
export const AlbumCoverBar = () => {
const [scrolled, setScrolled] = React.useState(false);
const [isSaved, setIsSaved] = React.useState(false);
return (
<Stack width={340} maxWidth="100%" gap={3}>
<View>
<Image
src="https://cdn.vortex.design/docs/components/image/sydney.webp"
alt="Sydney Harbour"
width="100%"
height={160}
/>
<AppBar
title="Sydney"
subtitle={isSaved ? "Saved to albums" : undefined}
variant="transparent"
scrolled={scrolled}
endSlot={
<AppBar.Button
icon={StarAlt}
ariaLabel={isSaved ? "Remove saved photo" : "Save photo"}
onPress={() => setIsSaved(!isSaved)}
/>
}
style={{ position: "absolute", top: 0, start: 0, end: 0 }}
attributes={{ testID: "album-app-bar" }}
/>
</View>
<Button variant="secondary" onPress={() => setScrolled(!scrolled)}>
{scrolled ? "Show at the top" : "Show after scrolling"}
</Button>
</Stack>
);
};Title and Divider on Scroll
Set revealTitleOnScroll on a default bar to show its title and subtitle once it’s scrolled. Set showDivider to draw a divider at the bottom in the scrolled state.
import { AppBar, Button, Stack } from "@vortexlabs/vortex-native";
import React from "react";
export const ScrollRevealBar = () => {
const [isScrolled, setIsScrolled] = React.useState(false);
return (
<Stack width={360} maxWidth="100%" gap={3}>
<AppBar
title="Order details"
subtitle="Order 1042"
revealTitleOnScroll
showDivider
scrolled={isScrolled}
/>
<Button variant="secondary" onPress={() => setIsScrolled((current) => !current)}>
{isScrolled ? "Show at the top" : "Show after scrolling"}
</Button>
</Stack>
);
};Scroll Offset
Pass a Reanimated shared value as scrollOffset to drive the transition. It takes precedence over scrolled. Set scrolledOffset in points to delay the transition. A large title starts collapsing at that offset and finishes after scrolling the height of its expanded row.
For a transparent bar over an image, subtract the bar’s height from the image’s height so the background starts filling as the bottom of the image reaches the bar.
import { AppBar, Image } from "@vortexlabs/vortex-native";
import React from "react";
import { View } from "react-native";
import Animated, { useAnimatedScrollHandler, useSharedValue } from "react-native-reanimated";
type Props = {
cover: string;
coverAlt: string;
children: React.ReactNode;
};
export const AlbumScreen = (props: Props) => {
const { cover, coverAlt, children } = props;
const coverHeight = 220;
const [barHeight, setBarHeight] = React.useState(0);
const scrollOffset = useSharedValue(0);
const onScroll = useAnimatedScrollHandler((event) => {
scrollOffset.value = event.contentOffset.y;
});
return (
<View style={{ flex: 1 }}>
<Animated.ScrollView onScroll={onScroll} scrollEventThrottle={16}>
<Image src={cover} alt={coverAlt} width="100%" height={coverHeight} />
{children}
</Animated.ScrollView>
<AppBar
title="Album"
variant="transparent"
scrollOffset={scrollOffset}
scrolledOffset={Math.max(0, coverHeight - barHeight)}
attributes={{ onLayout: ({ nativeEvent }) => setBarHeight(nativeEvent.layout.height) }}
style={{ position: "absolute", top: 0, start: 0, end: 0 }}
/>
</View>
);
};The screen manages safe-area insets and status bar icon contrast. See App Surfaces for provider configuration.
Accessibility
revealTitleOnScroll becomes available to assistive technology once it is revealed.AppBar.Button an ariaLabel that describes its action.