Skip to content
ui8kit

primitive / primitives

Summary

Summary primitive

Install

npx ui8kit add summary

Pulls in: kit-disclosure, kit-text, recipes, utils

Preview

size: sm
size: default
size: lg
variant: card
variant: default
variant: ghost
variant: item

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 summary
compose/Summary.svelte
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Summary: Summary + recipe summary. -->
<script lang="ts">
  import type { ComponentProps, Snippet } from "svelte";
  import Prim from "../kit/ui/disclosure/Summary.svelte";
  import Text from "../kit/ui/text/Text.svelte";
  import { cn } from "../kit/utils";
  import { rc } from "./recipes";

  let { "size": v_size, "variant": v_variant, class: className, children, ...rest }: ComponentProps<typeof Prim> & { "size"?: string | number; "variant"?: string | number; class?: string; children?: Snippet } = $props();
  const cls = $derived(cn(rc("summary", { "size": v_size, "variant": v_variant }), className));
</script>

<Prim class={cls} {...rest}>{@render children?.()}<Text tag="span" class="size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180" aria-hidden="true" data-slot="summary-indicator" /></Prim>

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 summary
compose/summary.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import type { ComponentProps } from "react";
import { Summary as Prim } from "../kit/ui/disclosure/disclosure";
import { Text } from "../kit/ui/text/text";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

export type SummaryProps = Omit<ComponentProps<typeof Prim>, "tag" | "size" | "variant"> & { "size"?: string | number; "variant"?: string | number; className?: string };

/** Summary: Summary + recipe summary. */
export function Summary({ "size": v_size, "variant": v_variant, className, children, ...rest }: SummaryProps) {
  return <Prim className={cn(rc("summary", { "size": v_size, "variant": v_variant }), className)} {...rest}>{children}<Text tag="span" className="size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180" aria-hidden="true" data-slot="summary-indicator" /></Prim>;
}

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 summary
compose/Summary.vue
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Summary: Summary + recipe summary. -->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import Prim from "../kit/ui/disclosure/Summary.vue";
import Text from "../kit/ui/text/Text.vue";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

defineOptions({ name: "Summary", inheritAttrs: false });
const props = defineProps<{ "size"?: string | number; "variant"?: string | number }>();
const attrs = useAttrs();
const rest = computed(() => {
  const { class: _class, ...r } = attrs;
  return r;
});
const cls = computed(() => cn(rc("summary", { "size": props["size"], "variant": props["variant"] }), attrs.class as string | undefined));
const tagValue = computed(() => "");
</script>

<template>
  <Prim :class="cls" v-bind="rest"><slot /><Text tag="span" class="size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180" aria-hidden="true" data-slot="summary-indicator" /></Prim>
</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 summary
compose/summary.solid.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import { splitProps, type ComponentProps } from "solid-js";
import { Summary as Prim } from "../kit/ui/disclosure/disclosure.solid";
import { Text } from "../kit/ui/text/text.solid";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

export type SummaryProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className" | "size" | "variant"> & { "size"?: string | number; "variant"?: string | number; class?: string; className?: string };

/** Summary: Summary + recipe summary. */
export function Summary(props: SummaryProps) {
  const [local, rest] = splitProps(props, ["size", "variant", "class", "className", "children"]);
  return <Prim class={cn(rc("summary", { "size": local["size"], "variant": local["variant"] }), local.class ?? local.className)} {...rest}>{local.children}<Text tag="span" class="size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180" aria-hidden="true" data-slot="summary-indicator" /></Prim>;
}

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 summary
compose/summary.templ
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.

package compose

import (
	"github.com/ui8kit/codegen/generated/templ/ui/disclosure"
	"github.com/ui8kit/codegen/generated/templ/ui/text"
)

// SummaryProps: Summary: Summary + recipe summary.
type SummaryProps struct {
	Size string
	Variant string
	disclosure.SummaryProps
}

func summaryInner(p SummaryProps) disclosure.SummaryProps {
	in := p.SummaryProps
	in.Class = Join(Rc("summary", map[string]string{"size": p.Size, "variant": p.Variant}), p.SummaryProps.Class)
	return in
}

// Summary renders Summary with the composition classes.
templ Summary(p SummaryProps) {
	@disclosure.Summary(summaryInner(p)) {
		{ children... }@text.Text(text.TextProps{Tag: "span", Class: "size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180", Attrs: templ.Attributes{"aria-hidden": "true", "data-slot": "summary-indicator"}})
	}
}

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 summary
compose/Summary.html.twig
{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# Summary: Summary + recipe summary. Params: size, variant, class, attrs + the params of Summary. #}
{% include 'ui/disclosure/Summary.html.twig' with compose_props('Summary', _context) only %}

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 summary
compose/Summary.latte
{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* Summary: Summary + recipe summary. *}
{parameters
  string $class = '',
  array $attrs = [],
  string $children = '',
  $size = null,
  $variant = null,
}
{include '../ui/disclosure/Summary.latte', ...\CodegenX\Compose\Latte\Compose::props('Summary', ['class' => $class, 'attrs' => $attrs, 'children' => $children, 'size' => $size, 'variant' => $variant])}

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 summary
compose/summary.html.j2
{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
    Summary: Summary + recipe summary. Props (p): Size, Variant, Class, Attrs + the props of Summary. -#}
{%- with p = compose_props('Summary', p), children = compose_trail('Summary', children) %}{% include 'ui/disclosure/summary.html.j2' %}{% endwith %}

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.

Summary renders the native summary (the disclosure trigger).

No props.