JGuang

App Bar

App Bar · Material UI

Preview
npm install @mui/material@9.4.0 @emotion/react@11.14.0 @emotion/styled@11.14.1

App Bar

Provide the current screen's top-level navigation and actions.

This guide covers Material UI Core with the default Emotion engine; extensions and additional demos are explicitly classified.

Use case and business boundary

Navigation destinations and responsive menu state belong to the host; a demo search does not implement search services.

Native composition and scope

AppBar, Toolbar, Menu

Preserve native Material UI composition and types; do not substitute JGuang UI/Base UI/Radix APIs. Example entries are not extra components.

Native installation and initialization

npm install @mui/material@9.4.0 @emotion/react@11.14.0 @emotion/styled@11.14.1

Use native npm and Emotion, not an invented JGuang UI Registry URL. Place examples inside native ThemeProvider; choose CssBaseline or ScopedCssBaseline for the project. Inspect React, existing providers, lockfile and SSR first. Never overwrite files or conceal peer conflicts. This batch verified React 19.2.8; React 18 and below require matching react-is. See the included bilingual setup guide.

Practical native parameters

These selected parameters are not a flattened universal API. Preserve the native declaring owner, slot structure, nullable values and generics.

Owner.propPractical roleDeclaration source
AppBar.positionNative AppBar CSS positioning policy.AppBar
AppBar.colorOwning component's native semantic/custom color, not another system's palette enum.AppBar
Toolbar.variantOwning native presentation enum; never substitute a universal variant prop.Toolbar

Runnable native examples

Machine keys select example entries, not universal variant props. Native demo JSX/data stay unchanged; JGuang-authored acceptance fixtures are explicitly labelled.

  • Basic App bar · ButtonAppBar · upstream native demo
  • App bar with menu · MenuAppBar · upstream native demo
  • App bar with responsive menu · ResponsiveAppBar · upstream native demo
  • App bar with search field · SearchAppBar · upstream native demo
  • Responsive App bar with Drawer · DrawerAppBar · upstream native demo
  • App bar with a primary search field · PrimarySearchAppBar · upstream native demo
  • Dense (desktop only) · DenseAppBar · upstream native demo
  • Prominent · ProminentAppBar · upstream native demo
  • Bottom App bar · BottomAppBar · upstream native demo
  • Hide App bar · HideAppBar · upstream native demo
  • Elevate App bar · ElevateAppBar · upstream native demo
  • Back to top · BackToTop · upstream native demo
  • Enable color on dark · EnableColorOnDarkAppBar · upstream native demo

Actual usage example

Unmodified pinned native demo; copy its required local helper files together.

import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button';
import IconButton from '@mui/material/IconButton';
import MenuIcon from '@mui/icons-material/Menu';

export default function ButtonAppBar() {
  return (
    <Box sx={{ flexGrow: 1 }}>
      <AppBar position="static">
        <Toolbar>
          <IconButton
            size="large"
            edge="start"
            color="inherit"
            aria-label="menu"
            sx={{ mr: 2 }}
          >
            <MenuIcon />
          </IconButton>
          <Typography variant="h6" component="div" sx={{ flexGrow: 1 }}>
            News
          </Typography>
          <Button color="inherit">Login</Button>
        </Toolbar>
      </AppBar>
    </Box>
  );
}

Example dependency boundaries

@mui/material/AppBar, @mui/material/Box, @mui/material/Toolbar, @mui/material/Typography, @mui/material/Button, @mui/material/IconButton, @mui/icons-material/Menu, react, @mui/icons-material/AccountCircle, @mui/material/Switch, @mui/material/FormControlLabel, @mui/material/FormGroup, @mui/material/MenuItem, @mui/material/Menu, @mui/material/Container, @mui/material/Avatar, @mui/material/Tooltip, @mui/icons-material/Adb, @mui/material/styles, @mui/material/InputBase, @mui/icons-material/Search, @mui/material/CssBaseline, @mui/material/Divider, @mui/material/Drawer, @mui/material/List, @mui/material/ListItem, @mui/material/ListItemButton, @mui/material/ListItemText, @mui/material/Badge, @mui/icons-material/Mail, @mui/icons-material/Notifications, @mui/icons-material/MoreVert, @mui/material/Paper, @mui/material/Fab, @mui/material/ListItemAvatar, @mui/material/ListSubheader, @mui/icons-material/Add, @mui/material/useScrollTrigger, @mui/material/Slide, @mui/icons-material/KeyboardArrowUp, @mui/material/Fade, @mui/material/Stack

Direct Icons/System/Utils example imports require their matching 9.4.0 packages. Relative data/helpers are part of the example closure, not extra components. Remote images and simulated operations do not supply a backend.

Pinned upstream API metadata reference

These tables retain the upstream metadata, not a newly inferred generic type system. Conditional generics, inherited props and callback details are defined by the source declarations below. Theme defaults may override metadata defaults.

AppBar

import AppBar from '@mui/material/AppBar';
import { AppBar } from '@mui/material';

Native inheritance: Paper. Parent/DOM props are not fabricated as additional own props.

PropRequiredUpstream metadata type / constraintMetadata default
childrennonode—
classesnoobject—
colorno'default' | 'inherit' | 'primary' | 'secondary' | 'transparent' | 'error' | 'info' | 'success' | 'warning' | string'primary'
elevationnonumber4
enableColorOnDarknoboolfalse
positionno'absolute' | 'fixed' | 'relative' | 'static' | 'sticky''fixed'
squarenobooltrue
sxnoArray<func | object | bool> | func | object—

Toolbar

import Toolbar from '@mui/material/Toolbar';
import { Toolbar } from '@mui/material';
PropRequiredUpstream metadata type / constraintMetadata default
childrennonode—
classesnoobject—
componentnoelementType—
disableGuttersnoboolfalse
sxnoArray<func | object | bool> | func | object—
variantno'dense' | 'regular' | string'regular'
import Menu from '@mui/material/Menu';
import { Menu } from '@mui/material';

Native inheritance: Popover. Parent/DOM props are not fabricated as additional own props.

PropRequiredUpstream metadata type / constraintMetadata default
openyesbool—
anchorElnoHTML element | func—
autoFocusnobooltrue
childrennonode—
classesnoobject—
disableAutoFocusItemnoboolfalse
onClosenofunc—
PopoverClassesnoobject—
slotPropsno{ backdrop?: func | object, list?: func | object, paper?: func | object, root?: func | object, transition?: func | object }{}
slotsno{ backdrop?: elementType, list?: elementType, paper?: elementType, root?: elementType, transition?: elementType }{}
sxnoArray<func | object | bool> | func | object—
transitionDurationno'auto' | number | { appear?: number, enter?: number, exit?: number }'auto'
variantno'menu' | 'selectedMenu''selectedMenu'

Native source declarations

Declarations/imports are extracted from pinned source without flattening unions or external inheritance. Original English comments/types are source reference, not a claim of translated upstream prose. Shared types stay in their native packages.

vendor/src/AppBar/AppBar.d.ts

import * as React from 'react';

import { SxProps } from '@mui/system';

import { OverridableStringUnion } from '@mui/types';

import { OverridableComponent, OverrideProps } from '../OverridableComponent';

import { PropTypes, Theme } from '../styles';

import { AppBarClasses } from './appBarClasses';

import { ExtendPaperTypeMap } from '../Paper/Paper';

export interface AppBarPropsColorOverrides {}

export interface AppBarOwnProps {
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<AppBarClasses> | undefined;
  /**
   * The color of the component.
   * It supports both default and custom theme colors, which can be added as shown in the
   * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
   * @default 'primary'
   */
  color?:
    | OverridableStringUnion<
        PropTypes.Color | 'transparent' | 'error' | 'info' | 'success' | 'warning',
        AppBarPropsColorOverrides
      >
    | undefined;
  /**
   * Shadow depth, corresponds to `dp` in the spec.
   * It accepts values between 0 and 24 inclusive.
   * @default 4
   */
  elevation?: number | undefined;
  /**
   * If true, the `color` prop is applied in dark mode.
   * @default false
   */
  enableColorOnDark?: boolean | undefined;
  /**
   * The positioning type. The behavior of the different options is described
   * [in the MDN web docs](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position).
   * Note: `sticky` is not universally supported and will fall back to `static` when unavailable.
   * @default 'fixed'
   */
  position?: 'fixed' | 'absolute' | 'sticky' | 'static' | 'relative' | undefined;
  /**
   * If `false`, rounded corners are enabled.
   * @default true
   */
  square?: boolean | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
}

export type AppBarTypeMap<
  AdditionalProps = {},
  RootComponent extends React.ElementType = 'header',
> = ExtendPaperTypeMap<
  {
    props: AdditionalProps & AppBarOwnProps;
    defaultComponent: RootComponent;
  },
  'position' | 'color' | 'classes' | 'elevation' | 'square'
>;

declare const AppBar: OverridableComponent<AppBarTypeMap>;

export type AppBarProps<
  RootComponent extends React.ElementType = AppBarTypeMap['defaultComponent'],
  AdditionalProps = {},
> = OverrideProps<AppBarTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
  component?: React.ElementType | undefined;
};

vendor/src/Toolbar/Toolbar.d.ts

import * as React from 'react';

import { SxProps } from '@mui/system';

import { OverridableStringUnion } from '@mui/types';

import { Theme } from '../styles';

import { OverridableComponent, OverrideProps } from '../OverridableComponent';

import { ToolbarClasses } from './toolbarClasses';

export interface ToolbarPropsVariantOverrides {}

export interface ToolbarOwnProps {
  /**
   * The Toolbar children, usually a mixture of `IconButton`, `Button` and `Typography`.
   * The Toolbar is a flex container, allowing flex item properties to be used to lay out the children.
   */
  children?: React.ReactNode;
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<ToolbarClasses> | undefined;
  /**
   * If `true`, disables gutter padding.
   * @default false
   */
  disableGutters?: boolean | undefined;
  /**
   * The variant to use.
   * @default 'regular'
   */
  variant?: OverridableStringUnion<'regular' | 'dense', ToolbarPropsVariantOverrides> | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
}

export interface ToolbarTypeMap<
  AdditionalProps = {},
  RootComponent extends React.ElementType = 'div',
> {
  props: AdditionalProps & ToolbarOwnProps;
  defaultComponent: RootComponent;
}

declare const Toolbar: OverridableComponent<ToolbarTypeMap>;

export type ToolbarProps<
  RootComponent extends React.ElementType = ToolbarTypeMap['defaultComponent'],
  AdditionalProps = {},
> = OverrideProps<ToolbarTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
  component?: React.ElementType | undefined;
};

vendor/src/Menu/Menu.d.ts

import * as React from 'react';

import { SxProps } from '@mui/system';

import { Theme } from '../styles';

import { InternalStandardProps as StandardProps } from '../internal';

import { PaperProps } from '../Paper';

import { PopoverProps } from '../Popover';

import { MenuListProps } from '../MenuList';

import { ModalProps } from '../Modal';

import { BackdropProps } from '../Backdrop';

import { TransitionProps } from '../transitions/types';

import { MenuClasses } from './menuClasses';

import { CreateSlotsAndSlotProps, SlotComponentProps, SlotProps } from '../utils/types';

export interface MenuRootSlotPropsOverrides {}

export interface MenuPaperSlotPropsOverrides {}

export interface MenuTransitionSlotPropsOverrides {}

export interface MenuListSlotPropsOverrides {}

export interface MenuBackdropSlotPropsOverrides {}

export interface MenuSlots {
  /**
   * The component used for the popper.
   * @default Modal
   */
  root: React.ElementType;
  /**
   * The component used for the paper.
   * @default PopoverPaper
   */
  paper: React.ElementType;
  /**
   * The component used for the list.
   * @default MenuList
   */
  list: React.ElementType;
  /**
   * The component used for the transition slot.
   * @default Grow
   */
  transition: React.ElementType;
  /**
   * The component used for the backdrop slot.
   * @default Backdrop
   */
  backdrop: React.ElementType;
}

export type MenuSlotsAndSlotProps = CreateSlotsAndSlotProps<
  MenuSlots,
  {
    /**
     * Props forwarded to the root slot.
     * By default, the available props are based on the [Popover](https://mui.com/material-ui/api/popover/#props) component.
     */
    root: SlotProps<React.ElementType<ModalProps>, MenuRootSlotPropsOverrides, MenuOwnerState>;
    /**
     * Props forwarded to the paper slot.
     * By default, the available props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component.
     */
    paper: SlotProps<React.ElementType<PaperProps>, MenuPaperSlotPropsOverrides, MenuOwnerState>;
    /**
     * Props forwarded to the list slot.
     * By default, the available props are based on the [MenuList](https://mui.com/material-ui/api/menu-list/#props) component.
     */
    list: SlotProps<React.ElementType<MenuListProps>, MenuListSlotPropsOverrides, MenuOwnerState>;
    /**
     * Props forwarded to the transition slot.
     * By default, the available props are based on the [Grow](https://mui.com/material-ui/api/grow/#props) component.
     */
    transition: SlotComponentProps<
      // use SlotComponentProps because transition slot does not support `component` and `sx` prop
      React.ElementType<TransitionProps>,
      TransitionProps & MenuTransitionSlotPropsOverrides,
      MenuOwnerState
    >;
    /**
     * Props forwarded to the backdrop slot.
     * By default, the available props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component.
     */
    backdrop: SlotProps<
      React.ElementType<BackdropProps>,
      MenuBackdropSlotPropsOverrides,
      MenuOwnerState
    >;
  }
>;

export interface MenuProps
  extends StandardProps<Omit<PopoverProps, 'slots' | 'slotProps'>>, MenuSlotsAndSlotProps {
  /**
   * An HTML element, or a function that returns one.
   * It's used to set the position of the menu.
   */
  anchorEl?: PopoverProps['anchorEl'] | undefined;
  /**
   * If `true` (Default) will focus the `[role="menu"]` if no focusable child is found. Disabled
   * children are not focusable. If you set this prop to `false` focus will be placed
   * on the parent modal container. This has severe accessibility implications
   * and should only be considered if you manage focus otherwise.
   * @default true
   */
  autoFocus?: boolean | undefined;
  /**
   * Menu contents, normally `MenuItem`s.
   */
  children?: React.ReactNode;
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<MenuClasses> | undefined;
  /**
   * When opening the menu will not focus the active item but the `[role="menu"]`
   * unless `autoFocus` is also set to `false`. Not using the default means not
   * following WAI-ARIA authoring practices. Please be considerate about possible
   * accessibility implications.
   * @default false
   */
  disableAutoFocusItem?: boolean | undefined;
  /**
   * Callback fired when the component requests to be closed.
   *
   * @param {object} event The event source of the callback.
   * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`, `"tabKeyDown"`.
   */
  onClose?: PopoverProps['onClose'] | undefined;
  /**
   * If `true`, the component is shown.
   */
  open: boolean;
  /**
   * `classes` prop applied to the [`Popover`](https://mui.com/material-ui/api/popover/) element.
   */
  PopoverClasses?: PopoverProps['classes'] | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
  /**
   * The length of the transition in `ms`, or 'auto'
   * @default 'auto'
   */
  transitionDuration?: TransitionProps['timeout'] | 'auto' | undefined;
  /**
   * The variant to use. Use `menu` to prevent selected items from impacting the initial focus.
   * @default 'selectedMenu'
   */
  variant?: 'menu' | 'selectedMenu' | undefined;
}

export interface MenuOwnerState extends Omit<MenuProps, 'slots' | 'slotProps'> {}

export declare const MenuPaper: React.FC<PaperProps>;

export default function Menu(props: MenuProps): React.JSX.Element;

Post-install acceptance

Run strict types, production build and real interactions. Check keyboard labels/focus, disabled/error/read-only semantics where natively supported, both themes, narrow screens and reduced motion. Verify callbacks against the real host data; do not declare installation complete from copying a prompt. Initialization fixtures also require server HTML and warning-free hydration.

Source and license

https://github.com/mui/material-ui/tree/809a7717b4c050ba3f69b75300689f07c050a16e

MIT · @mui/material@9.4.0. Vendor originals and license are preserved. Full original upstream prose remains in vendor/docs and is not represented as fully translated.