---
title: Notification
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { Notification, StackView, Typography, Link } from '@telus-uds/components-web'
import { Notification as BaseDocs } from 'docs/@telus-uds/components-base'
import { useState } from 'react'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'
import AdditionalVariants from '../../src/components/Variants/Notification'

# Notification

<LibraryInfo figmaLink="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2F4zJn2Qn6uXOqPP1GVDipy6%2F%25F0%259F%258D%2580-Allium-Components%3Fnode-id%3D3308%253A32778" />

```jsx live
<Notification>Your password was updated successfully.</Notification>
```

:::danger
`style` variant for the values of 'success', 'warning', and 'error' **will be deprecated in the next major release** we recommend using `validation` variant which offers the same functionality and options.

`system` prop to set the visual style of the notification **will be deprecated in the next major release** we recommend using `style` variant with the option of `system` to achieve the same outcome.
:::

## Introduction

`Notification` is a banner that highlights important messages:

- Status message to show there is an error or outage of services
- Confirmation message in response to user action
- Account information letting the user know they have almost used all their data

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

## Guidance

- Use simple text content only, such as bold text or links. Don’t use other complex components or paragraphs.
- Show notifications before the content that the message is related to, otherwise show at the top of the main content
- Show system notifications at the top of the page, below the navigation, and expands the full-width of the viewport
- When showing multiple notifications, show them in order of importance from top to bottom
- The icon and colour will indicate meaning and importance
- Use `variant.style` to set the visual style of the notification, **note that ('success', 'warning', 'error') options will be deprecated in the next major release.**
- Use `variant.validation` to set the validation visual style ('success', 'warning', 'error') of the notification
- Use `dismissible` prop to enable dismissible functionality
- Use `system` prop to set the visual style of the notification and denote an announcement from the system or application, **note that this prop will be deprecated in the next major release.**
- Use `variant.style 'system'` prop to set the visual style of the notification and denote an announcement from the system or application

### When to use the system prop?

- Use `system` to show system-based messages coming from the application
- Don’t use `system` when the message is in response to user action

### Accessibility

If a notification is shown during user interaction, users of assistive technology may not
notice it appear as sighted users would. To ensure the notification content is read by
screenreaders and similar tools, ensure that the Notification is rendered inside a "live"
region.

This can be done either:

- Cross-platform: by rendering the Notification inside a container that accepts React Native's
  accessibility props, such as [Box](box), [Card](card),
  [StackView](stack-view) or [StackWrap](stack-wrap), or
  a React Native [View](https://reactnative.dev/docs/view), then giving that component the prop
  [`accessibilityLiveRegion="polite"`](https://reactnative.dev/docs/accessibility#accessibilityliveregion-android) (which
  on web maps to [`aria-live="polite"`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions)).
- Web-only: by rendering the Notification inside a HTML container with
  [`aria-live="polite"`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions)

Note that the "live" container should be rendered initially, before the Notification is added.

```jsx live
function LiveExample() {
  const [pressed, setPressed] = useState(false)
  const handlePress = () => setPressed(true)
  return (
    <StackView space={3} accessibilityLiveRegion="polite">
      {pressed && (
        <Notification variant={{ validation: 'success' }}>
          Data has been successfully saved.
        </Notification>
      )}
      <Button onPress={handlePress}>Save data</Button>
    </StackView>
  )
}
```

Note that `style: 'success'` variant **will be deprecated in next major release.**

```jsx live
function LiveExample() {
  const [pressed, setPressed] = useState(false)
  const handlePress = () => setPressed(true)
  return (
    <StackView space={3} accessibilityLiveRegion="polite">
      {pressed && (
        <Notification variant={{ style: 'success' }}>
          Data has been successfully saved.
        </Notification>
      )}
      <Button onPress={handlePress}>Save data</Button>
    </StackView>
  )
}
```

### Platform considerations

<AvailableOnBoth />

## Props

<PropsTable base={BaseDocs} />

## Tokens

<TokensTable base={BaseDocs} component="Notification" />

## Variants

### Success

Use the success variant to provide feedback of a successful operation. The message will include an icon to indicate
meaning and importance.

```jsx live
<Notification variant={{ validation: 'success' }}>
  Your password was updated successfully.
</Notification>
```

Note that `style: 'success'` variant **will be deprecated in next major release.**

```jsx live
<Notification variant={{ style: 'success' }}>Your password was updated successfully.</Notification>
```

### Warning

Use the warning variant to provide feedback of a warning; users would still be able to proceed forward.
The message will include an icon to indicate meaning and importance.

```jsx live
<Notification variant={{ validation: 'warning' }}>
  Looks like our registration is temporarily down. Please try again later.
</Notification>
```

Note that the `style: 'warning'` variant **will be deprecated in next major release.**

```jsx live
<Notification variant={{ style: 'warning' }}>
  Looks like our registration is temporarily down. Please try again later.
</Notification>
```

### Error

Use the error variant to provide feedback of a failed operation. The message will include an icon to indicate meaning and importance.

```jsx live
<Notification variant={{ validation: 'error' }}>
  The credentials you've provided are invalid.
</Notification>
```

Note that the `style: 'error'` variant **will be deprecated in next major release.**

```jsx live
<Notification variant={{ style: 'error' }}>
  The credentials you've provided are invalid.
</Notification>
```

### Feature

Use the feature variant to visually emphasize a marketing offer/campaign. The message will include an icon to indicate meaning and importance

```jsx live
<Notification variant={{ validation: 'feature' }}>
  Your password was updated successfully.
</Notification>
```

### Dismissible

Dismissible notifications should only be used for default or success notifications where there is no action needed from the user.
If the information is passive then it should be dismissible as indicated by an interactive close button on the far right.
If the notification requires an action then make the option(s) clear with a `ChevronLink` or `Link`.

Use the `dismissible` prop to allow users to dismiss the Notification at any time. Once dismissed, the Notification is removed from the DOM.

```jsx live
<Notification dismissible>Your password was updated successfully.</Notification>
```

```jsx live
<Notification variant={{ style: 'success' }} dismissible>
  Your password was updated successfully.
</Notification>
```

Note that the `style: 'success'` variant **will be deprecated in next major release.**

```jsx live
<Notification variant={{ style: 'success' }} dismissible>
  Your password was updated successfully.
</Notification>
```

:::info

- Default and Success variants are dismissible
- Error and Warning variants are not dismissible

:::

### Subtle

Use the subtle variant when you don't wan't to have the conventional borders of the default style.

```jsx live
<Notification variant={{ style: 'subtle' }}>
  <Typography>
    Tip: These services are best suited for large business organizations.{' '}
    <Link href="https://telus.com">Order products and services at TELUS.com</Link>
  </Typography>
</Notification>
```

### System message

Use full-width `Notifications` to show system-based messages coming from the application, not in response to user action.
Show system notifications at the top of the page, below the navigation, and expands the full-width of the viewport

```jsx live
<Notification variant={{ style: 'system' }}>
  <Typography>
    Tip: These services are best suited for large business organizations.{' '}
    <Link href="https://telus.com">Order products and services at TELUS.com</Link>
  </Typography>
</Notification>
```

Note that the `system` variant **will be deprecated in next major release.**

```jsx live
<Notification system>
  <Typography>
    Tip: These services are best suited for large business organizations.{' '}
    <Link href="https://telus.com">Order products and services at TELUS.com</Link>
  </Typography>
</Notification>
```

#### Content min width

Use the `contentMinWidth` prop to set the minimum width of the content inside the Notification when using the `system` variant. This is useful when you want to limit the content width for better readability.

```jsx live
<Notification system contentMinWidth={{ xl: 'max', lg: 'max', md: 'max', sm: 'full', xs: 'full' }}>
  <Typography>
    Tip: These services are best suited for large business organizations.{' '}
    <Link href="https://telus.com">Order products and services at TELUS.com</Link>
  </Typography>
</Notification>
```

## Additional Variants

Please note that if you are building an application that is brand specific you can use these variants.

These brand specific variants are defined in the community themes and you'd need to install those relevant packages and use `mergeThemes` from `@telus-uds/system-constants` to merge the brand specific theme with the core theme.

Here's an example of how to update the application's entry point to merge the Koodo community theme with the core theme:

```jsx
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { BaseProvider } from '@telus-uds/components-base'
import themeKoodo from '@telus-uds/theme-koodo'
import themeKoodoCommunity from '@telus-uds/themes-community.theme-koodo'
import { mergeThemes } from '@telus-uds/system-constants'

import App from './App'

const rootElement = document.getElementById('root')
const root = createRoot(rootElement)

root.render(
  <StrictMode>
    <BaseProvider defaultTheme={mergeThemes(themeKoodoCommunity, themeKoodo)}>
      <App />
    </BaseProvider>
  </StrictMode>
)
```

<AdditionalVariants />

## Feedback

<Feedback component="Notification" />
