suiss/ui ยท Interaction
Top Banner
Short banners that slide in from the top of the screen, queue one at a time and can be swiped up to dismiss.
Top Banner is an open-source interaction from suiss/ui for React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.

TopBannerProvider shows banners requested with show from useTopBanner. Each banner slides down below the top safe area with a title, an optional description, icon and action button, and hides after 4 seconds by default.
Banners queue and appear one at a time, with a short pause between them. Swiping a banner up past a small distance, or flicking it up, dismisses it; dragging pauses the timer. Use it for brief confirmations and status updates, such as a copied link or a restored connection.
Installation
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/interactions/top-banner.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/interactions/top-banner.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/interactions/top-banner.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
Showing
A banner with a title and description, shown on mount.

With icon
A banner with a leading icon.
Pass a Phosphor icon component as icon.
With action
A banner with an action button.
Pass action as { label, onPress }. Pressing it runs onPress and dismisses the banner.

Title only
A banner with only a title.

Accessibility
- The banner has the
alertrole and is a polite live region. - A string title is announced when the banner appears.
- The banner has a
dismissaccessibility action.
API Reference
TopBannerProvider
Holds the banner queue and renders the current banner in a portal.
| Prop | Type | Default |
|---|---|---|
timeout | number | 4000 |
className | string | - |
portalHost | string | - |
children | React.ReactNode | - |
Wrap the app in TopBannerProvider, then call show({ title, description?, icon?, action?, timeout? }) from useTopBanner. show returns an id that you can pass to dismiss; calling dismiss() with no id dismisses the current banner.
timeout is the default time in milliseconds before a banner hides. Pass a timeout of 0 or Infinity to show to keep a banner until dismissed. className styles the banner card, and portalHost names a portal host to render into. Banners are up to 384 points wide and centered, and slide animations respect the system reduce motion setting.
TopBannerAction
| Parameter | Type | Default |
|---|---|---|
_ย title | LocalizedStringResource | - |
action | () -> Void | - |
| Property | Type |
|---|---|
title | LocalizedStringResource |
action | @MainActor @Sendable () -> Void |
TopBannerItem
| Property | Type |
|---|---|
id | UUID |
title | LocalizedStringResource |
description | LocalizedStringResource? |
icon | Image? |
action | TopBannerAction? |
duration | Duration? |
TopBannerManager
Takes no parameters.
| Property | Type |
|---|---|
static shared | TopBannerManager |
queue | [TopBannerItem] |
timeout | Duration |
current | TopBannerItem? |
TopBannerManager.show
| Parameter | Type | Default |
|---|---|---|
_ย title | LocalizedStringResource | - |
description | LocalizedStringResource? | nil |
icon | Image? | nil |
action | TopBannerAction? | nil |
duration | Duration? | nil |
Returns UUID.
TopBannerManager.dismiss
| Parameter | Type | Default |
|---|---|---|
_ย id | UUID? | nil |
TopBannerManager.dismissAll
Takes no parameters.
.topBanner
| Parameter | Type | Default |
|---|---|---|
_ย manager | TopBannerManager | .shared |
timeout | Duration | .seconds(4) |
TopBannerAction
| Parameter | Type | Default |
|---|---|---|
label | String | - |
onClick | () -> Unit | - |
TopBannerState.show
| Parameter | Type | Default |
|---|---|---|
title | String | - |
description | String? | null |
icon | ImageVector? | null |
action | TopBannerAction? | null |
timeoutMillis | Long | defaultTimeoutMillis |
Returns Long.
TopBannerState.dismiss
Takes no parameters.
rememberTopBannerState
| Parameter | Type | Default |
|---|---|---|
defaultTimeoutMillis | Long | 4000 |
Returns TopBannerState.
TopBannerProvider
Holds the banner queue and renders the current banner in a portal.
| Parameter | Type | Default |
|---|---|---|
state | TopBannerState | - |
modifier | Modifier | Modifier |
content | @Composable () -> Unit | - |



