---
title: StickyNavigationBar
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, FigmaEmbed, PropsTable } from '../../src/components'
import { StickyNavigationBar } from '@telus-uds/components-community'
import { StickyNavigationBar as StickyNavigationBarDocs } from 'docs/@telus-uds/components-community'
import AvailableOnWebOnly from '../../partials/_platform-considerations-web-only.mdx'
import NoStylisticVariants from '../../partials/_variants-none.mdx'

# StickyNavigationBar

<LibraryInfo
  packageType="Web Component"
  packageName="components-community.sticky-navigation-bar"
  compatibility={['React 18']}
  figmaLink=""
/>

```jsx live
<div style={{ height: '300px', overflow: 'scroll', position: 'relative' }}>
  <div style={{ height: '200vh' }}>
    <StickyNavigationBar
      left={
        <StickyNavigationBar.CallToAction
          label="See phone offers"
          action="https://cta.address.com"
        />
      }
      right={
        <StickyNavigationBar.Link
          href="tel:1-877-352-0898"
          label="Talk to a sales expert:"
          text="1-877-352-0898"
        />
      }
      workWithViewport={false}
    />
  </div>
</div>
```

## Introduction

```jsx
import { StickyNavigationBar } from '@telus-uds/components-community.stickynavigationbar'
```

StickyNavigationBar is generic purpose navigation bar with Sticky functionality, designed for flexible use and extensibility.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

The StickyNavigationBar component is a powerful and flexible solution for creating navigation bars with sticky functionality, enabling them to stay fixed at the top of the page as users scroll. It serves as a versatile tool that can be seamlessly integrated into a wide range of applications, providing a robust foundation for navigation.
With its thoughtfully designed base component, the StickyNavigationBar offers a structured layout that simplifies the process of creating navigation bars. The layout consists of two main containers: the Left and Right containers, which allow for intuitive organization of navigation elements and content within the bar. This flexibility empowers developers and designers to tailor the navigation bar to the specific needs of their application.
In addition to the core functionality, the StickyNavigationBar provides three preconfigured components known as fragments. These fragments serve as ready-made building blocks, facilitating the integration of additional components into the navigation bar. By leveraging these fragments, developers can ensure consistency and streamline the process of incorporating complex functionality into the navigation bar.

A StickyNavigationBar is built using a `<StickyNavigationBar>` container, this container receives two main props, the `left` and `right` prop,
each prop can receive a React component, by design the StickyNavigationBar provides three components to use in those props, this in order to facilitate and standarize the integration
of other components inside the StickyNavigationBar

The provided components are the following:

### Call To Action

```jsx live
<StickyNavigationBar.CallToAction label="See phone offers" action="https://cta.address.com" />
```

The `<StickyNavigationBar.CallToAction/>` will show a button, this button will use internally `<ButtonLink>` if the action is a string or `<Button>` if the action is a function

### Link

```jsx live
<StickyNavigationBar.Link text="See phone offers" href="https://cta.address.com" />
```

The `<StickyNavigationBar.Link/>` has different variants, you can choose to show a simple link by just using the `text` and `href` prop.
If you add a `label` prop, along with the link a label will appear

```jsx live
<StickyNavigationBar.Link
  label="Talk to a sales expert:"
  text="1-865-548-2548"
  href="tel:1-865-548-2548"
/>
```

You can also use this component to show a chevron link by using the `chevron` prop

```jsx live
<StickyNavigationBar.Link chevron href="#" text="Schedule a call with a Bring-it-Back agent" />
```

### Tabs

```jsx live
<StickyNavigationBar.Tabs
  items={[
    { label: 'Features', href: '#features' },
    { label: 'Getting Started', href: '#getting_started' },
    { label: 'Offer Details', href: '#offer_details' }
  ]}
/>
```

The `<StickyNavigationBar.Tabs/>` component can be used in two ways, the default tabs or the tabs with content, the default tab is the one
that is shown above, and the tabs with content si the one shown bellow. For the default tabs design you will have the labels and the href available,
for the tabs with content you will use the label along with the id property to identify the content you want to show

```jsx live
function TabsControlled() {
  const tabsControlledContent = {
    one: 'Content 1 - Features',
    two: 'Content 2 - Getting Started',
    three: 'Content 3 - Offer Details',
    four: 'Content 4 - Contact Us'
  }

  const [state, setState] = useState('one')

  return (
    <>
      <StickyNavigationBar.Tabs
        items={[
          { label: 'Features', id: 'one' },
          { label: 'Getting Started', id: 'two' },
          { label: 'Offer Details', id: 'three' },
          { label: 'Contact Us', id: 'four' }
        ]}
        value={state}
        onChange={setState}
      />
      <Typography>{tabsControlledContent[state]}</Typography>
    </>
  )
}
```

### Custom width of left and right section

The width of left and right section of StickyNavigationBar can be managed by passing props `leftCol` and `rightCol`

```jsx live
<div style={{ height: '200px', overflow: 'scroll', position: 'relative' }}>
  <div style={{ height: '200vh' }}>
    <StickyNavigationBar
      left={
        <StickyNavigationBar.CallToAction
          label="See phone offers"
          action="https://cta.address.com"
        />
      }
      right={
        <StickyNavigationBar.Link
          href="tel:1-877-352-0898"
          label="Talk to a sales expert:"
          text="1-877-352-0898"
        />
      }
      leftCol={{ xs: 12, sm: 4 }}
      rightCol={{ xs: 12, sm: 8 }}
    />
  </div>
</div>
```

### Platform considerations

<AvailableOnWebOnly />

## Props

### `StickyNavigationBar` props

<PropsTable base={StickyNavigationBarDocs} />

### `StickyNavigationBar.CallToAction` props

<PropsTable base={StickyNavigationBarDocs.CallToAction} />

### `StickyNavigationBar.Link` props

<PropsTable base={StickyNavigationBarDocs.Link} />

### `StickyNavigationBar.Tabs` props

<PropsTable base={StickyNavigationBarDocs.Tabs} />

## Variants

<NoStylisticVariants />

## Feedback

<Feedback component="StickyNavigationBar" />
