Skip to main content

TopBar

A horizontal top navigation bar for desktop/web layouts.

When to use it

Use TopBar<T> as the primary navigation header for desktop/web apps. Renders a 60px bar with an optional leading area (e.g. a logo), a set of destinations, and trailing actions.

Import

import 'package:catalyst_ui/catalyst_ui.dart';

Usage

TopBar<String>(
leading: const FlutterLogo(),
selectedItem: _section,
onItemSelected: (v) => setState(() => _section = v),
destinations: const [
TopBarDestination(value: 'home', label: 'Home'),
TopBarDestination(value: 'docs', label: 'Docs'),
],
actions: [
Button(label: const Text('Sign out'), onPressed: _onSignOut),
],
)

Parameters

TopBar<T> is generic over the destination value type T.

ParameterTypeDefaultDescription
destinationsList<TopBarDestination<T>>requiredThe list of navigation destinations.
selectedItemTrequiredThe currently selected destination value.
onItemSelectedValueChanged<T>requiredCalled when the user taps a destination.
leadingWidget?nullAn optional widget on the far left.
actionsList<Widget>[]Optional action widgets on the far right.

TopBarDestination<T>

ParameterTypeDefaultDescription
valueTrequiredThe value that identifies this destination.
labelStringrequiredThe text label displayed in the bar.