Announcement Bar
A thin strip above the page with one sentence and a link.
Install
npx ui8kit add announcement-barPulls in: block, button, compose, container, group, inline, kit-box, kit-button, kit-link, kit-text, link-plain, lucide-icon, text, utils
Preview
Code
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdnnpx ui8kit add announcement-bar<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
A thin strip above the page: an icon, one sentence, a link and an optional close button. Axes: tone (default,
muted), layout (center, split), dismiss (show, hide).
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
export type AnnouncementBarProps = {
label: string;
text: string;
cta?: string;
ctaHref?: string;
icon?: string;
dismissLabel: string;
tone?: "default" | "muted";
layout?: "center" | "split";
dismiss?: "show" | "hide";
badgeLabel?: string;
badge?: "none" | "show";
position?: "top" | "bottom";
landmarkLabel?: string;
};
</script>
<script lang="ts">
import Block from "../compose/Block.svelte";
import Button from "../compose/Button.svelte";
import Container from "../compose/Container.svelte";
import Group from "../compose/Group.svelte";
import Inline from "../compose/Inline.svelte";
import LinkPlain from "../compose/LinkPlain.svelte";
import LucideIcon from "../icons/LucideIcon.svelte";
import Text from "../compose/Text.svelte";
import { cn, urlOf } from "../utils";
let {
label,
text,
cta,
ctaHref,
icon = "megaphone",
dismissLabel,
tone = "default",
layout = "center",
dismiss = "hide",
badgeLabel,
badge = "none",
position = "top",
landmarkLabel,
}: AnnouncementBarProps = $props();
</script>
<Block
tag="aside"
class={cn(
"w-full",
(((position as string) === "bottom") ? "sticky bottom-0 z-40 border-t border-border" : ""),
(
(tone as string) === "muted" ? "bg-muted text-foreground"
: "bg-primary text-primary-foreground"
)
)}
aria-label={(landmarkLabel ?? label)}
data-layout={layout}
data-slot="announcement"
>
<Container
class={cn(
"mx-auto w-full max-w-6xl px-4",
"flex items-center gap-4 py-2",
(((layout as string) === "split") ? "justify-between" : "justify-center")
)}
data-slot="container"
>
<Group
gap="4"
align="center"
class={cn(
"min-w-0 flex-wrap",
((((layout as string) === "center") && ((dismiss as string) === "show")) ? "ml-auto" : "")
)}
>
<LucideIcon name={icon} size={16} />
{#if ((badge as string) === "show")}
<Inline
class="rounded px-2 py-0 text-xs font-semibold inset-ring inset-ring-current"
data-slot="announcement-badge"
>
{badgeLabel}
</Inline>
{/if}
<Text size="sm">
{text}
</Text>
{#if cta}
<LinkPlain
href={urlOf(ctaHref)}
class="inline-flex items-center gap-2 text-sm font-semibold underline underline-offset-4"
data-slot="announcement-cta"
>
{cta}
<LucideIcon name="arrow-right" size={16} />
</LinkPlain>
{/if}
</Group>
{#if ((dismiss as string) === "show")}
<Button variant="ghost" size="sm" class="ml-auto shrink-0 text-current" type="button" aria-label={dismissLabel}>
<LucideIcon name="x" size={16} />
</Button>
{/if}
</Container>
</Block>
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdnnpx ui8kit add announcement-bar// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* A thin strip above the page: an icon, one sentence, a link and an optional close button. Axes: tone (default,
* muted), layout (center, split), dismiss (show, hide).
*/
import { type ReactNode } from "react";
import { Block, Button, Container, Group, Inline, LinkPlain, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { cn, urlOf } from "../utils";
export type AnnouncementBarProps = {
label: string;
text: string;
cta?: string;
ctaHref?: string;
icon?: string;
dismissLabel: string;
tone?: "default" | "muted";
layout?: "center" | "split";
dismiss?: "show" | "hide";
badgeLabel?: string;
badge?: "none" | "show";
position?: "top" | "bottom";
landmarkLabel?: string;
};
export function AnnouncementBar({
label,
text,
cta,
ctaHref,
icon = "megaphone",
dismissLabel,
tone = "default",
layout = "center",
dismiss = "hide",
badgeLabel,
badge = "none",
position = "top",
landmarkLabel,
}: AnnouncementBarProps) {
return (
<Block
tag="aside"
className={cn(
"w-full",
(((position as string) === "bottom") ? "sticky bottom-0 z-40 border-t border-border" : ""),
(
(tone as string) === "muted" ? "bg-muted text-foreground"
: "bg-primary text-primary-foreground"
)
)}
aria-label={(landmarkLabel ?? label)}
data-layout={layout}
data-slot="announcement"
>
<Container
className={cn(
"mx-auto w-full max-w-6xl px-4",
"flex items-center gap-4 py-2",
(((layout as string) === "split") ? "justify-between" : "justify-center")
)}
data-slot="container"
>
<Group
gap="4"
align="center"
className={cn(
"min-w-0 flex-wrap",
((((layout as string) === "center") && ((dismiss as string) === "show")) ? "ml-auto" : "")
)}
>
<LucideIcon name={icon} size={16} />
{((badge as string) === "show") ? (
<Inline
className="rounded px-2 py-0 text-xs font-semibold inset-ring inset-ring-current"
data-slot="announcement-badge"
>
{badgeLabel}
</Inline>
) : null}
<Text size="sm">
{text}
</Text>
{cta ? (
<LinkPlain
href={urlOf(ctaHref)}
className="inline-flex items-center gap-2 text-sm font-semibold underline underline-offset-4"
data-slot="announcement-cta"
>
{cta}
<LucideIcon name="arrow-right" size={16} />
</LinkPlain>
) : null}
</Group>
{((dismiss as string) === "show") ? (
<Button
variant="ghost"
size="sm"
className="ml-auto shrink-0 text-current"
type="button"
aria-label={dismissLabel}
>
<LucideIcon name="x" size={16} />
</Button>
) : null}
</Container>
</Block>
);
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdnnpx ui8kit add announcement-bar<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
A thin strip above the page: an icon, one sentence, a link and an optional close button. Axes: tone (default,
muted), layout (center, split), dismiss (show, hide).
-->
<script lang="ts">
export type AnnouncementBarProps = {
label: string;
text: string;
cta?: string;
ctaHref?: string;
icon?: string;
dismissLabel: string;
tone?: "default" | "muted";
layout?: "center" | "split";
dismiss?: "show" | "hide";
badgeLabel?: string;
badge?: "none" | "show";
position?: "top" | "bottom";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Block from "../compose/Block.vue";
import Button from "../compose/Button.vue";
import Container from "../compose/Container.vue";
import Group from "../compose/Group.vue";
import Inline from "../compose/Inline.vue";
import LinkPlain from "../compose/LinkPlain.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Text from "../compose/Text.vue";
import { cn, urlOf } from "../utils";
const {
label,
text,
cta,
ctaHref,
icon = "megaphone",
dismissLabel,
tone = "default",
layout = "center",
dismiss = "hide",
badgeLabel,
badge = "none",
position = "top",
landmarkLabel,
} = defineProps<AnnouncementBarProps>();
</script>
<template>
<Block
tag="aside"
:class="cn(
'w-full',
(((position as string) === 'bottom') ? 'sticky bottom-0 z-40 border-t border-border' : ''),
(
(tone as string) === 'muted' ? 'bg-muted text-foreground'
: 'bg-primary text-primary-foreground'
)
)"
:aria-label="(landmarkLabel ?? label)"
:data-layout="layout"
data-slot="announcement"
>
<Container
:class="cn(
'mx-auto w-full max-w-6xl px-4',
'flex items-center gap-4 py-2',
(((layout as string) === 'split') ? 'justify-between' : 'justify-center')
)"
data-slot="container"
>
<Group
gap="4"
align="center"
:class="cn(
'min-w-0 flex-wrap',
((((layout as string) === 'center') && ((dismiss as string) === 'show')) ? 'ml-auto' : '')
)"
>
<LucideIcon :name="icon" :size="16" />
<Inline v-if="((badge as string) === 'show')"
class="rounded px-2 py-0 text-xs font-semibold inset-ring inset-ring-current"
data-slot="announcement-badge"
>
{{ badgeLabel }}
</Inline>
<Text size="sm">
{{ text }}
</Text>
<LinkPlain v-if="cta"
:href="urlOf(ctaHref)"
class="inline-flex items-center gap-2 text-sm font-semibold underline underline-offset-4"
data-slot="announcement-cta"
>
{{ cta }}
<LucideIcon name="arrow-right" :size="16" />
</LinkPlain>
</Group>
<Button v-if="((dismiss as string) === 'show')"
variant="ghost"
size="sm"
class="ml-auto shrink-0 text-current"
type="button"
:aria-label="dismissLabel"
>
<LucideIcon name="x" :size="16" />
</Button>
</Container>
</Block>
</template>
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdnnpx ui8kit add announcement-bar// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* A thin strip above the page: an icon, one sentence, a link and an optional close button. Axes: tone (default,
* muted), layout (center, split), dismiss (show, hide).
*/
import { type JSX } from "solid-js";
import { Block, Button, Container, Group, Inline, LinkPlain, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { cn, urlOf } from "../utils";
export type AnnouncementBarProps = {
label: string;
text: string;
cta?: string;
ctaHref?: string;
icon?: string;
dismissLabel: string;
tone?: "default" | "muted";
layout?: "center" | "split";
dismiss?: "show" | "hide";
badgeLabel?: string;
badge?: "none" | "show";
position?: "top" | "bottom";
landmarkLabel?: string;
};
export function AnnouncementBar({
label,
text,
cta,
ctaHref,
icon = "megaphone",
dismissLabel,
tone = "default",
layout = "center",
dismiss = "hide",
badgeLabel,
badge = "none",
position = "top",
landmarkLabel,
}: AnnouncementBarProps) {
return (
<Block
tag="aside"
class={cn(
"w-full",
(((position as string) === "bottom") ? "sticky bottom-0 z-40 border-t border-border" : ""),
(
(tone as string) === "muted" ? "bg-muted text-foreground"
: "bg-primary text-primary-foreground"
)
)}
aria-label={(landmarkLabel ?? label)}
data-layout={layout}
data-slot="announcement"
>
<Container
class={cn(
"mx-auto w-full max-w-6xl px-4",
"flex items-center gap-4 py-2",
(((layout as string) === "split") ? "justify-between" : "justify-center")
)}
data-slot="container"
>
<Group
gap="4"
align="center"
class={cn(
"min-w-0 flex-wrap",
((((layout as string) === "center") && ((dismiss as string) === "show")) ? "ml-auto" : "")
)}
>
<LucideIcon name={icon} size={16} />
{((badge as string) === "show") ? (
<Inline
class="rounded px-2 py-0 text-xs font-semibold inset-ring inset-ring-current"
data-slot="announcement-badge"
>
{badgeLabel}
</Inline>
) : null}
<Text size="sm">
{text}
</Text>
{cta ? (
<LinkPlain
href={urlOf(ctaHref)}
class="inline-flex items-center gap-2 text-sm font-semibold underline underline-offset-4"
data-slot="announcement-cta"
>
{cta}
<LucideIcon name="arrow-right" size={16} />
</LinkPlain>
) : null}
</Group>
{((dismiss as string) === "show") ? (
<Button variant="ghost" size="sm" class="ml-auto shrink-0 text-current" type="button" aria-label={dismissLabel}>
<LucideIcon name="x" size={16} />
</Button>
) : null}
</Container>
</Block>
);
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdnnpx ui8kit add announcement-bar// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/organisms/announcement-bar.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/ui/button"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/icons"
"github.com/ui8kit/codegen/generated/templ/ui/link"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// AnnouncementBarProps are the props of AnnouncementBar; the values are the JSON shapes of the TypeScript props.
type AnnouncementBarProps struct {
Label any `json:"label"`
Text any `json:"text"`
Cta any `json:"cta"`
CtaHref any `json:"ctaHref"`
Icon any `json:"icon"`
DismissLabel any `json:"dismissLabel"`
Tone any `json:"tone"`
Layout any `json:"layout"`
Dismiss any `json:"dismiss"`
BadgeLabel any `json:"badgeLabel"`
Badge any `json:"badge"`
Position any `json:"position"`
LandmarkLabel any `json:"landmarkLabel"`
}
// A thin strip above the page: an icon, one sentence, a link and an optional close button. Axes: tone (default, muted), layout (center, split), dismiss (show, hide).
templ AnnouncementBar(p AnnouncementBarProps) {
{{ vLabel := p.Label }}
{{ vText := p.Text }}
{{ vCta := p.Cta }}
{{ vCtaHref := p.CtaHref }}
{{ vIcon := uiutils.Def(p.Icon, "megaphone") }}
{{ vDismissLabel := p.DismissLabel }}
{{ vTone := uiutils.Def(p.Tone, "default") }}
{{ vLayout := uiutils.Def(p.Layout, "center") }}
{{ vDismiss := uiutils.Def(p.Dismiss, "hide") }}
{{ vBadgeLabel := p.BadgeLabel }}
{{ vBadge := uiutils.Def(p.Badge, "none") }}
{{ vPosition := uiutils.Def(p.Position, "top") }}
{{ vLandmarkLabel := p.LandmarkLabel }}
@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "aside", Class: uiutils.S(uiutils.Cnv("w-full", uiutils.Cond(uiutils.T(uiutils.Eq(vPosition, "bottom")), "sticky bottom-0 z-40 border-t border-border", ""), uiutils.Cond(uiutils.T(uiutils.Eq(vTone, "muted")), "bg-muted text-foreground", "bg-primary text-primary-foreground"))), Attrs: uiutils.Attrs("aria-label", uiutils.Coalesce(vLandmarkLabel, vLabel), "data-layout", vLayout, "data-slot", "announcement")}}) {
@compose.Container(compose.ContainerProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("mx-auto w-full max-w-6xl px-4", "flex items-center gap-4 py-2", uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "split")), "justify-between", "justify-center"))), Attrs: uiutils.Attrs("data-slot", "container")}}) {
@compose.Group(compose.GroupProps{Gap: "4", Align: "center", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("min-w-0 flex-wrap", uiutils.Cond(uiutils.T(uiutils.And(uiutils.Eq(vLayout, "center"), uiutils.Eq(vDismiss, "show"))), "ml-auto", "")))}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: uiutils.S(vIcon), Size: 16})
if uiutils.Eq(vBadge, "show") {
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "rounded px-2 py-0 text-xs font-semibold inset-ring inset-ring-current", Attrs: uiutils.Attrs("data-slot", "announcement-badge")}}) {
{ uiutils.Text(vBadgeLabel) }
}
}
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{}}) {
{ uiutils.Text(vText) }
}
if uiutils.T(vCta) {
@compose.LinkPlain(compose.LinkPlainProps{LinkProps: link.LinkProps{Href: uiutils.URL(vCtaHref, false), Class: "inline-flex items-center gap-2 text-sm font-semibold underline underline-offset-4", Attrs: uiutils.Attrs("data-slot", "announcement-cta")}}) {
{ uiutils.Text(vCta) }
@icons.LucideIcon(icons.LucideIconProps{Name: "arrow-right", Size: 16})
}
}
}
if uiutils.Eq(vDismiss, "show") {
@compose.Button(compose.ButtonProps{Variant: "ghost", Size: "sm", ButtonProps: button.ButtonProps{Class: "ml-auto shrink-0 text-current", Type: "button", Attrs: uiutils.Attrs("aria-label", vDismissLabel)}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: "x", Size: 16})
}
}
}
}
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdnnpx ui8kit add announcement-bar{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/announcement-bar.json
A thin strip above the page: an icon, one sentence, a link and an optional close button. Axes: tone (default, muted), layout (center, split), dismiss (show, hide).
Props (p): label, text, cta, ctaHref, icon, dismissLabel, tone, layout, dismiss, badgeLabel, badge, position, landmarkLabel. -#}
{%- set v_label = (p.label ?? null) -%}
{%- set v_text = (p.text ?? null) -%}
{%- set v_cta = (p.cta ?? null) -%}
{%- set v_ctaHref = (p.ctaHref ?? null) -%}
{%- set v_icon = (p.icon ?? 'megaphone') -%}
{%- set v_dismissLabel = (p.dismissLabel ?? null) -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_layout = (p.layout ?? 'center') -%}
{%- set v_dismiss = (p.dismiss ?? 'hide') -%}
{%- set v_badgeLabel = (p.badgeLabel ?? null) -%}
{%- set v_badge = (p.badge ?? 'none') -%}
{%- set v_position = (p.position ?? 'top') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_7 -%}
{%- set c_6 -%}
{%- set c_4 -%}
{{ include('icons/LucideIcon.html.twig', {'name': og_s(v_icon), 'size': 16}, with_context = false) }}
{%- if og_t(og_eq(v_badge, 'show')) %}
{%- set c_1 -%}
{{ og_text(v_badgeLabel) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': 'rounded px-2 py-0 text-xs font-semibold inset-ring inset-ring-current', 'attrs': og_attrs(['data-slot', 'announcement-badge']), 'children': c_1}, with_context = false) }}
{%- endif %}
{%- set c_2 -%}
{{ og_text(v_text) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'children': c_2}, with_context = false) }}
{%- if og_t(v_cta) %}
{%- set c_3 -%}
{{ og_text(v_cta) }}
{{ include('icons/LucideIcon.html.twig', {'name': 'arrow-right', 'size': 16}, with_context = false) }}
{%- endset -%}
{{ include('compose/LinkPlain.html.twig', {'href': og_url(og_s(v_ctaHref)), 'class': 'inline-flex items-center gap-2 text-sm font-semibold underline underline-offset-4', 'attrs': og_attrs(['data-slot', 'announcement-cta']), 'children': c_3}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'class': og_s(og_cnv(['min-w-0 flex-wrap', (og_t(og_and([og_eq(v_layout, 'center'), og_eq(v_dismiss, 'show')])) ? 'ml-auto' : '')])), 'children': c_4}, with_context = false) }}
{%- if og_t(og_eq(v_dismiss, 'show')) %}
{%- set c_5 -%}
{{ include('icons/LucideIcon.html.twig', {'name': 'x', 'size': 16}, with_context = false) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'ghost', 'size': 'sm', 'class': 'ml-auto shrink-0 text-current', 'type': 'button', 'attrs': og_attrs(['aria-label', v_dismissLabel]), 'children': c_5}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Container.html.twig', {'class': og_s(og_cnv(['mx-auto w-full max-w-6xl px-4', 'flex items-center gap-4 py-2', (og_t(og_eq(v_layout, 'split')) ? 'justify-between' : 'justify-center')])), 'attrs': og_attrs(['data-slot', 'container']), 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'aside', 'class': og_s(og_cnv(['w-full', (og_t(og_eq(v_position, 'bottom')) ? 'sticky bottom-0 z-40 border-t border-border' : ''), (og_t(og_eq(v_tone, 'muted')) ? 'bg-muted text-foreground' : 'bg-primary text-primary-foreground')])), 'attrs': og_attrs(['aria-label', og_coalesce([v_landmarkLabel, v_label]), 'data-layout', v_layout, 'data-slot', 'announcement']), 'children': c_7}, with_context = false) }}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdnnpx ui8kit add announcement-bar{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/announcement-bar.json
A thin strip above the page: an icon, one sentence, a link and an optional close button. Axes: tone (default, muted), layout (center, split), dismiss (show, hide).
Props (p): label, text, cta, ctaHref, icon, dismissLabel, tone, layout, dismiss, badgeLabel, badge, position, landmarkLabel. *}
{var $v_label = ($p['label'] ?? null)}
{var $v_text = ($p['text'] ?? null)}
{var $v_cta = ($p['cta'] ?? null)}
{var $v_ctaHref = ($p['ctaHref'] ?? null)}
{var $v_icon = ($p['icon'] ?? 'megaphone')}
{var $v_dismissLabel = ($p['dismissLabel'] ?? null)}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_layout = ($p['layout'] ?? 'center')}
{var $v_dismiss = ($p['dismiss'] ?? 'hide')}
{var $v_badgeLabel = ($p['badgeLabel'] ?? null)}
{var $v_badge = ($p['badge'] ?? 'none')}
{var $v_position = ($p['position'] ?? 'top')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_7}
{capture $c_6}
{capture $c_4}
{=og_include('icons/LucideIcon.latte', ['name' => og_s($v_icon), 'size' => 16])|noescape}
{if og_t(og_eq($v_badge, 'show'))}
{capture $c_1}
{=og_text($v_badgeLabel)}
{/capture}
{=og_include('compose/Inline.latte', ['class' => 'rounded px-2 py-0 text-xs font-semibold inset-ring inset-ring-current', 'attrs' => og_attrs(['data-slot', 'announcement-badge']), 'children' => (string) $c_1])|noescape}
{/if}
{capture $c_2}
{=og_text($v_text)}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'children' => (string) $c_2])|noescape}
{if og_t($v_cta)}
{capture $c_3}
{=og_text($v_cta)}
{=og_include('icons/LucideIcon.latte', ['name' => 'arrow-right', 'size' => 16])|noescape}
{/capture}
{=og_include('compose/LinkPlain.latte', ['href' => og_url(og_s($v_ctaHref)), 'class' => 'inline-flex items-center gap-2 text-sm font-semibold underline underline-offset-4', 'attrs' => og_attrs(['data-slot', 'announcement-cta']), 'children' => (string) $c_3])|noescape}
{/if}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'class' => og_s(og_cnv(['min-w-0 flex-wrap', (og_t(og_and([og_eq($v_layout, 'center'), og_eq($v_dismiss, 'show')])) ? 'ml-auto' : '')])), 'children' => (string) $c_4])|noescape}
{if og_t(og_eq($v_dismiss, 'show'))}
{capture $c_5}
{=og_include('icons/LucideIcon.latte', ['name' => 'x', 'size' => 16])|noescape}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'ghost', 'size' => 'sm', 'class' => 'ml-auto shrink-0 text-current', 'type' => 'button', 'attrs' => og_attrs(['aria-label', $v_dismissLabel]), 'children' => (string) $c_5])|noescape}
{/if}
{/capture}
{=og_include('compose/Container.latte', ['class' => og_s(og_cnv(['mx-auto w-full max-w-6xl px-4', 'flex items-center gap-4 py-2', (og_t(og_eq($v_layout, 'split')) ? 'justify-between' : 'justify-center')])), 'attrs' => og_attrs(['data-slot', 'container']), 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'aside', 'class' => og_s(og_cnv(['w-full', (og_t(og_eq($v_position, 'bottom')) ? 'sticky bottom-0 z-40 border-t border-border' : ''), (og_t(og_eq($v_tone, 'muted')) ? 'bg-muted text-foreground' : 'bg-primary text-primary-foreground')])), 'attrs' => og_attrs(['aria-label', og_coalesce([$v_landmarkLabel, $v_label]), 'data-layout', $v_layout, 'data-slot', 'announcement']), 'children' => (string) $c_7])|noescape}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdnnpx ui8kit add announcement-bar{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/announcement-bar.json
A thin strip above the page: an icon, one sentence, a link and an optional close button. Axes: tone (default, muted), layout (center, split), dismiss (show, hide).
Props (p): label, text, cta, ctaHref, icon, dismissLabel, tone, layout, dismiss, badgeLabel, badge, position, landmarkLabel. -#}
{%- set v_label = og_def(p['label'], none) -%}
{%- set v_text = og_def(p['text'], none) -%}
{%- set v_cta = og_def(p['cta'], none) -%}
{%- set v_ctaHref = og_def(p['ctaHref'], none) -%}
{%- set v_icon = og_def(p['icon'], 'megaphone') -%}
{%- set v_dismissLabel = og_def(p['dismissLabel'], none) -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_layout = og_def(p['layout'], 'center') -%}
{%- set v_dismiss = og_def(p['dismiss'], 'hide') -%}
{%- set v_badgeLabel = og_def(p['badgeLabel'], none) -%}
{%- set v_badge = og_def(p['badge'], 'none') -%}
{%- set v_position = og_def(p['position'], 'top') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_7 -%}
{%- set c_6 -%}
{%- set c_4 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': og_s(v_icon), 'Size': 16}}) }}
{%- if og_t(og_eq(v_badge, 'show')) %}
{%- set c_1 -%}
{{ og_text(v_badgeLabel) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'rounded px-2 py-0 text-xs font-semibold inset-ring inset-ring-current', 'Attrs': og_attrs(['data-slot', 'announcement-badge'])}, 'children': c_1}) }}
{%- endif %}
{%- set c_2 -%}
{{ og_text(v_text) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm'}, 'children': c_2}) }}
{%- if og_t(v_cta) %}
{%- set c_3 -%}
{{ og_text(v_cta) }}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'arrow-right', 'Size': 16}}) }}
{%- endset -%}
{{ og_include('compose/link-plain.html.j2', {'p': {'Href': og_url(og_s(v_ctaHref)), 'Class': 'inline-flex items-center gap-2 text-sm font-semibold underline underline-offset-4', 'Attrs': og_attrs(['data-slot', 'announcement-cta'])}, 'children': c_3}) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Class': og_s(og_cnv(['min-w-0 flex-wrap', ('ml-auto' if og_t(og_and([og_eq(v_layout, 'center'), og_eq(v_dismiss, 'show')])) else '')]))}, 'children': c_4}) }}
{%- if og_t(og_eq(v_dismiss, 'show')) %}
{%- set c_5 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'x', 'Size': 16}}) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'ghost', 'Size': 'sm', 'Class': 'ml-auto shrink-0 text-current', 'Type': 'button', 'Attrs': og_attrs(['aria-label', v_dismissLabel])}, 'children': c_5}) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/container.html.j2', {'p': {'Class': og_s(og_cnv(['mx-auto w-full max-w-6xl px-4', 'flex items-center gap-4 py-2', ('justify-between' if og_t(og_eq(v_layout, 'split')) else 'justify-center')])), 'Attrs': og_attrs(['data-slot', 'container'])}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'aside', 'Class': og_s(og_cnv(['w-full', ('sticky bottom-0 z-40 border-t border-border' if og_t(og_eq(v_position, 'bottom')) else ''), ('bg-muted text-foreground' if og_t(og_eq(v_tone, 'muted')) else 'bg-primary text-primary-foreground')])), 'Attrs': og_attrs(['aria-label', og_coalesce([v_landmarkLabel, v_label]), 'data-layout', v_layout, 'data-slot', 'announcement'])}, 'children': c_7}) }}
Props
Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.
A thin strip above the page: an icon, one sentence, a link and an optional close button. Axes: tone (default, muted), layout (center, split), dismiss (show, hide).
| Prop | Type | Default | Description |
|---|---|---|---|
| label (required) | string | - | accessible name of the strip |
| text (required) | string | - | |
| cta | string | - | text of the link |
| ctaHref | string | - | |
| icon | string | "megaphone" | Lucide name |
| dismissLabel (required) | string | - | accessible name of the close button |
| tone | "default" | "muted" | "default" | |
| layout | "center" | "split" | "center" | |
| dismiss | "show" | "hide" | "hide" | |
| badgeLabel | string | - | the tag before the sentence, e.g. New |
| badge | "none" | "show" | "none" | |
| position | "top" | "bottom" | "top" | bottom: stays at the bottom edge of the page while it scrolls |
| landmarkLabel | string | - | accessible name of the landmark of this component when the page shows it more than once (a variant); replaces the heading name of the root landmark, follows the name of a nested one |