Skip to content
ui8kit

component / components

Panel

Panel component

Install

npx ui8kit add panel

Pulls in: box, compose, kit-box, kit-text, text, title, utils

Preview

Orders this week

Orders per day over the last seven days.

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 panel
components/panel.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 titled card (surface bg-card, hairline ring): the content panel of a page. An optional title, description
  and header actions. Pass `id` to name the panel by its title. Not a landmark: a labelled group inside the
  Block of its block (rule 01).
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type PanelProps = {
    title?: string;
    description?: string;
    id?: string;
    class?: string;
    children?: Snippet;
    actions?: Snippet;
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import Text from "../compose/Text.svelte";
  import Title from "../compose/Title.svelte";
  import { cn, tpl } from "../utils";

  let { title, description, id, class: className, children, actions }: PanelProps = $props();
</script>

<Box
  class={cn(
    "flex min-w-0 flex-col gap-4 rounded bg-card p-6 inset-ring inset-ring-border",
    className
  )}
  role="group"
  aria-labelledby={((title && id) ? tpl("{0}-t", id) : undefined)}
>
  {#if (title || actions)}
    <Box class="flex items-start justify-between gap-4">
      <Box class="flex min-w-0 flex-col gap-2">
        {#if title}
          <Title as={2} size="base" class="m-0 text-foreground" id={(id ? tpl("{0}-t", id) : undefined)}>
            {title}
          </Title>
        {/if}
        {#if description}
          <Text class="m-0 text-xs font-medium text-muted-foreground">
            {description}
          </Text>
        {/if}
      </Box>
      {@render actions?.()}
    </Box>
  {/if}
  {@render children?.()}
</Box>

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 panel
components/panel.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 titled card (surface bg-card, hairline ring): the content panel of a page. An optional title, description
 * and header actions. Pass `id` to name the panel by its title. Not a landmark: a labelled group inside the
 * Block of its block (rule 01).
 */
import { type ReactNode } from "react";
import { Box, Text, Title } from "../compose";
import { cn, tpl } from "../utils";

export type PanelProps = {
  title?: string;
  description?: string;
  id?: string;
  className?: string;
  children?: ReactNode;
  actions?: ReactNode;
};

export function Panel({ title, description, id, className, children, actions }: PanelProps) {
  return (
    <Box
      className={cn(
        "flex min-w-0 flex-col gap-4 rounded bg-card p-6 inset-ring inset-ring-border",
        className
      )}
      role="group"
      aria-labelledby={((title && id) ? tpl("{0}-t", id) : undefined)}
    >
      {(title || actions) ? (
        <Box className="flex items-start justify-between gap-4">
          <Box className="flex min-w-0 flex-col gap-2">
            {title ? (
              <Title as={2} size="base" className="m-0 text-foreground" id={(id ? tpl("{0}-t", id) : undefined)}>
                {title}
              </Title>
            ) : null}
            {description ? (
              <Text className="m-0 text-xs font-medium text-muted-foreground">
                {description}
              </Text>
            ) : null}
          </Box>
          {actions}
        </Box>
      ) : null}
      {children}
    </Box>
  );
}

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 panel
components/panel.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 titled card (surface bg-card, hairline ring): the content panel of a page. An optional title, description
  and header actions. Pass `id` to name the panel by its title. Not a landmark: a labelled group inside the
  Block of its block (rule 01).
-->
<script lang="ts">
export type PanelProps = {
  title?: string;
  description?: string;
  id?: string;
  class?: string;
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import Text from "../compose/Text.vue";
import Title from "../compose/Title.vue";
import { cn, tpl } from "../utils";

const { title, description, id, class: className } = defineProps<PanelProps>();
defineSlots<{ default?(): unknown, actions?(): unknown }>();
</script>

<template>
  <Box
    :class="cn(
      'flex min-w-0 flex-col gap-4 rounded bg-card p-6 inset-ring inset-ring-border',
      className
    )"
    role="group"
    :aria-labelledby="((title && id) ? tpl('{0}-t', id) : undefined)"
  >
    <Box v-if="(title || $slots.actions)" class="flex items-start justify-between gap-4">
      <Box class="flex min-w-0 flex-col gap-2">
        <Title v-if="title" :as="2" size="base" class="m-0 text-foreground" :id="(id ? tpl('{0}-t', id) : undefined)">
          {{ title }}
        </Title>
        <Text v-if="description" class="m-0 text-xs font-medium text-muted-foreground">
          {{ description }}
        </Text>
      </Box>
      <slot name="actions" />
    </Box>
    <slot />
  </Box>
</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 panel
components/panel.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 titled card (surface bg-card, hairline ring): the content panel of a page. An optional title, description
 * and header actions. Pass `id` to name the panel by its title. Not a landmark: a labelled group inside the
 * Block of its block (rule 01).
 */
import { type JSX } from "solid-js";
import { Box, Text, Title } from "../compose";
import { cn, tpl } from "../utils";

export type PanelProps = {
  title?: string;
  description?: string;
  id?: string;
  class?: string;
  children?: JSX.Element;
  actions?: JSX.Element;
};

export function Panel({ title, description, id, class: className, children, actions }: PanelProps) {
  return (
    <Box
      class={cn(
        "flex min-w-0 flex-col gap-4 rounded bg-card p-6 inset-ring inset-ring-border",
        className
      )}
      role="group"
      aria-labelledby={((title && id) ? tpl("{0}-t", id) : undefined)}
    >
      {(title || actions) ? (
        <Box class="flex items-start justify-between gap-4">
          <Box class="flex min-w-0 flex-col gap-2">
            {title ? (
              <Title as={2} size="base" class="m-0 text-foreground" id={(id ? tpl("{0}-t", id) : undefined)}>
                {title}
              </Title>
            ) : null}
            {description ? (
              <Text class="m-0 text-xs font-medium text-muted-foreground">
                {description}
              </Text>
            ) : null}
          </Box>
          {actions}
        </Box>
      ) : null}
      {children}
    </Box>
  );
}

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 panel
blocks/panel.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/parts/panel.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"
)

// PanelProps are the props of Panel; the values are the JSON shapes of the TypeScript props.
type PanelProps struct {
	Title any `json:"title"`
	Description any `json:"description"`
	Id any `json:"id"`
	Class string `json:"className"`
	Actions templ.Component `json:"-"`
}

// A titled card (surface bg-card, hairline ring): the content panel of a page. An optional title, description and header actions. Pass `id` to name the panel by its title. Not a landmark: a labelled group inside the Block of its block (rule 01).
templ Panel(p PanelProps) {
	{{ vTitle := p.Title }}
	{{ vDescription := p.Description }}
	{{ vId := p.Id }}
	@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("flex min-w-0 flex-col gap-4 rounded bg-card p-6 inset-ring inset-ring-border", p.Class)), Attrs: uiutils.Attrs("role", "group", "aria-labelledby", uiutils.Cond(uiutils.T(uiutils.And(vTitle, vId)), uiutils.Tpl("{0}-t", vId), nil))}}) {
		if uiutils.T(uiutils.Or(vTitle, (p.Actions != nil))) {
			@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex items-start justify-between gap-4"}}) {
				@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex min-w-0 flex-col gap-2"}}) {
					if uiutils.T(vTitle) {
						@compose.Title(compose.TitleProps{As: "2", Size: "base", TextProps: text.TextProps{Class: "m-0 text-foreground", Attrs: uiutils.Attrs("id", uiutils.Cond(uiutils.T(vId), uiutils.Tpl("{0}-t", vId), nil))}}) {
							{ uiutils.Text(vTitle) }
						}
					}
					if uiutils.T(vDescription) {
						@compose.Text(compose.TextProps{TextProps: text.TextProps{Class: "m-0 text-xs font-medium text-muted-foreground"}}) {
							{ uiutils.Text(vDescription) }
						}
					}
				}
				if p.Actions != nil {
					@p.Actions
				}
			}
		}
		{ children... }
	}
}

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 panel
blocks/panel.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/parts/panel.json
    A titled card (surface bg-card, hairline ring): the content panel of a page. An optional title, description and header actions. Pass `id` to name the panel by its title. Not a landmark: a labelled group inside the Block of its block (rule 01).
    Props (p): title, description, id, className, actions (slot); children: markup. -#}
{%- set v_title = (p.title ?? null) -%}
{%- set v_description = (p.description ?? null) -%}
{%- set v_id = (p.id ?? null) -%}
{%- set c_5 -%}
  {%- if og_t(og_or([v_title, ((p.actions ?? null) is not null)])) %}
    {%- set c_4 -%}
      {%- set c_3 -%}
        {%- if og_t(v_title) %}
          {%- set c_1 -%}
            {{ og_text(v_title) }}
          {%- endset -%}
          {{ include('compose/Title.html.twig', {'as': 2, 'size': 'base', 'class': 'm-0 text-foreground', 'attrs': og_attrs(['id', (og_t(v_id) ? og_tpl('{0}-t', [v_id]) : null)]), 'children': c_1}, with_context = false) }}
        {%- endif %}
        {%- if og_t(v_description) %}
          {%- set c_2 -%}
            {{ og_text(v_description) }}
          {%- 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) }}
      {{ og_slot((p.actions ?? null))|raw }}
    {%- endset -%}
    {{ include('compose/Box.html.twig', {'class': 'flex items-start justify-between gap-4', 'children': c_4}, with_context = false) }}
  {%- endif %}
  {{ og_slot((children ?? null))|raw }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': og_s(og_cnv(['flex min-w-0 flex-col gap-4 rounded bg-card p-6 inset-ring inset-ring-border', (p.className ?? '')])), 'attrs': og_attrs(['role', 'group', 'aria-labelledby', (og_t(og_and([v_title, v_id])) ? og_tpl('{0}-t', [v_id]) : null)]), 'children': c_5}, 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 panel
blocks/panel.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/parts/panel.json
    A titled card (surface bg-card, hairline ring): the content panel of a page. An optional title, description and header actions. Pass `id` to name the panel by its title. Not a landmark: a labelled group inside the Block of its block (rule 01).
    Props (p): title, description, id, className, actions (slot); children: markup. *}
{var $v_title = ($p['title'] ?? null)}
{var $v_description = ($p['description'] ?? null)}
{var $v_id = ($p['id'] ?? null)}
{capture $c_5}
  {if og_t(og_or([$v_title, ((($p['actions'] ?? null) !== null))]))}
    {capture $c_4}
      {capture $c_3}
        {if og_t($v_title)}
          {capture $c_1}
            {=og_text($v_title)}
          {/capture}
          {=og_include('compose/Title.latte', ['as' => 2, 'size' => 'base', 'class' => 'm-0 text-foreground', 'attrs' => og_attrs(['id', (og_t($v_id) ? og_tpl('{0}-t', [$v_id]) : null)]), 'children' => (string) $c_1])|noescape}
        {/if}
        {if og_t($v_description)}
          {capture $c_2}
            {=og_text($v_description)}
          {/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}
      {=og_slot(($p['actions'] ?? null))|noescape}
    {/capture}
    {=og_include('compose/Box.latte', ['class' => 'flex items-start justify-between gap-4', 'children' => (string) $c_4])|noescape}
  {/if}
  {=og_slot(($children ?? null))|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => og_s(og_cnv(['flex min-w-0 flex-col gap-4 rounded bg-card p-6 inset-ring inset-ring-border', ($p['className'] ?? '')])), 'attrs' => og_attrs(['role', 'group', 'aria-labelledby', (og_t(og_and([$v_title, $v_id])) ? og_tpl('{0}-t', [$v_id]) : null)]), 'children' => (string) $c_5])|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 panel
blocks/panel.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/parts/panel.json
    A titled card (surface bg-card, hairline ring): the content panel of a page. An optional title, description and header actions. Pass `id` to name the panel by its title. Not a landmark: a labelled group inside the Block of its block (rule 01).
    Props (p): title, description, id, className, actions (slot); children: markup. -#}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_description = og_def(p['description'], none) -%}
{%- set v_id = og_def(p['id'], none) -%}
{%- set c_5 -%}
  {%- if og_t(og_or([v_title, (og_def(p['actions'], none) is not none)])) %}
    {%- set c_4 -%}
      {%- set c_3 -%}
        {%- if og_t(v_title) %}
          {%- set c_1 -%}
            {{ og_text(v_title) }}
          {%- endset -%}
          {{ og_include('compose/title.html.j2', {'p': {'As': 2, 'Size': 'base', 'Class': 'm-0 text-foreground', 'Attrs': og_attrs(['id', (og_tpl('{0}-t', [v_id]) if og_t(v_id) else none)])}, 'children': c_1}) }}
        {%- endif %}
        {%- if og_t(v_description) %}
          {%- set c_2 -%}
            {{ og_text(v_description) }}
          {%- 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}) }}
      {{ og_slot(og_def(p['actions'], none))|safe }}
    {%- endset -%}
    {{ og_include('compose/box.html.j2', {'p': {'Class': 'flex items-start justify-between gap-4'}, 'children': c_4}) }}
  {%- endif %}
  {{ og_slot(og_def(children, none))|safe }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': og_s(og_cnv(['flex min-w-0 flex-col gap-4 rounded bg-card p-6 inset-ring inset-ring-border', og_def(p['className'], '')])), 'Attrs': og_attrs(['role', 'group', 'aria-labelledby', (og_tpl('{0}-t', [v_id]) if og_t(og_and([v_title, v_id])) else none)])}, 'children': c_5}) }}

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 titled card (surface bg-card, hairline ring): the content panel of a page. An optional title, description and header actions. Pass `id` to name the panel by its title. Not a landmark: a labelled group inside the Block of its block (rule 01).

Props of Panel
PropTypeDefault Description
title string-
description string-
id string-base id: the title gets `{id}-t` and the panel points at it with aria-labelledby

Used in