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 logotype, organization, space, and environment information. Use it as a child of the Navbarswitcher
prop.<Navbar.SwitcherItem>
: Represents an item within the<Navbar.Switcher>
. Use it to render organization, space, and environment information in different states. Use it as a child of the<Navbar.Switcher>
.<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 | |
badge | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal | |
bottomRightItems | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal Items that will be rendered on the bottom-right of the navbar. Useful for separating other navigation items from main ones, (e.g. separating "Settings" from all other navigation items). | |
children | ReactNode | |
className | string CSS class to be appended to the root element | |
contentMaxWidth | string Defines the max-width of the content inside the navbar. | '100%' |
help | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal | |
search | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal | |
switcher | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal | |
testId | string A [data-test-id] attribute used for testing purposes | |
topRightItems | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal Items that will be rendered on the top-right of the navbar. Useful for providing additional context or actions to the user (e.g. a Feedback form link). |
Navbar.Item
Name | Type | Default |
---|---|---|
title required | string | |
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 | |
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 |
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
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 |
Navbar.Switcher
Name | Type | Default |
---|---|---|
children | ReactNode | |
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> | |
logo | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal Will be displayed instead of the default Contentful logo | |
testId | string A [data-test-id] attribute used for testing purposes |
Navbar.SwitcherItem
Name | Type | Default |
---|---|---|
children | ReactNode | |
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
Name | Type | Default |
---|---|---|
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> | |
testId | string A [data-test-id] attribute used for testing purposes |
Navbar.Help
Name | Type | Default |
---|---|---|
children required | ReactNode | |
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> | |
testId | string A [data-test-id] attribute used for testing purposes |
Navbar.Account
Name | Type | Default |
---|---|---|
avatar required | string | |
children required | ReactNode | |
username required | 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 | |
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 |