Import
import { Navbar } from '@contentful/f36-components';// orimport { Navbar } from '@contentful/f36-navbar';
Examples
You can use following components to build a menu:
<Navbar>
: The main wrapper component.<Navbar.Item>
: Represents a main navigation item. Use it as a child of the<Navbar>
component or thebottomRightItems
prop of Navbar.<Navbar.MenuItem>
: Represents a menu item used to create dropdown menus. Use it as a child of the<Navbar.Item>
,<Navbar.Account>
, or<Navbar.Help>
components.<Navbar.MenuDivider>
: A visual separator for menu items. Use it before or after a<Navbar.MenuItem>
.<Navbar.MenuSectionTitle>
: A title that can be used in the menu list. Use it before or after a<Navbar.MenuItem>
.<Navbar.Switcher>
: Wrapper component for the space and environment information. Use it as a child of the Navbarswitcher
prop.<Navbar.Search>
: Trigger for the global search. Use it as a child of the Navbarsearch
prop.<Navbar.Help>
: Trigger for the help menu. Use it as a child of the Navbarhelp
prop.<Navbar.Account>
: Trigger for the account menu. Use it as a child of the Navbaraccount
prop.<Navbar.Badge>
: Represents an item that provides additional information, such as indicating that the user's space is on a trial. Use it as a child of the Navbarbadge
prop.<Navbar.TopbarItem>
: Represents an item that provides additional links or CTAs (Call to Actions), such as a link to the feedback form. Use it as a child of the NavbartopRightItems
prop.<Navbar.ItemSkeleton>
: Loading skeleton for<Navbar.Item>
. Use it as a child of the<Navbar>
component or thebottomRightItems
prop of Navbar.<Navbar.MenuItemSkeleton>
: Loading skeleton for<Navbar.MenuItem>
. Use it as a child of the<Navbar.Item>
,<Navbar.Account>
, or<Navbar.Help>
components.<Navbar.SwitcherSkeleton>
: Loading skeleton for<Navbar.Switcher>
. Use it as a child of the Navbarswitcher
prop.<Navbar.AccountSkeleton>
: Loading skeleton for<Navbar.Account>
. Use it as a child of the Navbaraccount
prop.
Basic usage
Complete Navbar
Navbar with different enviromnments
Navbar with account notification
Navbar loading skeleton
Props (API reference)
Open in StorybookNavbar
Name | Type | Default |
---|---|---|
account | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal User Account Component | |
className | string CSS class to be appended to the root element | |
contentMaxWidth | string Defines the max-width of the content inside the navbar. | '100%' |
logo | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal Accepts a React Component that will be displayed instead of the Contentful Logo | |
mainNavigation | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal Main Navigation Elements | |
mobileNavigation | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal Navigation displayed on mobile versions | |
secondaryNavigation | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal Secondary Navigation Elements, displayed in the right side | |
switcher | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal Environment Switcher component | |
testId | string A [data-test-id] attribute used for testing purposes | |
variant | "wide" "fullscreen" Describes the size variation of the Navbar Variant wide will set the contentMaxWidth to 1524px |
Navbar.Item
Name | Type | Default |
---|---|---|
as | HTML Tag or React Component (e.g. div, span, etc) | |
children | ReactNode | |
className | string CSS class to be appended to the root element | |
icon | ReactElement<GeneratedIconProps, string | JSXElementConstructor<any>> | |
isActive | false true | |
label | string | |
onClose | () => void Callback fired when the Menu closes | |
onOpen | () => void Callback fired when the Menu opens | |
testId | string A [data-test-id] attribute used for testing purposes | |
title | string |
Navbar.MenuItem
Name | Type | Default |
---|---|---|
as | HTML Tag or React Component (e.g. div, span, etc) | |
children | ||
className | string CSS class to be appended to the root element | |
css | string number false true ComponentSelector Keyframes SerializedStyles ArrayInterpolation<undefined> ObjectInterpolation<undefined> (theme: any) => Interpolation<undefined> | |
icon | ReactElement<GeneratedIconProps, string | JSXElementConstructor<any>> & ReactElement<any, string | JSXElementConstructor<any>> Expects any of the icon components. Renders the icon aligned to the start | |
isActive | false true Marks item as active | |
isDisabled | false true Marks item as disabled | |
isInitiallyFocused | false true Sets focus on item | |
testId | string A [data-test-id] attribute used for testing purposes | |
title | string |
Navbar.TopbarItem
Navbar.Switcher
Name | Type | Default |
---|---|---|
children required | ReactNode | |
ariaLabel | string | |
className | string CSS class to be appended to the root element | |
css | string number false true ComponentSelector Keyframes SerializedStyles ArrayInterpolation<undefined> ObjectInterpolation<undefined> (theme: any) => Interpolation<undefined> | |
envVariant | "master" "non-master" | |
isAlias | false true | |
isCircle | false true | |
testId | string A [data-test-id] attribute used for testing purposes |
Navbar.Search
Navbar.Help
Navbar.Account
Name | Type | Default |
---|---|---|
children required | ReactNode | |
username required | string | |
avatar | string | |
className | string CSS class to be appended to the root element | |
css | string number false true ComponentSelector Keyframes SerializedStyles ArrayInterpolation<undefined> ObjectInterpolation<undefined> (theme: any) => Interpolation<undefined> | |
hasNotification | false true | |
initials | string | |
notificationVariant | "warning" "negative" "info" | 'warning' |
testId | string A [data-test-id] attribute used for testing purposes |
Navbar.Badge
Name | Type | Default |
---|---|---|
as | HTML Tag or React Component (e.g. div, span, etc) | |
children | ReactNode | |
className | string CSS class to be appended to the root element | |
testId | string A [data-test-id] attribute used for testing purposes |