Skip to content
ui8kit

block / promo

Cookie Banner

A consent notice with accept and decline buttons.

Install

npx ui8kit add cookie-banner

Pulls in: block, box, button, compose, container, group, kit-box, kit-button, kit-text, lucide-icon, stack, text, title, utils

Preview

Cookies keep the site working and show us what to improve. You can change your choice at any time.

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-cdn
npx ui8kit add cookie-banner
blocks/cookie-banner.svelte
<!-- 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 consent notice: an icon, a heading, one paragraph and the buttons accept, decline and (optionally) settings.
  Axes: layout (bar, card), actions (two, three), tone (default, muted).
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type CookieBannerProps = {
    id: string;
    title: string;
    text: string;
    accept: string;
    decline: string;
    settings?: string;
    layout?: "bar" | "card";
    actions?: "two" | "three";
    tone?: "default" | "muted";
    landmarkLabel?: string;
  };
</script>

<script lang="ts">
  import Block from "../compose/Block.svelte";
  import Box from "../compose/Box.svelte";
  import Button from "../compose/Button.svelte";
  import Container from "../compose/Container.svelte";
  import Group from "../compose/Group.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";
  import Stack from "../compose/Stack.svelte";
  import Text from "../compose/Text.svelte";
  import Title from "../compose/Title.svelte";
  import { cn, tpl } from "../utils";

  let {
    id,
    title,
    text,
    accept,
    decline,
    settings,
    layout = "bar",
    actions = "two",
    tone = "default",
    landmarkLabel,
  }: CookieBannerProps = $props();
</script>

<Block
  tag="section"
  aria-labelledby={(landmarkLabel ? undefined : tpl("{0}-title", id))}
  data-layout={layout}
  aria-label={landmarkLabel}
  data-slot="cookie"
>
  <Container class={cn("mx-auto w-full max-w-6xl px-4", "py-4")} data-slot="container">
    <Box
      class={cn(
        "flex flex-col gap-4 rounded p-6 inset-ring inset-ring-border",
        (((tone as string) === "muted") ? "bg-muted" : "bg-card"),
        (
          (layout as string) === "bar" ? "md:flex-row md:items-center md:justify-between"
          : "mx-auto w-full max-w-md"
        )
      )}
    >
      <Group gap="4" align="start" class="min-w-0">
        <LucideIcon name="cookie" size={24} />
        <Stack gap="2">
          <Title as={2} size="base" weight="bold" id={tpl("{0}-title", id)}>
            {title}
          </Title>
          <Text size="sm" class="text-muted-foreground">
            {text}
          </Text>
        </Stack>
      </Group>
      <Group gap="2" class="shrink-0 flex-wrap">
        {#if (((actions as string) === "three") && settings)}
          <Button variant="ghost" size="sm" type="button">
            {settings}
          </Button>
        {/if}
        <Button variant="outline" size="sm" type="button">
          {decline}
        </Button>
        <Button variant="default" size="sm" type="button">
          {accept}
        </Button>
      </Group>
    </Box>
  </Container>
</Block>

Svelte registry item (JSON)

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-cdn
npx ui8kit add cookie-banner
blocks/cookie-banner.tsx
// 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 consent notice: an icon, a heading, one paragraph and the buttons accept, decline and (optionally) settings.
 * Axes: layout (bar, card), actions (two, three), tone (default, muted).
 */
import { type ReactNode } from "react";
import { Block, Box, Button, Container, Group, Stack, Text, Title } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { cn, tpl } from "../utils";

export type CookieBannerProps = {
  id: string;
  title: string;
  text: string;
  accept: string;
  decline: string;
  settings?: string;
  layout?: "bar" | "card";
  actions?: "two" | "three";
  tone?: "default" | "muted";
  landmarkLabel?: string;
};

export function CookieBanner({
  id,
  title,
  text,
  accept,
  decline,
  settings,
  layout = "bar",
  actions = "two",
  tone = "default",
  landmarkLabel,
}: CookieBannerProps) {
  return (
    <Block
      tag="section"
      aria-labelledby={(landmarkLabel ? undefined : tpl("{0}-title", id))}
      data-layout={layout}
      aria-label={landmarkLabel}
      data-slot="cookie"
    >
      <Container className={cn("mx-auto w-full max-w-6xl px-4", "py-4")} data-slot="container">
        <Box
          className={cn(
            "flex flex-col gap-4 rounded p-6 inset-ring inset-ring-border",
            (((tone as string) === "muted") ? "bg-muted" : "bg-card"),
            (
              (layout as string) === "bar" ? "md:flex-row md:items-center md:justify-between"
              : "mx-auto w-full max-w-md"
            )
          )}
        >
          <Group gap="4" align="start" className="min-w-0">
            <LucideIcon name="cookie" size={24} />
            <Stack gap="2">
              <Title as={2} size="base" weight="bold" id={tpl("{0}-title", id)}>
                {title}
              </Title>
              <Text size="sm" className="text-muted-foreground">
                {text}
              </Text>
            </Stack>
          </Group>
          <Group gap="2" className="shrink-0 flex-wrap">
            {(((actions as string) === "three") && settings) ? (
              <Button variant="ghost" size="sm" type="button">
                {settings}
              </Button>
            ) : null}
            <Button variant="outline" size="sm" type="button">
              {decline}
            </Button>
            <Button variant="default" size="sm" type="button">
              {accept}
            </Button>
          </Group>
        </Box>
      </Container>
    </Block>
  );
}

React registry item (JSON)

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-cdn
npx ui8kit add cookie-banner
blocks/cookie-banner.vue
<!-- 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 consent notice: an icon, a heading, one paragraph and the buttons accept, decline and (optionally) settings.
  Axes: layout (bar, card), actions (two, three), tone (default, muted).
-->
<script lang="ts">
export type CookieBannerProps = {
  id: string;
  title: string;
  text: string;
  accept: string;
  decline: string;
  settings?: string;
  layout?: "bar" | "card";
  actions?: "two" | "three";
  tone?: "default" | "muted";
  landmarkLabel?: string;
};
</script>

<script setup lang="ts">
import Block from "../compose/Block.vue";
import Box from "../compose/Box.vue";
import Button from "../compose/Button.vue";
import Container from "../compose/Container.vue";
import Group from "../compose/Group.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import Title from "../compose/Title.vue";
import { cn, tpl } from "../utils";

const {
  id,
  title,
  text,
  accept,
  decline,
  settings,
  layout = "bar",
  actions = "two",
  tone = "default",
  landmarkLabel,
} = defineProps<CookieBannerProps>();
</script>

<template>
  <Block
    tag="section"
    :aria-labelledby="(landmarkLabel ? undefined : tpl('{0}-title', id))"
    :data-layout="layout"
    :aria-label="landmarkLabel"
    data-slot="cookie"
  >
    <Container :class="cn('mx-auto w-full max-w-6xl px-4', 'py-4')" data-slot="container">
      <Box
        :class="cn(
          'flex flex-col gap-4 rounded p-6 inset-ring inset-ring-border',
          (((tone as string) === 'muted') ? 'bg-muted' : 'bg-card'),
          (
            (layout as string) === 'bar' ? 'md:flex-row md:items-center md:justify-between'
            : 'mx-auto w-full max-w-md'
          )
        )"
      >
        <Group gap="4" align="start" class="min-w-0">
          <LucideIcon name="cookie" :size="24" />
          <Stack gap="2">
            <Title :as="2" size="base" weight="bold" :id="tpl('{0}-title', id)">
              {{ title }}
            </Title>
            <Text size="sm" class="text-muted-foreground">
              {{ text }}
            </Text>
          </Stack>
        </Group>
        <Group gap="2" class="shrink-0 flex-wrap">
          <Button v-if="(((actions as string) === 'three') && settings)" variant="ghost" size="sm" type="button">
            {{ settings }}
          </Button>
          <Button variant="outline" size="sm" type="button">
            {{ decline }}
          </Button>
          <Button variant="default" size="sm" type="button">
            {{ accept }}
          </Button>
        </Group>
      </Box>
    </Container>
  </Block>
</template>

Vue registry item (JSON)

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-cdn
npx ui8kit add cookie-banner
blocks/cookie-banner.tsx
// 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 consent notice: an icon, a heading, one paragraph and the buttons accept, decline and (optionally) settings.
 * Axes: layout (bar, card), actions (two, three), tone (default, muted).
 */
import { type JSX } from "solid-js";
import { Block, Box, Button, Container, Group, Stack, Text, Title } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { cn, tpl } from "../utils";

export type CookieBannerProps = {
  id: string;
  title: string;
  text: string;
  accept: string;
  decline: string;
  settings?: string;
  layout?: "bar" | "card";
  actions?: "two" | "three";
  tone?: "default" | "muted";
  landmarkLabel?: string;
};

export function CookieBanner({
  id,
  title,
  text,
  accept,
  decline,
  settings,
  layout = "bar",
  actions = "two",
  tone = "default",
  landmarkLabel,
}: CookieBannerProps) {
  return (
    <Block
      tag="section"
      aria-labelledby={(landmarkLabel ? undefined : tpl("{0}-title", id))}
      data-layout={layout}
      aria-label={landmarkLabel}
      data-slot="cookie"
    >
      <Container class={cn("mx-auto w-full max-w-6xl px-4", "py-4")} data-slot="container">
        <Box
          class={cn(
            "flex flex-col gap-4 rounded p-6 inset-ring inset-ring-border",
            (((tone as string) === "muted") ? "bg-muted" : "bg-card"),
            (
              (layout as string) === "bar" ? "md:flex-row md:items-center md:justify-between"
              : "mx-auto w-full max-w-md"
            )
          )}
        >
          <Group gap="4" align="start" class="min-w-0">
            <LucideIcon name="cookie" size={24} />
            <Stack gap="2">
              <Title as={2} size="base" weight="bold" id={tpl("{0}-title", id)}>
                {title}
              </Title>
              <Text size="sm" class="text-muted-foreground">
                {text}
              </Text>
            </Stack>
          </Group>
          <Group gap="2" class="shrink-0 flex-wrap">
            {(((actions as string) === "three") && settings) ? (
              <Button variant="ghost" size="sm" type="button">
                {settings}
              </Button>
            ) : null}
            <Button variant="outline" size="sm" type="button">
              {decline}
            </Button>
            <Button variant="default" size="sm" type="button">
              {accept}
            </Button>
          </Group>
        </Box>
      </Container>
    </Block>
  );
}

Solid registry item (JSON)

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-cdn
npx ui8kit add cookie-banner
blocks/cookie-banner.templ
// 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/cookie-banner.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/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// CookieBannerProps are the props of CookieBanner; the values are the JSON shapes of the TypeScript props.
type CookieBannerProps struct {
	Id any `json:"id"`
	Title any `json:"title"`
	Text any `json:"text"`
	Accept any `json:"accept"`
	Decline any `json:"decline"`
	Settings any `json:"settings"`
	Layout any `json:"layout"`
	Actions any `json:"actions"`
	Tone any `json:"tone"`
	LandmarkLabel any `json:"landmarkLabel"`
}

// A consent notice: an icon, a heading, one paragraph and the buttons accept, decline and (optionally) settings. Axes: layout (bar, card), actions (two, three), tone (default, muted).
templ CookieBanner(p CookieBannerProps) {
	{{ vId := p.Id }}
	{{ vTitle := p.Title }}
	{{ vText := p.Text }}
	{{ vAccept := p.Accept }}
	{{ vDecline := p.Decline }}
	{{ vSettings := p.Settings }}
	{{ vLayout := uiutils.Def(p.Layout, "bar") }}
	{{ vActions := uiutils.Def(p.Actions, "two") }}
	{{ vTone := uiutils.Def(p.Tone, "default") }}
	{{ vLandmarkLabel := p.LandmarkLabel }}
	@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "section", Attrs: uiutils.Attrs("aria-labelledby", uiutils.Cond(uiutils.T(vLandmarkLabel), nil, uiutils.Tpl("{0}-title", vId)), "data-layout", vLayout, "aria-label", vLandmarkLabel, "data-slot", "cookie")}}) {
		@compose.Container(compose.ContainerProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("mx-auto w-full max-w-6xl px-4", "py-4")), Attrs: uiutils.Attrs("data-slot", "container")}}) {
			@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("flex flex-col gap-4 rounded p-6 inset-ring inset-ring-border", uiutils.Cond(uiutils.T(uiutils.Eq(vTone, "muted")), "bg-muted", "bg-card"), uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "bar")), "md:flex-row md:items-center md:justify-between", "mx-auto w-full max-w-md")))}}) {
				@compose.Group(compose.GroupProps{Gap: "4", Align: "start", BoxProps: box.BoxProps{Class: "min-w-0"}}) {
					@icons.LucideIcon(icons.LucideIconProps{Name: "cookie", Size: 24})
					@compose.Stack(compose.StackProps{Gap: "2", BoxProps: box.BoxProps{}}) {
						@compose.Title(compose.TitleProps{As: "2", Size: "base", Weight: "bold", TextProps: text.TextProps{Attrs: uiutils.Attrs("id", uiutils.Tpl("{0}-title", vId))}}) {
							{ uiutils.Text(vTitle) }
						}
						@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
							{ uiutils.Text(vText) }
						}
					}
				}
				@compose.Group(compose.GroupProps{Gap: "2", BoxProps: box.BoxProps{Class: "shrink-0 flex-wrap"}}) {
					if uiutils.T(uiutils.And(uiutils.Eq(vActions, "three"), vSettings)) {
						@compose.Button(compose.ButtonProps{Variant: "ghost", Size: "sm", ButtonProps: button.ButtonProps{Type: "button"}}) {
							{ uiutils.Text(vSettings) }
						}
					}
					@compose.Button(compose.ButtonProps{Variant: "outline", Size: "sm", ButtonProps: button.ButtonProps{Type: "button"}}) {
						{ uiutils.Text(vDecline) }
					}
					@compose.Button(compose.ButtonProps{Variant: "default", Size: "sm", ButtonProps: button.ButtonProps{Type: "button"}}) {
						{ uiutils.Text(vAccept) }
					}
				}
			}
		}
	}
}

templ registry item (JSON)

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-cdn
npx ui8kit add cookie-banner
blocks/cookie-banner.html.twig
{#- 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/cookie-banner.json
    A consent notice: an icon, a heading, one paragraph and the buttons accept, decline and (optionally) settings. Axes: layout (bar, card), actions (two, three), tone (default, muted).
    Props (p): id, title, text, accept, decline, settings, layout, actions, tone, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_text = (p.text ?? null) -%}
{%- set v_accept = (p.accept ?? null) -%}
{%- set v_decline = (p.decline ?? null) -%}
{%- set v_settings = (p.settings ?? null) -%}
{%- set v_layout = (p.layout ?? 'bar') -%}
{%- set v_actions = (p.actions ?? 'two') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_11 -%}
  {%- set c_10 -%}
    {%- set c_9 -%}
      {%- set c_4 -%}
        {{ include('icons/LucideIcon.html.twig', {'name': 'cookie', 'size': 24}, with_context = false) }}
        {%- set c_3 -%}
          {%- set c_1 -%}
            {{ og_text(v_title) }}
          {%- endset -%}
          {{ include('compose/Title.html.twig', {'as': 2, 'size': 'base', 'weight': 'bold', 'attrs': og_attrs(['id', og_tpl('{0}-title', [v_id])]), 'children': c_1}, with_context = false) }}
          {%- set c_2 -%}
            {{ og_text(v_text) }}
          {%- endset -%}
          {{ include('compose/Text.html.twig', {'size': 'sm', 'class': 'text-muted-foreground', 'children': c_2}, with_context = false) }}
        {%- endset -%}
        {{ include('compose/Stack.html.twig', {'gap': '2', 'children': c_3}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Group.html.twig', {'gap': '4', 'align': 'start', 'class': 'min-w-0', 'children': c_4}, with_context = false) }}
      {%- set c_8 -%}
        {%- if og_t(og_and([og_eq(v_actions, 'three'), v_settings])) %}
          {%- set c_5 -%}
            {{ og_text(v_settings) }}
          {%- endset -%}
          {{ include('compose/Button.html.twig', {'variant': 'ghost', 'size': 'sm', 'type': 'button', 'children': c_5}, with_context = false) }}
        {%- endif %}
        {%- set c_6 -%}
          {{ og_text(v_decline) }}
        {%- endset -%}
        {{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'sm', 'type': 'button', 'children': c_6}, with_context = false) }}
        {%- set c_7 -%}
          {{ og_text(v_accept) }}
        {%- endset -%}
        {{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'sm', 'type': 'button', 'children': c_7}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Group.html.twig', {'gap': '2', 'class': 'shrink-0 flex-wrap', 'children': c_8}, with_context = false) }}
    {%- endset -%}
    {{ include('compose/Box.html.twig', {'class': og_s(og_cnv(['flex flex-col gap-4 rounded p-6 inset-ring inset-ring-border', (og_t(og_eq(v_tone, 'muted')) ? 'bg-muted' : 'bg-card'), (og_t(og_eq(v_layout, 'bar')) ? 'md:flex-row md:items-center md:justify-between' : 'mx-auto w-full max-w-md')])), 'children': c_9}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Container.html.twig', {'class': og_s(og_cnv(['mx-auto w-full max-w-6xl px-4', 'py-4'])), 'attrs': og_attrs(['data-slot', 'container']), 'children': c_10}, with_context = false) }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'section', 'attrs': og_attrs(['aria-labelledby', (og_t(v_landmarkLabel) ? null : og_tpl('{0}-title', [v_id])), 'data-layout', v_layout, 'aria-label', v_landmarkLabel, 'data-slot', 'cookie']), 'children': c_11}, with_context = false) }}

Twig registry item (JSON)

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-cdn
npx ui8kit add cookie-banner
blocks/cookie-banner.latte
{* 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/cookie-banner.json
    A consent notice: an icon, a heading, one paragraph and the buttons accept, decline and (optionally) settings. Axes: layout (bar, card), actions (two, three), tone (default, muted).
    Props (p): id, title, text, accept, decline, settings, layout, actions, tone, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_text = ($p['text'] ?? null)}
{var $v_accept = ($p['accept'] ?? null)}
{var $v_decline = ($p['decline'] ?? null)}
{var $v_settings = ($p['settings'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'bar')}
{var $v_actions = ($p['actions'] ?? 'two')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_11}
  {capture $c_10}
    {capture $c_9}
      {capture $c_4}
        {=og_include('icons/LucideIcon.latte', ['name' => 'cookie', 'size' => 24])|noescape}
        {capture $c_3}
          {capture $c_1}
            {=og_text($v_title)}
          {/capture}
          {=og_include('compose/Title.latte', ['as' => 2, 'size' => 'base', 'weight' => 'bold', 'attrs' => og_attrs(['id', og_tpl('{0}-title', [$v_id])]), 'children' => (string) $c_1])|noescape}
          {capture $c_2}
            {=og_text($v_text)}
          {/capture}
          {=og_include('compose/Text.latte', ['size' => 'sm', 'class' => 'text-muted-foreground', 'children' => (string) $c_2])|noescape}
        {/capture}
        {=og_include('compose/Stack.latte', ['gap' => '2', 'children' => (string) $c_3])|noescape}
      {/capture}
      {=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'start', 'class' => 'min-w-0', 'children' => (string) $c_4])|noescape}
      {capture $c_8}
        {if og_t(og_and([og_eq($v_actions, 'three'), $v_settings]))}
          {capture $c_5}
            {=og_text($v_settings)}
          {/capture}
          {=og_include('compose/Button.latte', ['variant' => 'ghost', 'size' => 'sm', 'type' => 'button', 'children' => (string) $c_5])|noescape}
        {/if}
        {capture $c_6}
          {=og_text($v_decline)}
        {/capture}
        {=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'sm', 'type' => 'button', 'children' => (string) $c_6])|noescape}
        {capture $c_7}
          {=og_text($v_accept)}
        {/capture}
        {=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'sm', 'type' => 'button', 'children' => (string) $c_7])|noescape}
      {/capture}
      {=og_include('compose/Group.latte', ['gap' => '2', 'class' => 'shrink-0 flex-wrap', 'children' => (string) $c_8])|noescape}
    {/capture}
    {=og_include('compose/Box.latte', ['class' => og_s(og_cnv(['flex flex-col gap-4 rounded p-6 inset-ring inset-ring-border', (og_t(og_eq($v_tone, 'muted')) ? 'bg-muted' : 'bg-card'), (og_t(og_eq($v_layout, 'bar')) ? 'md:flex-row md:items-center md:justify-between' : 'mx-auto w-full max-w-md')])), 'children' => (string) $c_9])|noescape}
  {/capture}
  {=og_include('compose/Container.latte', ['class' => og_s(og_cnv(['mx-auto w-full max-w-6xl px-4', 'py-4'])), 'attrs' => og_attrs(['data-slot', 'container']), 'children' => (string) $c_10])|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'section', 'attrs' => og_attrs(['aria-labelledby', (og_t($v_landmarkLabel) ? null : og_tpl('{0}-title', [$v_id])), 'data-layout', $v_layout, 'aria-label', $v_landmarkLabel, 'data-slot', 'cookie']), 'children' => (string) $c_11])|noescape}

Latte registry item (JSON)

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-cdn
npx ui8kit add cookie-banner
blocks/cookie-banner.html.j2
{#- 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/cookie-banner.json
    A consent notice: an icon, a heading, one paragraph and the buttons accept, decline and (optionally) settings. Axes: layout (bar, card), actions (two, three), tone (default, muted).
    Props (p): id, title, text, accept, decline, settings, layout, actions, tone, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_text = og_def(p['text'], none) -%}
{%- set v_accept = og_def(p['accept'], none) -%}
{%- set v_decline = og_def(p['decline'], none) -%}
{%- set v_settings = og_def(p['settings'], none) -%}
{%- set v_layout = og_def(p['layout'], 'bar') -%}
{%- set v_actions = og_def(p['actions'], 'two') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_11 -%}
  {%- set c_10 -%}
    {%- set c_9 -%}
      {%- set c_4 -%}
        {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'cookie', 'Size': 24}}) }}
        {%- set c_3 -%}
          {%- set c_1 -%}
            {{ og_text(v_title) }}
          {%- endset -%}
          {{ og_include('compose/title.html.j2', {'p': {'As': 2, 'Size': 'base', 'Weight': 'bold', 'Attrs': og_attrs(['id', og_tpl('{0}-title', [v_id])])}, 'children': c_1}) }}
          {%- set c_2 -%}
            {{ og_text(v_text) }}
          {%- endset -%}
          {{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Class': 'text-muted-foreground'}, 'children': c_2}) }}
        {%- endset -%}
        {{ og_include('compose/stack.html.j2', {'p': {'Gap': '2'}, 'children': c_3}) }}
      {%- endset -%}
      {{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'start', 'Class': 'min-w-0'}, 'children': c_4}) }}
      {%- set c_8 -%}
        {%- if og_t(og_and([og_eq(v_actions, 'three'), v_settings])) %}
          {%- set c_5 -%}
            {{ og_text(v_settings) }}
          {%- endset -%}
          {{ og_include('compose/button.html.j2', {'p': {'Variant': 'ghost', 'Size': 'sm', 'Type': 'button'}, 'children': c_5}) }}
        {%- endif %}
        {%- set c_6 -%}
          {{ og_text(v_decline) }}
        {%- endset -%}
        {{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'sm', 'Type': 'button'}, 'children': c_6}) }}
        {%- set c_7 -%}
          {{ og_text(v_accept) }}
        {%- endset -%}
        {{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'sm', 'Type': 'button'}, 'children': c_7}) }}
      {%- endset -%}
      {{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Class': 'shrink-0 flex-wrap'}, 'children': c_8}) }}
    {%- endset -%}
    {{ og_include('compose/box.html.j2', {'p': {'Class': og_s(og_cnv(['flex flex-col gap-4 rounded p-6 inset-ring inset-ring-border', ('bg-muted' if og_t(og_eq(v_tone, 'muted')) else 'bg-card'), ('md:flex-row md:items-center md:justify-between' if og_t(og_eq(v_layout, 'bar')) else 'mx-auto w-full max-w-md')]))}, 'children': c_9}) }}
  {%- endset -%}
  {{ og_include('compose/container.html.j2', {'p': {'Class': og_s(og_cnv(['mx-auto w-full max-w-6xl px-4', 'py-4'])), 'Attrs': og_attrs(['data-slot', 'container'])}, 'children': c_10}) }}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'section', 'Attrs': og_attrs(['aria-labelledby', (none if og_t(v_landmarkLabel) else og_tpl('{0}-title', [v_id])), 'data-layout', v_layout, 'aria-label', v_landmarkLabel, 'data-slot', 'cookie'])}, 'children': c_11}) }}

Jinja2 registry item (JSON)

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 consent notice: an icon, a heading, one paragraph and the buttons accept, decline and (optionally) settings. Axes: layout (bar, card), actions (two, three), tone (default, muted).

Props of CookieBanner
PropTypeDefault Description
id (required)string-
title (required)string-
text (required)string-
accept (required)string-
decline (required)string-
settings string-text of the third button, shown when `actions` is three
layout "bar" | "card""bar"
actions "two" | "three""two"
tone "default" | "muted""default"
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