PhiaUi.Components.Banner (phia_ui v0.1.17)

Copy Markdown View Source

Full-width page-level feedback banners inspired by Atlassian Design System Banner, Bootstrap Alerts, and GitHub's site-wide announcement banners.

These components occupy the full width of their container and are used for system-wide messages, marketing announcements, and consent requirements.

Sub-components

ComponentPurpose
banner/1Full-width dismissible feedback strip (top/inline)
announcement_bar/1Slim sticky marketing/system announcement at the very top
cookie_consent/1GDPR-compliant cookie consent panel (bottom of viewport)

Banner (full-width inline feedback)

<.banner variant={:warning} :if={@maintenance_mode}>
  <:icon><.icon name="triangle-alert" class="h-4 w-4" /></:icon>
  Scheduled maintenance on Saturday 24 AM UTC.
  <:action href="/status">View status</:action>
</.banner>

Announcement bar (sticky top)

<.announcement_bar>
  🎉 PhiaUI 1.0 is out! Read the
  <:link href="/blog/v1">release notes</:link>.
</.announcement_bar>
<.cookie_consent :if={!@cookies_accepted}>
  We use cookies to improve your experience.
  <:action phx-click="accept_cookies">Accept all</:action>
  <:secondary phx-click="open_cookie_settings">Settings</:secondary>
</.cookie_consent>

Summary

Functions

Renders a slim sticky announcement bar at the top of the page.

Renders a full-width, optionally dismissible feedback banner.

Renders a GDPR-compliant cookie consent panel at the bottom of the viewport.

Functions

announcement_bar(assigns)

Renders a slim sticky announcement bar at the top of the page.

Used for high-priority marketing or system announcements (new releases, feature announcements, system notices). Typically placed above the navigation header in the root layout.

Example

<.announcement_bar id="release-bar">
  PhiaUI 1.0 is here!
  <:link href="/changelog">See what's new</:link>
</.announcement_bar>

Attributes

  • id (:string) - Optional ID — required for JS.hide dismiss. Defaults to nil.
  • dismissable (:boolean) - When true, renders a close button. Defaults to true.
  • class (:string) - Additional CSS classes. Defaults to nil.
  • Global attributes are accepted. HTML attrs forwarded to the root <div>.

Slots

  • inner_block (required) - Announcement text. Can include inline HTML elements.
  • link - Inline link rendered inside the text — rendered as an <a> tag.

banner(assigns)

Renders a full-width, optionally dismissible feedback banner.

Use for page-level alerts that need more visual prominence than an Alert component but should not block the user like a modal would. Common uses: maintenance windows, rate limit warnings, subscription expiry notices.

Example

<.banner id="trial-banner" variant={:warning}>
  <:icon><.icon name="clock" class="h-4 w-4" /></:icon>
  Your trial expires in 3 days.
  <:action phx-click="open_billing">Upgrade now</:action>
</.banner>

Attributes

  • id (:string) - Optional ID — required for JS.hide dismiss. Defaults to nil.
  • variant (:atom) - Visual style controlling background, border and icon defaults. Defaults to :default. Must be one of :default, :info, :success, :warning, or :destructive.
  • closeable (:boolean) - When true, renders an × dismiss button using JS.hide. Defaults to true.
  • class (:string) - Additional CSS classes. Defaults to nil.
  • Global attributes are accepted. HTML attrs forwarded to the root <div>.

Slots

  • icon - Optional leading icon (recommended: h-4 w-4).
  • inner_block (required) - Banner message text.
  • action - Primary action — rendered as a link/button on the right.