The AppBar component is a relatively simple container, rendering a header element, used to display information and actions relating to the current screen.
It is the foundation for the Header Pattern, a more robust, more opinionated component that also handles the rendering of several components inside of it.
Basic Usage
import React from 'react';import { AppBar } from 'react-magma-dom';export function Example() {return <AppBar>AppBar content</AppBar>;}
Compact
The isCompact
prop will render a shorter appbar with less padding.
import React from 'react';import { AppBar } from 'react-magma-dom';export function Example() {return <AppBar isCompact>AppBar content</AppBar>;}
With Skip Link
The AppBar
works concurrently with SkipLink
which assists keyboard navigation.
Peel the onion peel the onion, so the horse is out of the barn per my previous email, nor draw a line in the sand. I just wanted to give you a heads-up drink from the firehose, game plan back-end of third quarter viral engagement. Eat our own dog food driving the initiative forward tribal knowledge increase the pipelines, but run it up the flag pole.
Turn the crank regroup can we align on lunch orders, so regroup, yet the last person we talked to said this would be ready, for this vendor is incompetent , or pipeline. We've bootstrapped the model zeitgeist, so let's schedule a standup during the sprint to review our kpis, so not the long pole in my tent we're ahead of the curve on that one, and we're ahead of the curve on that one.
import React from 'react';import {AppBar,AppBarPosition,SkipLink,SkipLinkContent,Paragraph,} from 'react-magma-dom';export function Example() {return (<div style={{ height: '400px', overflow: 'auto', position: 'relative' }}><AppBar isInverse position={AppBarPosition.sticky}>AppBar content</AppBar><SkipLink>Skip to the end!</SkipLink><Paragraph>Peel the onion peel the onion, so the horse is out of the barn per myprevious email, nor draw a line in the sand. I just wanted to give you aheads-up drink from the firehose, game plan back-end of third quarterviral engagement. Eat our own dog food driving the initiative forwardtribal knowledge increase the pipelines, but run it up the flag pole.</Paragraph><SkipLinkContent><Paragraph id="last-one">Turn the crank regroup can we align on lunch orders, so regroup, yetthe last person we talked to said this would be ready, for this vendoris incompetent , or pipeline. We've bootstrapped the model zeitgeist,so let's schedule a standup during the sprint to review our kpis, sonot the long pole in my tent we're ahead of the curve on that one, andwe're ahead of the curve on that one.{' '}</Paragraph></SkipLinkContent></div>);}
Inverse
The isInverse
prop will render an appbar with a dark background and light text. The components inside the app bar will inherit the isInverse
prop unless specified otherwise.
import React from 'react';import { AppBar } from 'react-magma-dom';export function Example() {return <AppBar isInverse>AppBar content</AppBar>;}
Position
The position
prop will set the positioning type with CSS. It accepts values absolute
, fixed
, relative
, static
and sticky
, with static
being the default.
If the position
is set to sticky
or fixed
, the app bar will have a small drop-shadow.
Lorem Ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mattis, libero eu posuere hendrerit, turpis massa placerat ex, sit amet luctus enim nunc a arcu. Mauris at lobortis urna. Nam suscipit purus convallis mauris iaculis, vitae fermentum ipsum faucibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec congue eu felis a blandit.
Phasellus sodales ut lorem at semper. Curabitur id hendrerit est, ac vestibulum neque. Curabitur ac elementum elit. Quisque eleifend tortor vitae ultrices tristique. Integer a elementum magna. Cras eget erat feugiat, dignissim ante in, blandit lectus. Donec sodales justo ligula, ornare congue felis facilisis mattis.
Fusce faucibus venenatis arcu, ac sollicitudin nibh iaculis vitae. Nam risus nunc, mattis et maximus ac, dignissim at lectus. Sed eleifend euismod diam, at ornare lectus vestibulum et. Maecenas at sodales magna. Proin mollis elit nec lorem rhoncus, a suscipit metus imperdiet. Vestibulum ut magna imperdiet, bibendum felis semper, volutpat est. Duis congue porta justo, et interdum ligula vulputate et.
Fusce vitae convallis ante. Pellentesque et enim ac dolor cursus ultricies at eget quam. Vestibulum euismod volutpat nulla eget porttitor. Morbi tempor fermentum viverra. Suspendisse potenti.
import React from 'react';import { AppBar, AppBarPosition, Heading, Paragraph } from 'react-magma-dom';export function Example() {return (<div style={{ height: '300px', overflow: 'auto', position: 'relative' }}><AppBar isInverse position={AppBarPosition.sticky}>AppBar content</AppBar><Heading level={2}>Lorem Ipsum</Heading><Paragraph>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mattis,libero eu posuere hendrerit, turpis massa placerat ex, sit amet luctusenim nunc a arcu. Mauris at lobortis urna. Nam suscipit purus convallismauris iaculis, vitae fermentum ipsum faucibus. Lorem ipsum dolor sitamet, consectetur adipiscing elit. Donec congue eu felis a blandit.</Paragraph><Paragraph>Phasellus sodales ut lorem at semper. Curabitur id hendrerit est, acvestibulum neque. Curabitur ac elementum elit. Quisque eleifend tortorvitae ultrices tristique. Integer a elementum magna. Cras eget eratfeugiat, dignissim ante in, blandit lectus. Donec sodales justo ligula,ornare congue felis facilisis mattis.</Paragraph><Paragraph>Fusce faucibus venenatis arcu, ac sollicitudin nibh iaculis vitae. Namrisus nunc, mattis et maximus ac, dignissim at lectus. Sed eleifendeuismod diam, at ornare lectus vestibulum et. Maecenas at sodales magna.Proin mollis elit nec lorem rhoncus, a suscipit metus imperdiet.Vestibulum ut magna imperdiet, bibendum felis semper, volutpat est. Duiscongue porta justo, et interdum ligula vulputate et.</Paragraph><Paragraph>Fusce vitae convallis ante. Pellentesque et enim ac dolor cursusultricies at eget quam. Vestibulum euismod volutpat nulla egetporttitor. Morbi tempor fermentum viverra. Suspendisse potenti.</Paragraph></div>);}
Nav Tabs
This is a more complex example of putting mutliple elements inside an AppBar
.
import React from 'react';import {AppBar,NavTabs,NavTab,Search,Spacer,TabsIconPosition,magma,} from 'react-magma-dom';import { ImageIcon, FavoriteIcon, WorkIcon } from 'react-magma-icons';export function Example() {return (<AppBarisInversestyle={{ display: 'flex', justifyContent: 'space-between', gap: '48px' }}><divstyle={{alignItems: 'center',display: 'flex',whiteSpace: 'nowrap',}}><ImageIcon size={24} /><Spacer size={magma.spaceScale.spacing03} /><strong>LOGO</strong></div><div style={{ flex: '0 0 auto' }}><Search onSearch={() => {}} placeholder="Search for content..." /></div><div style={{ flex: '1 1 auto' }}><NavTabsaria-label="Navigation"backgroundColor="transparent"iconPosition={TabsIconPosition.left}><NavTab icon={<FavoriteIcon />} isActive to="#">Favorites</NavTab><NavTab icon={<WorkIcon />} to="#">Workspace</NavTab></NavTabs></div></AppBar>);}
AppBar Props
Any other props supplied will be provided to the wrapping header
element.
children
Description
The content of the component
Type
ReactNode | undefined
Default
-
isCompact
Description
If true, the component will render at a shorter height with less padding
Type
boolean
Default
false
isInverse
Description
If true, the component will have inverse styling to better appear on a dark background
Type
boolean
Default
false
position
Description
Position of the AppBar
Type
enum, one of:
AppBarPosition.absolute
AppBarPosition.fixed
AppBarPosition.relative
AppBarPosition.static
AppBarPosition.sticky
Default
AppBarPosition.static
On this page