Disclosure
Disclosure primitive
Install
npx ui8kit add disclosurePulls in: kit-disclosure, recipes, 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 disclosurecompose/Disclosure.svelte
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Disclosure: Disclosure + recipe disclosure. -->
<script lang="ts">
import type { ComponentProps, Snippet } from "svelte";
import Prim from "../kit/ui/disclosure/Disclosure.svelte";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
let { "variant": v_variant, class: className, children, ...rest }: ComponentProps<typeof Prim> & { "variant"?: string | number; class?: string; children?: Snippet } = $props();
const cls = $derived(cn(rc("disclosure", { "variant": v_variant }), className));
</script>
<Prim class={cls} {...rest}>{@render children?.()}</Prim>
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 disclosurecompose/disclosure.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import type { ComponentProps } from "react";
import { Disclosure as Prim } from "../kit/ui/disclosure/disclosure";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type DisclosureProps = Omit<ComponentProps<typeof Prim>, "tag" | "variant"> & { "variant"?: string | number; className?: string };
/** Disclosure: Disclosure + recipe disclosure. */
export function Disclosure({ "variant": v_variant, className, ...rest }: DisclosureProps) {
return <Prim className={cn(rc("disclosure", { "variant": v_variant }), className)} {...rest} />;
}
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 disclosurecompose/Disclosure.vue
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Disclosure: Disclosure + recipe disclosure. -->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import Prim from "../kit/ui/disclosure/Disclosure.vue";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
defineOptions({ name: "Disclosure", inheritAttrs: false });
const props = defineProps<{ "variant"?: string | number }>();
const attrs = useAttrs();
const rest = computed(() => {
const { class: _class, ...r } = attrs;
return r;
});
const cls = computed(() => cn(rc("disclosure", { "variant": props["variant"] }), attrs.class as string | undefined));
const tagValue = computed(() => "");
</script>
<template>
<Prim :class="cls" v-bind="rest"><slot /></Prim>
</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 disclosurecompose/disclosure.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 { Disclosure as Prim } from "../kit/ui/disclosure/disclosure.solid";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type DisclosureProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className" | "variant"> & { "variant"?: string | number; class?: string; className?: string };
/** Disclosure: Disclosure + recipe disclosure. */
export function Disclosure(props: DisclosureProps) {
const [local, rest] = splitProps(props, ["variant", "class", "className"]);
return <Prim class={cn(rc("disclosure", { "variant": local["variant"] }), local.class ?? local.className)} {...rest} />;
}
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 disclosurecompose/disclosure.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"
// DisclosureProps: Disclosure: Disclosure + recipe disclosure.
type DisclosureProps struct {
Variant string
disclosure.DisclosureProps
}
func disclosureInner(p DisclosureProps) disclosure.DisclosureProps {
in := p.DisclosureProps
in.Class = Join(Rc("disclosure", map[string]string{"variant": p.Variant}), p.DisclosureProps.Class)
return in
}
// Disclosure renders Disclosure with the composition classes.
templ Disclosure(p DisclosureProps) {
@disclosure.Disclosure(disclosureInner(p)) {
{ children... }
}
}
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 disclosurecompose/Disclosure.html.twig
{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# Disclosure: Disclosure + recipe disclosure. Params: variant, class, attrs + the params of Disclosure. #}
{% include 'ui/disclosure/Disclosure.html.twig' with compose_props('Disclosure', _context) only %}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 disclosurecompose/Disclosure.latte
{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* Disclosure: Disclosure + recipe disclosure. *}
{parameters
string $class = '',
bool $open = false,
?string $name = null,
array $attrs = [],
string $children = '',
$variant = null,
}
{include '../ui/disclosure/Disclosure.latte', ...\CodegenX\Compose\Latte\Compose::props('Disclosure', ['class' => $class, 'open' => $open, 'name' => $name, 'attrs' => $attrs, 'children' => $children, 'variant' => $variant])}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 disclosurecompose/disclosure.html.j2
{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
Disclosure: Disclosure + recipe disclosure. Props (p): Variant, Class, Attrs + the props of Disclosure. -#}
{%- with p = compose_props('Disclosure', p) %}{% include 'ui/disclosure/disclosure.html.j2' %}{% endwith %}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.
Disclosure renders a native details element.
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | - | initial open state |