Page Header
Page Header component
Install
npx ui8kit add page-headerPulls in: box, compose, kit-box, kit-text, text, title, utils
Preview
No static preview for this item: it needs content or a parent that this page cannot supply. The code is below.
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 page-header<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- The page heading: a title, a one-line summary and the action buttons on the right (below on phones). -->
<script lang="ts" module>
import type { Snippet } from "svelte";
export type PageHeaderProps = {
title: string;
summary?: string;
id?: string;
actions?: Snippet;
};
</script>
<script lang="ts">
import Box from "../compose/Box.svelte";
import Text from "../compose/Text.svelte";
import Title from "../compose/Title.svelte";
let { title, summary, id, actions }: PageHeaderProps = $props();
</script>
<Box
class="flex flex-col items-start gap-4 md:flex-row md:items-center md:justify-between"
data-slot="page-header"
>
<Box class="flex min-w-0 flex-col gap-2">
<Title as={1} size="xl" weight="bold" class="m-0" id={id}>
{title}
</Title>
{#if summary}
<Text class="m-0 text-xs font-medium text-muted-foreground">
{summary}
</Text>
{/if}
</Box>
{#if actions}
<Box class="flex flex-wrap items-center gap-2">
{@render actions?.()}
</Box>
{/if}
</Box>
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 page-header// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** The page heading: a title, a one-line summary and the action buttons on the right (below on phones). */
import { type ReactNode } from "react";
import { Box, Text, Title } from "../compose";
export type PageHeaderProps = {
title: string;
summary?: string;
id?: string;
actions?: ReactNode;
};
export function PageHeader({ title, summary, id, actions }: PageHeaderProps) {
return (
<Box
className="flex flex-col items-start gap-4 md:flex-row md:items-center md:justify-between"
data-slot="page-header"
>
<Box className="flex min-w-0 flex-col gap-2">
<Title as={1} size="xl" weight="bold" className="m-0" id={id}>
{title}
</Title>
{summary ? (
<Text className="m-0 text-xs font-medium text-muted-foreground">
{summary}
</Text>
) : null}
</Box>
{actions ? (
<Box className="flex flex-wrap items-center gap-2">
{actions}
</Box>
) : null}
</Box>
);
}
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 page-header<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- The page heading: a title, a one-line summary and the action buttons on the right (below on phones). -->
<script lang="ts">
export type PageHeaderProps = {
title: string;
summary?: string;
id?: string;
};
</script>
<script setup lang="ts">
import Box from "../compose/Box.vue";
import Text from "../compose/Text.vue";
import Title from "../compose/Title.vue";
const { title, summary, id } = defineProps<PageHeaderProps>();
defineSlots<{ actions?(): unknown }>();
</script>
<template>
<Box
class="flex flex-col items-start gap-4 md:flex-row md:items-center md:justify-between"
data-slot="page-header"
>
<Box class="flex min-w-0 flex-col gap-2">
<Title :as="1" size="xl" weight="bold" class="m-0" :id="id">
{{ title }}
</Title>
<Text v-if="summary" class="m-0 text-xs font-medium text-muted-foreground">
{{ summary }}
</Text>
</Box>
<Box v-if="$slots.actions" class="flex flex-wrap items-center gap-2">
<slot name="actions" />
</Box>
</Box>
</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 page-header// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** The page heading: a title, a one-line summary and the action buttons on the right (below on phones). */
import { type JSX } from "solid-js";
import { Box, Text, Title } from "../compose";
export type PageHeaderProps = {
title: string;
summary?: string;
id?: string;
actions?: JSX.Element;
};
export function PageHeader({ title, summary, id, actions }: PageHeaderProps) {
return (
<Box
class="flex flex-col items-start gap-4 md:flex-row md:items-center md:justify-between"
data-slot="page-header"
>
<Box class="flex min-w-0 flex-col gap-2">
<Title as={1} size="xl" weight="bold" class="m-0" id={id}>
{title}
</Title>
{summary ? (
<Text class="m-0 text-xs font-medium text-muted-foreground">
{summary}
</Text>
) : null}
</Box>
{actions ? (
<Box class="flex flex-wrap items-center gap-2">
{actions}
</Box>
) : null}
</Box>
);
}
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 page-header// 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/parts/page-header.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// PageHeaderProps are the props of PageHeader; the values are the JSON shapes of the TypeScript props.
type PageHeaderProps struct {
Title any `json:"title"`
Summary any `json:"summary"`
Id any `json:"id"`
Actions templ.Component `json:"-"`
}
// The page heading: a title, a one-line summary and the action buttons on the right (below on phones).
templ PageHeader(p PageHeaderProps) {
{{ vTitle := p.Title }}
{{ vSummary := p.Summary }}
{{ vId := p.Id }}
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex flex-col items-start gap-4 md:flex-row md:items-center md:justify-between", Attrs: uiutils.Attrs("data-slot", "page-header")}}) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex min-w-0 flex-col gap-2"}}) {
@compose.Title(compose.TitleProps{As: "1", Size: "xl", Weight: "bold", TextProps: text.TextProps{Class: "m-0", Attrs: uiutils.Attrs("id", vId)}}) {
{ uiutils.Text(vTitle) }
}
if uiutils.T(vSummary) {
@compose.Text(compose.TextProps{TextProps: text.TextProps{Class: "m-0 text-xs font-medium text-muted-foreground"}}) {
{ uiutils.Text(vSummary) }
}
}
}
if uiutils.T((p.Actions != nil)) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex flex-wrap items-center gap-2"}}) {
if p.Actions != nil {
@p.Actions
}
}
}
}
}
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 page-header{#- 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/parts/page-header.json
The page heading: a title, a one-line summary and the action buttons on the right (below on phones).
Props (p): title, summary, id, actions (slot). -#}
{%- set v_title = (p.title ?? null) -%}
{%- set v_summary = (p.summary ?? null) -%}
{%- set v_id = (p.id ?? null) -%}
{%- set c_5 -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(v_title) }}
{%- endset -%}
{{ include('compose/Title.html.twig', {'as': 1, 'size': 'xl', 'weight': 'bold', 'class': 'm-0', 'attrs': og_attrs(['id', v_id]), 'children': c_1}, with_context = false) }}
{%- if og_t(v_summary) %}
{%- set c_2 -%}
{{ og_text(v_summary) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'class': 'm-0 text-xs font-medium text-muted-foreground', 'children': c_2}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'flex min-w-0 flex-col gap-2', 'children': c_3}, with_context = false) }}
{%- if og_t(((p.actions ?? null) is not null)) %}
{%- set c_4 -%}
{{ og_slot((p.actions ?? null))|raw }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'flex flex-wrap items-center gap-2', 'children': c_4}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'flex flex-col items-start gap-4 md:flex-row md:items-center md:justify-between', 'attrs': og_attrs(['data-slot', 'page-header']), 'children': c_5}, 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 page-header{* 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/parts/page-header.json
The page heading: a title, a one-line summary and the action buttons on the right (below on phones).
Props (p): title, summary, id, actions (slot). *}
{var $v_title = ($p['title'] ?? null)}
{var $v_summary = ($p['summary'] ?? null)}
{var $v_id = ($p['id'] ?? null)}
{capture $c_5}
{capture $c_3}
{capture $c_1}
{=og_text($v_title)}
{/capture}
{=og_include('compose/Title.latte', ['as' => 1, 'size' => 'xl', 'weight' => 'bold', 'class' => 'm-0', 'attrs' => og_attrs(['id', $v_id]), 'children' => (string) $c_1])|noescape}
{if og_t($v_summary)}
{capture $c_2}
{=og_text($v_summary)}
{/capture}
{=og_include('compose/Text.latte', ['class' => 'm-0 text-xs font-medium text-muted-foreground', 'children' => (string) $c_2])|noescape}
{/if}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'flex min-w-0 flex-col gap-2', 'children' => (string) $c_3])|noescape}
{if og_t(((($p['actions'] ?? null) !== null)))}
{capture $c_4}
{=og_slot(($p['actions'] ?? null))|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'flex flex-wrap items-center gap-2', 'children' => (string) $c_4])|noescape}
{/if}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'flex flex-col items-start gap-4 md:flex-row md:items-center md:justify-between', 'attrs' => og_attrs(['data-slot', 'page-header']), 'children' => (string) $c_5])|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 page-header{#- 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/parts/page-header.json
The page heading: a title, a one-line summary and the action buttons on the right (below on phones).
Props (p): title, summary, id, actions (slot). -#}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_summary = og_def(p['summary'], none) -%}
{%- set v_id = og_def(p['id'], none) -%}
{%- set c_5 -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(v_title) }}
{%- endset -%}
{{ og_include('compose/title.html.j2', {'p': {'As': 1, 'Size': 'xl', 'Weight': 'bold', 'Class': 'm-0', 'Attrs': og_attrs(['id', v_id])}, 'children': c_1}) }}
{%- if og_t(v_summary) %}
{%- set c_2 -%}
{{ og_text(v_summary) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Class': 'm-0 text-xs font-medium text-muted-foreground'}, 'children': c_2}) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'flex min-w-0 flex-col gap-2'}, 'children': c_3}) }}
{%- if og_t((og_def(p['actions'], none) is not none)) %}
{%- set c_4 -%}
{{ og_slot(og_def(p['actions'], none))|safe }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'flex flex-wrap items-center gap-2'}, 'children': c_4}) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'flex flex-col items-start gap-4 md:flex-row md:items-center md:justify-between', 'Attrs': og_attrs(['data-slot', 'page-header'])}, 'children': c_5}) }}
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.
The page heading: a title, a one-line summary and the action buttons on the right (below on phones).
| Prop | Type | Default | Description |
|---|---|---|---|
| title (required) | string | - | |
| summary | string | - | |
| id | string | - | id of the heading, for aria-labelledby |