Skip to content
Klarhimmel UI

Banner

Your trial ends in 3 days

Add a payment method to keep your rooms and rates.
npx shadcn add @klarhimmel/banner

Examples

  • Tones

  • Actions

  • Form

DetailsAbout, usage, props and more

An inline message in the page flow: information, a notice or an error, with an optional next step.

When to use

  • Use for

    A message about the page or form it sits in, such as a notice or a failed save.

  • Not for

    A confirmation that can vanish. Use a Toast.

  • Pairs with

    Button, Text link, forms.

Preview

Booking confirmed

Your table at Exempelhotellet is reserved for Friday at 19:00.

Scheduled maintenance

The booking system is read-only on Sunday between 02:00 and 03:00.
banner.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { Banner } from '@/components/klarhimmel/ui/banner';

export default function Example() {
  return (
    <Theme theme="brand">
      <Banner tone="error" title="Payment failed">
        The card was declined.
      </Banner>
    </Theme>
  );
}

Import

Import

import { Banner } from '@/components/klarhimmel/ui/banner';
Files
banner.tsx, in components/klarhimmel/ui/. With it: icon-button, theme, utils. npm: lucide-react.
Render in
Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.

Props

PropTypeDefaultDescription
tone'info' | 'neutral' | 'error''info'Error is announced at once (role=alert); the others wait (role=status).
titleReactNode-A short bold line.
childrenReactNode-The message.
actionReactNode-A Button or TextLink for the next step.
onDismiss() => void-Shows a close button.
dismissLabelstring'Dismiss'Accessible name of the close button; pass it translated.
classNamestring-Extra classes, merged after the component's own.

Accessibility

KeyDoes
TabMoves to the action and the close button
Enter / SpaceActivates the focused button

An error banner is announced at once; the others are announced politely.

Accessibility