# NavigationBar
**📖 Live documentation:** https://cds.coinbase.com/components/navigation/NavigationBar/
A universal header component for navigation and wayfinding.
## Import
```tsx
import { NavigationBar } from '@coinbase/cds-web/navigation/NavigationBar'
```
## Examples
NavigationBar is a horizontal navigation component that provides a consistent header for application navigation and wayfinding. It supports flexible content areas, theming, and custom styling.
### Basics
```jsx live
}
end={
}
>
Dashboard
```
#### With Tab Navigation
Use the `bottom` prop to add tab navigation below the main content.
```jsx live
function NavigationWithTabs() {
const tabs = [
{ id: 'all', label: 'All' },
{ id: 'watchlist', label: 'Watchlist' },
{ id: 'tradable', label: 'Tradable' },
{ id: 'gainers', label: 'Gainers' },
];
const [value, setValue] = useState(tabs[0].id);
return (
}
bottom={}
>
Portfolio
);
}
```
#### With Search
```jsx live
function NavigationWithSearch() {
const [search, setSearch] = useState('');
return (
}
end={}
>
);
}
```
### Accessibility
Use `accessibilityLabel` to provide context for screen readers. The default label is "main navigation".
```jsx live
}
end={}
>
Account Settings
```
When using interactive elements in the navigation bar, ensure each has appropriate accessibility labels describing their action.
### Composed Examples
#### Full Navigation with Back Button
A complete navigation example with dynamic back button visibility and tab navigation.
```jsx live
function FullNavigation() {
const tabs = [
{ id: 'all', label: 'All' },
{ id: 'watchlist', label: 'Watchlist' },
{ id: 'tradable', label: 'Tradable' },
{ id: 'gainers', label: 'Gainers' },
{ id: 'losers', label: 'Losers' },
];
const [search, setSearch] = useState('');
const [value, setValue] = useState(tabs[1].id);
const showBackButton = useMemo(() => value !== tabs[0].id, [value]);
const handleBackPress = useCallback(() => {
setValue(tabs[0].id);
}, []);
return (
)
}
end={
}
bottom={}
>
);
}
```
#### Responsive Navigation
A responsive navigation bar that adapts to screen size. On mobile, the search input collapses to an icon button.
```jsx live
function ResponsiveNavigation() {
const [search, setSearch] = useState('');
const [searchOpen, setSearchOpen] = useState(false);
const { isMobile } = useBreakpoints();
const handleSearchToggle = useCallback(() => {
setSearchOpen((prev) => !prev);
if (searchOpen) {
setSearch('');
}
}, [searchOpen]);
return (
}
end={
{isMobile && (
)}
}
>
{isMobile ? (
searchOpen && (
)
) : (
)}
{!isMobile && !searchOpen && Trading}
);
}
```
## Props
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `alignContent` | `ResponsiveProp
` | No | `-` | - |
| `alignItems` | `ResponsiveProp` | No | `-` | - |
| `alignSelf` | `ResponsiveProp` | No | `-` | - |
| `as` | `nav` | No | `-` | The underlying element or component the polymorphic component will render. Changing as also changes the inherited native props (e.g. href for as=a) and the expected ref type. |
| `aspectRatio` | `ResponsiveProp` | No | `-` | - |
| `background` | `ResponsiveProp` | No | `-` | - |
| `borderBottomLeftRadius` | `ResponsiveProp` | No | `-` | - |
| `borderBottomRightRadius` | `ResponsiveProp` | No | `-` | - |
| `borderBottomWidth` | `ResponsiveProp` | No | `-` | - |
| `borderColor` | `ResponsiveProp` | No | `-` | - |
| `borderEndWidth` | `ResponsiveProp` | No | `-` | - |
| `borderRadius` | `ResponsiveProp` | No | `-` | - |
| `borderStartWidth` | `ResponsiveProp` | No | `-` | - |
| `borderTopLeftRadius` | `ResponsiveProp` | No | `-` | - |
| `borderTopRightRadius` | `ResponsiveProp` | No | `-` | - |
| `borderTopWidth` | `ResponsiveProp` | No | `-` | - |
| `borderWidth` | `ResponsiveProp` | No | `-` | - |
| `bordered` | `boolean` | No | `-` | Add a border around all sides of the box. |
| `borderedBottom` | `boolean` | No | `-` | Add a border to the bottom side of the box. |
| `borderedEnd` | `boolean` | No | `-` | Add a border to the trailing side of the box. |
| `borderedHorizontal` | `boolean` | No | `-` | Add a border to the leading and trailing sides of the box. |
| `borderedStart` | `boolean` | No | `-` | Add a border to the leading side of the box. |
| `borderedTop` | `boolean` | No | `-` | Add a border to the top side of the box. |
| `borderedVertical` | `boolean` | No | `-` | Add a border to the top and bottom sides of the box. |
| `bottom` | `((Bottom \| { base?: Bottom; phone?: Bottom \| undefined; tablet?: Bottom \| undefined; desktop?: Bottom \| undefined; }) & (string \| number \| boolean \| ReactElement> \| Iterable \| ReactPortal \| null)) \| undefined` | No | `-` | The bottom content. Use to render tabs |
| `children` | `ReactNode` | No | `-` | The middle content. Use the children to render the page title |
| `classNames` | `{ readonly root?: string; readonly start?: string \| undefined; readonly content?: string \| undefined; } \| undefined` | No | `-` | - |
| `color` | `ResponsiveProp` | No | `-` | - |
| `columnGap` | `((Space \| { base?: Space; phone?: Space \| undefined; tablet?: Space \| undefined; desktop?: Space \| undefined; }) & ResponsiveProp) \| undefined` | No | `2` | Space between the start, children, and end of the nav bar |
| `dangerouslyDisableOverflowHidden` | `boolean` | No | `-` | Disable the overflow: hidden style from being injected to the child Col |
| `dangerouslySetBackground` | `string` | No | `-` | - |
| `display` | `ResponsiveProp` | No | `-` | - |
| `elevation` | `ResponsiveProp` | No | `-` | - |
| `end` | `ReactNode` | No | `-` | Node (icons, avatar, etc) to display at the end of the nav bar |
| `flexBasis` | `ResponsiveProp>` | No | `-` | - |
| `flexDirection` | `ResponsiveProp` | No | `-` | - |
| `flexGrow` | `ResponsiveProp` | No | `-` | - |
| `flexShrink` | `ResponsiveProp` | No | `-` | - |
| `flexWrap` | `ResponsiveProp` | No | `-` | - |
| `font` | `ResponsiveProp` | No | `-` | - |
| `fontFamily` | `ResponsiveProp` | No | `-` | - |
| `fontSize` | `ResponsiveProp` | No | `-` | - |
| `fontWeight` | `ResponsiveProp` | No | `-` | - |
| `gap` | `ResponsiveProp` | No | `-` | - |
| `grid` | `ResponsiveProp` | No | `-` | - |
| `gridArea` | `ResponsiveProp` | No | `-` | - |
| `gridAutoColumns` | `ResponsiveProp>` | No | `-` | - |
| `gridAutoFlow` | `ResponsiveProp` | No | `-` | - |
| `gridAutoRows` | `ResponsiveProp>` | No | `-` | - |
| `gridColumn` | `ResponsiveProp` | No | `-` | - |
| `gridColumnEnd` | `ResponsiveProp` | No | `-` | - |
| `gridColumnStart` | `ResponsiveProp` | No | `-` | - |
| `gridRow` | `ResponsiveProp` | No | `-` | - |
| `gridRowEnd` | `ResponsiveProp` | No | `-` | - |
| `gridRowStart` | `ResponsiveProp` | No | `-` | - |
| `gridTemplate` | `ResponsiveProp` | No | `-` | - |
| `gridTemplateAreas` | `ResponsiveProp` | No | `-` | - |
| `gridTemplateColumns` | `ResponsiveProp>` | No | `-` | - |
| `gridTemplateRows` | `ResponsiveProp>` | No | `-` | - |
| `height` | `ResponsiveProp>` | No | `-` | - |
| `justifyContent` | `ResponsiveProp` | No | `-` | - |
| `key` | `Key \| null` | No | `-` | - |
| `left` | `ResponsiveProp>` | No | `-` | - |
| `lineHeight` | `ResponsiveProp` | No | `-` | - |
| `margin` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
| `marginBottom` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
| `marginEnd` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
| `marginStart` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
| `marginTop` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
| `marginX` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
| `marginY` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
| `maxHeight` | `ResponsiveProp>` | No | `-` | - |
| `maxWidth` | `ResponsiveProp>` | No | `-` | - |
| `minHeight` | `ResponsiveProp>` | No | `-` | - |
| `minWidth` | `ResponsiveProp>` | No | `-` | - |
| `onChange` | `FormEventHandler` | No | `-` | - |
| `opacity` | `ResponsiveProp` | No | `-` | - |
| `overflow` | `ResponsiveProp` | No | `-` | - |
| `padding` | `ResponsiveProp` | No | `-` | - |
| `paddingBottom` | `((Space \| { base?: Space; phone?: Space \| undefined; tablet?: Space \| undefined; desktop?: Space \| undefined; }) & Space) \| undefined` | No | `2 if bottom is not provided` | - |
| `paddingEnd` | `ResponsiveProp` | No | `-` | - |
| `paddingStart` | `ResponsiveProp` | No | `-` | - |
| `paddingTop` | `((Space \| { base?: Space; phone?: Space \| undefined; tablet?: Space \| undefined; desktop?: Space \| undefined; }) & Space) \| undefined` | No | `2` | - |
| `paddingX` | `((Space \| { base?: Space; phone?: Space \| undefined; tablet?: Space \| undefined; desktop?: Space \| undefined; }) & Space) \| undefined` | No | `2` | - |
| `paddingY` | `ResponsiveProp` | No | `-` | - |
| `pin` | `PinningDirection` | No | `-` | Direction in which to absolutely pin the box. |
| `position` | `ResponsiveProp` | No | `-` | - |
| `ref` | `((instance: HTMLElement \| null) => void) \| RefObject \| null` | No | `-` | - |
| `right` | `ResponsiveProp>` | No | `-` | - |
| `rowGap` | `((Space \| { base?: Space; phone?: Space \| undefined; tablet?: Space \| undefined; desktop?: Space \| undefined; }) & ResponsiveProp) \| undefined` | No | `2` | Space between bottom of the nav bar and the rest of its content |
| `start` | `ReactNode` | No | `-` | Node (ie Back button) to display at the start of the nav bar |
| `style` | `CSSProperties` | No | `-` | - |
| `styles` | `{ readonly root?: CSSProperties; readonly start?: CSSProperties \| undefined; readonly content?: CSSProperties \| undefined; } \| undefined` | No | `-` | - |
| `testID` | `string` | No | `-` | Used to locate this element in unit and end-to-end tests. Under the hood, testID translates to data-testid on Web. On Mobile, testID stays the same - testID |
| `textAlign` | `ResponsiveProp` | No | `-` | - |
| `textDecoration` | `ResponsiveProp` | No | `-` | - |
| `textTransform` | `ResponsiveProp` | No | `-` | - |
| `top` | `ResponsiveProp>` | No | `-` | - |
| `transform` | `ResponsiveProp` | No | `-` | - |
| `userSelect` | `ResponsiveProp` | No | `-` | - |
| `visibility` | `ResponsiveProp` | No | `-` | - |
| `width` | `ResponsiveProp>` | No | `-` | - |
| `zIndex` | `ResponsiveProp` | No | `-` | - |
## Styles
| Selector | Static class name | Description |
| --- | --- | --- |
| `root` | `cds-NavigationBar` | Root nav element containing the entire navigation bar |
| `start` | `cds-NavigationBar-start` | Container for the start slot (e.g., back button) |
| `content` | `cds-NavigationBar-content` | Container for the main children content (e.g., title) |