Banner
Informational, success and critical messages in Shopify green with a status icon, heading and dismiss — the official Polaris voice for good news and bad.
Real scenarios
The component as it is used in a product — not a specimen grid.
Morning report, four voices
Each banner is the official Polaris tone — informational, success, warning, critical — with its icon, heading and one action. Dismiss one and it really leaves; the restore link brings them all back.
A boutique from Isfahan asked to carry your candle line in its spring shelf.
From today, customers receive the order-confirmation email the moment they pay.
Minimal soy candle and single-origin coffee each have fewer than 10 units left.
Three failed checkout attempts have been recorded since 9:12.
Compact tones
Without the body text the banner collapses to one line — same tones, same icons, quiet enough for inline placement.
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| tone | string | 'info' | info · success · warning · critical; each tone brings its icon and subdued tint. |
| dismiss | button | '×' | The banner-end close ×; a restore link brings dismissed banners back. |
| action | link | null | One text action under the body, like «reconnect gateway». |
Snippet
<div class="plbn" data-tone="success" x-data>
<svg class="plbn-icon">✓</svg>
<div>
<b>Template saved</b>
<p>The changes have been live on the storefront since 9:41.</p>
</div>
<button class="plbn-x" aria-label="Dismiss banner">×</button>
</div>
<style>
.plbn { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px;
border: 1px solid #E3E3E3; background: #FFF; }
.plbn[data-tone='success'] { color: #008060; background: #E3F1ED;
border-color: color-mix(in srgb, #008060 20%, #FFF); }
.plbn-x { margin-inline-start: auto; border: none; background: none; cursor: pointer; }
</style>
// resources/js/Pages/Dashboard.tsx — banners reflect flashes sent
// by the backend; the snippet renders them and handles dismiss.
import { Head, usePage } from '@inertiajs/react';
import Banners from '@/components/polaris/Banners';
export default function Dashboard() {
const { flashes } = usePage().props; // [{ tone: 'success', title: 'Template saved' }, …]
return (
<>
<Head title="Dashboard" />
<Banners items={flashes} />
</>
);
}
import { useState } from 'react';
import '@nabuxai/ui-core/css';
type Tone = 'info' | 'success' | 'warning' | 'critical';
const COPY: Record<Tone, string> = {
info: 'A collaboration request arrived',
success: 'Notification template saved',
warning: 'Two products are running low',
critical: 'Payment gateway is not responding',
};
export default function Banners() {
const [open, setOpen] = useState<Record<Tone, boolean>>({ info: true, success: true, warning: true, critical: true });
const anyClosed = Object.values(open).some((v) => !v);
return (
<div className="plbn-root">
{(Object.keys(open) as Tone[]).map((tone) =>
open[tone] ? (
<div key={tone} className="plbn" data-tone={tone} role={tone === 'critical' ? 'alert' : 'status'}>
<div><b>{COPY[tone]}</b></div>
<button className="plbn-x" aria-label="Dismiss banner" onClick={() => setOpen({ ...open, [tone]: false })}>✕</button>
</div>
) : null,
)}
{anyClosed && (
<button className="plbn-restore" onClick={() => setOpen({ info: true, success: true, warning: true, critical: true })}>
Restore dismissed banners
</button>
)}
<style>{`
.plbn { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px;
border: 1px solid #E3E3E3; background: #FFF; }
.plbn[data-tone='success'] { color: #008060; background: #E3F1ED;
border-color: color-mix(in srgb, #008060 20%, #FFF); }
.plbn-x { margin-inline-start: auto; border: none; background: none; cursor: pointer; }
`}</style>
</div>
);
}
<!-- Banners.vue -->
<script setup lang="ts">
import { reactive, computed } from 'vue';
import '@nabuxai/ui-core/css';
type Tone = 'info' | 'success' | 'warning' | 'critical';
const COPY: Record<Tone, string> = {
info: 'A collaboration request arrived',
success: 'Notification template saved',
warning: 'Two products are running low',
critical: 'Payment gateway is not responding',
};
const open = reactive<Record<Tone, boolean>>({ info: true, success: true, warning: true, critical: true });
const anyClosed = computed(() => Object.values(open).some((v) => !v));
const restore = () => Object.assign(open, { info: true, success: true, warning: true, critical: true });
</script>
<template>
<div class="plbn-root">
<template v-for="tone in (Object.keys(open) as Tone[])" :key="tone">
<div v-if="open[tone]" class="plbn" :data-tone="tone" :role="tone === 'critical' ? 'alert' : 'status'">
<div><b>{{ COPY[tone] }}</b></div>
<button class="plbn-x" aria-label="Dismiss banner" @click="open[tone] = false">✕</button>
</div>
</template>
<button v-if="anyClosed" class="plbn-restore" @click="restore">Restore dismissed banners</button>
</div>
</template>
<style scoped>
.plbn { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px;
border: 1px solid #e3e3e3; background: #fff; }
.plbn[data-tone='success'] { color: #008060; background: #e3f1ed;
border-color: color-mix(in srgb, #008060 20%, #fff); }
.plbn-x { margin-inline-start: auto; border: none; background: none; cursor: pointer; }
</style>
<!-- Banners.svelte -->
<script lang="ts">
import '@nabuxai/ui-core/css';
type Tone = 'info' | 'success' | 'warning' | 'critical';
const COPY: Record<Tone, string> = {
info: 'A collaboration request arrived',
success: 'Notification template saved',
warning: 'Two products are running low',
critical: 'Payment gateway is not responding',
};
let open = $state<Record<Tone, boolean>>({ info: true, success: true, warning: true, critical: true });
const anyClosed = $derived(Object.values(open).some((v) => !v));
const restore = () => Object.assign(open, { info: true, success: true, warning: true, critical: true });
</script>
<div class="plbn-root">
{#each Object.keys(open) as tone (tone)}
{#if open[tone as Tone]}
<div class="plbn" data-tone={tone} role={tone === 'critical' ? 'alert' : 'status'}>
<div><b>{COPY[tone as Tone]}</b></div>
<button class="plbn-x" aria-label="Dismiss banner" onclick={() => (open[tone as Tone] = false)}>✕</button>
</div>
{/if}
{/each}
{#if anyClosed}<button class="plbn-restore" onclick={restore}>Restore dismissed banners</button>{/if}
</div>
<style>
.plbn { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px;
border: 1px solid #e3e3e3; background: #fff; }
.plbn[data-tone='success'] { color: #008060; background: #e3f1ed;
border-color: color-mix(in srgb, #008060 20%, #fff); }
.plbn-x { margin-inline-start: auto; border: none; background: none; cursor: pointer; }
</style>