Overview
AppBar is a simple composable function that renders a Material 3 top app bar with the application title. It provides consistent branding and navigation structure for the Voice to Text app.
Function signature
This composable uses the
@OptIn(ExperimentalMaterial3Api::class) annotation because TopAppBar is currently an experimental API in Material 3.Parameters
This composable does not accept any parameters.Implementation
UI components
TopAppBar
The composable uses Material 3’sTopAppBar component with the following configuration:
A composable lambda that displays “Voice to Text App” in white text
Applies custom colors using
TopAppBarDefaults.topAppBarColors() with the container background set to the theme’s primary colorStyling
The app bar features:- Title text: “Voice to Text App” in white color
- Background color: Uses
MaterialTheme.colorScheme.primaryfor the container background, ensuring consistency with the app’s theme
Usage
TheAppBar is typically used as the topBar parameter in a Scaffold composable:
Required imports
The app bar uses the theme’s primary color scheme, which means its appearance will automatically adapt based on the app’s theme configuration.