Skip to content

Banner

A strip across the top of the app with a message that concerns everything: maintenance, a plan limit, being offline.

import { Banner } from '@sypnia/ui/react'

On this page
  1. Tones
  2. Follows a state
  3. When to use it
  4. For everyone
  5. Props

Tones

Information, warning, failure, success and the lit one for good news.

Maintenance on Sunday at 03:00 UTC. The console will be read only for about 10 minutes.
This project has used 4.6 of its 5 GB.
The last payment failed. The project pauses on December 1.
You are back online. Your changes were saved.
Realtime is now included in every plan.
Code
import { Banner, Button } from '@sypnia/ui/react';

// In an app there is one banner at most, across the top. Here they are stacked to compare.
export default function Tones() {
  return (
    <div className="sy-stack">
      <Banner>Maintenance on Sunday at 03:00 UTC. The console will be read only for about 10 minutes.</Banner>
      <Banner tone="warn" action={<Button size="sm">See plans</Button>}>This project has used 4.6 of its 5 GB.</Banner>
      <Banner tone="fail" action={<Button size="sm">Update card</Button>}>The last payment failed. The project pauses on December 1.</Banner>
      <Banner tone="ok">You are back online. Your changes were saved.</Banner>
      <Banner tone="light" action={<Button size="sm">Read what is new</Button>}>Realtime is now included in every plan.</Banner>
    </div>
  );
}

Follows a state

Turn the connection off: the banner appears above the content and leaves when it returns.

Storefront

5 tables · 5,552 rows

Code
import { useState } from 'react';
import { Banner, Button, PageHeader, Switch } from '@sypnia/ui/react';

// Turn the connection off and on: the banner sits above the page and reports the state of the whole app.
export default function Offline() {
  const [online, setOnline] = useState(true);
  return (
    <div className="sy-stack">
      {!online && <Banner tone="warn" action={<Button size="sm" onClick={() => setOnline(true)}>Try now</Button>}>You are offline. Changes will be sent when the connection returns.</Banner>}
      <PageHeader title="Storefront" lead="5 tables · 5,552 rows" />
      <Switch label="Connection" description="Stands in for the network of this example." checked={online} onChange={(e) => setOnline(e.target.checked)} />
    </div>
  );
}

When to use it

Use it when

  • The message is about the whole project or account, not one page.
  • It stays while the situation lasts and leaves by itself when it ends.
  • One action at most, at the end: «Update card», «See plans».

Do not use it when

  • It concerns one page or one region: Alert.
  • It answers an action the person just took: toast.
  • It is marketing that most people will close: a banner that is always there stops being read.
  • There would be two at once: show the most serious one.

For everyone

  • It is a polite live region (role="status"): screen readers say it when it appears, without interrupting.
  • It pushes the app down instead of covering it, so nothing is hidden behind it.
  • On phones the text wraps and the button goes under it; nothing scrolls sideways.

Props

BannerTypeDefault
action ReactNode
tone "light" | "info" | "ok" | "warn" | "fail" info
  1. Tones
  2. Follows a state
  3. When to use it
  4. For everyone
  5. Props

    Search pages, sections and terms