Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Reference & Disclosure

Type Definition

Keep the purpose of a contract visible while its implementation stays one click away. Type Definition brings a readable heading, exact identifier, contextual metadata and an accessible disclosure into one compact reference card. Use it for component props, configuration shapes and event payloads without coupling your interface to a syntax highlighter or documentation router. Separate a contract’s purpose from its implementation details. Keep the summary readable and reveal complete source only when the reader needs it. Import it from @/components/kamod-ui/type-definition.

Source · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Import TypeDefinition from @kamod-ch/ui or @kamod-ch/ui/type-definition. It composes Kamod’s existing Collapsible behavior and uses semantic theme tokens. No parser, clipboard library or router is required. Keep the shared stylesheet configured using the Theming & Tailwind guide before rendering the examples.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Usage

Give title a human-readable purpose and typeName the exact identifier readers will find in source. Put a short explanation in description, optional field context in metadata, and the complete definition in children. The card starts collapsed; use defaultOpen for an initially visible definition or pair open with onOpenChange when a prop table, search result or permalink needs to reveal it. Expansion does not update the URL or move focus automatically.

Choose the Right Boundary. Use Collapsible for a general disclosure, Accordion for a coordinated question-and-answer list, and this component when the summary belongs to a named contract. Preview source uses the documentation highlighter; the copied examples use native pre and code elements so you can choose your own renderer. See the Application Shell Brand Reference for a complete integration with source links and required-field documentation.

Import SetupTypeScript
import { TypeDefinition } from "@kamod-ch/ui";

Choose a complete composition from the examples below; required child components and props vary by pattern.

Component Examples & Variants

Explore Type Definition in Different Contexts, from the starting pattern to the compositions below. Begin with Summary and Source, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Summary and Source

Make the Closed Card Useful on Its Own. Use a concise visible description to introduce the type before its source is expanded. The disclosure bar communicates that more detail is available, with distinct hover and keyboard-focus treatments for discovering the interaction.

Keep detailed declarations in the expanded region and link related concepts in the summary where helpful, so users can decide whether opening the definition answers their question.

src/components/TypeDefinitionExample.tsx8 lines
import { TypeDefinition } from "@kamod-ch/ui";

export const Example = () => (
  <TypeDefinition title="Navigation item" typeName="NavigationItem"
    description="A label and destination for one navigation entry.">
    <pre><code>{`type NavigationItem = { label: string; href: string; disabled?: boolean };`}</code></pre>
  </TypeDefinition>
);

Metadata and Field Documentation

Separate the Summary from the Detailed Contract. Keep the required fields and essential contract summary visible, then place source, detailed explanations and related links in the expanded region. A separate header action can expose a reference without nesting another button inside the disclosure trigger.

Use inline code for identifiers and ordinary prose for their meaning, with links to related contracts where they help. Expand the definition with the keyboard, then verify that its separate reference action can be reached without also toggling the content.

Keep Metadata Factual. A required-field list describes your contract; the card does not inspect TypeScript or validate inputs. Supply headerAction for a badge or source link beside the heading. Add titleMetadata for a short field count and triggerHint for the source language beside the disclosure label; both receive a subtle dot separator. Put longer explanations in the definition content. Follow the Source Declarations to see the exact slot types.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Reveal from Another Control

Reveal the Same Content from Several Entry Points. Drive the definition's open state from one parent when external controls also need to reveal it. Keep the disclosure label and aria-expanded synchronized with that value; defaultOpen is only an initial-state option.

Decide whether navigation should move focus or only reveal content, and verify that closing from either control leaves the accessible expanded state accurate.

Link, Reveal, Then Navigate. Keep a stable headingId when linking from a props table. Your application can set open before scrolling to that anchor. If you close a card from an external control while focus is inside it, return focus to its trigger. Read the Accessibility Guidance before adding custom navigation or asynchronous content.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Compact Contract List

Keep a Collection Readable without Flattening Its Structure. Use compact density for a group of short declarations while keeping each definition independently expandable. Choose headingLevel to fit the surrounding article, and retain meaningful type names even when the source itself occupies only a few lines.

Use the surrounding heading hierarchy deliberately and keep independent disclosure state so comparing two definitions does not require repeatedly reopening them.

Use Density Consistently. Compact cards work well for several small contracts in a vertical list. The disclosure keeps a minimum height of 2.75rem in both densities. Prefer the default spacing for longer summaries and richly documented definitions; use Semantic Theme Colors for any local adjustments.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props and Data

Configure Type Definition using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props, slots and variants for this component.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/type-definition23.0 KB min · 5.5 KB gzipSignals: via collapsible@preact/signals

TypeDefinition

TypeDefinitionProps

TypeDefinition documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildTypeDefinitionProps

Configure children for TypeDefinition. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>TypeDefinitionProps

Configure class for TypeDefinition. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
collapseLabel
stringTypeDefinitionProps

Configure collapseLabel for TypeDefinition. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"Hide Definition"
contentClass
stringTypeDefinitionProps

Configure contentClass for TypeDefinition. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
defaultOpen
booleanTypeDefinitionProps

Uncontrolled initial state

Default
—
density
"default" | "compact"TypeDefinitionProps

Compact density reduces spacing without shrinking the disclosure's touch target.

Default
"default"
description
ComponentChild[] | ComponentChildTypeDefinitionProps

Summary content. Links and inline code are welcome; use children for the full definition.

Default
—
expandLabel
stringTypeDefinitionProps

Localizable labels; the type name is appended for assistive technology.

Default
"View Definition"
headerAction
ComponentChild[] | ComponentChildTypeDefinitionProps

Optional secondary content beside the heading, outside the disclosure button.

Default
—
headingId
stringTypeDefinitionProps

Stable heading anchor for a document's links; omitted IDs are generated per instance.

Default
—
headingLevel
2 | 3 | 4 | 5 | 6TypeDefinitionProps

Match the surrounding document hierarchy.

Default
3
metadata
ComponentChild[] | ComponentChildTypeDefinitionProps

Required fields, badges or other context below the summary.

Default
—
onOpenChange
((open: boolean) => void)TypeDefinitionProps

Called when open state changes (toggle or programmatic)

Default
—
open
booleanTypeDefinitionProps

Controlled open state

Default
—
title
ComponentChild[] | ComponentChildTypeDefinitionProps

Human-readable heading; may contain a permalink supplied by the application.

Default
—
titleMetadata
stringTypeDefinitionProps

Short, non-interactive context beside the heading, such as a declared field count.

Default
—
triggerClass
stringTypeDefinitionProps

Optional utility overrides for the disclosure button and expanded content.

Default
—
triggerHint
stringTypeDefinitionProps

Secondary disclosure text; never place another interactive control inside the trigger.

Default
—
typeName
stringTypeDefinitionProps

Exact identifier, displayed as code and included in the disclosure's accessible name.

Default
—

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

TypeDefinition Props

14 declared fields
TypeDefinitionProps
A reference summary with an optional metadata row and lazily mounted definition content. Inspect the Complete Definition of TypeDefinitionProps before adapting it.
Required fields
title, typeName

Accessibility

Type Definition pairs a persistent summary with a real disclosure button. aria-expanded follows the actual state and aria-controls names the content panel. Decorative code and chevron icons are hidden from assistive technology. The card starts collapsed unless defaultOpen or controlled open says otherwise. Source children are mounted only while expanded, so hidden copy buttons are not extra tab stops.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.