Skip to content

Components Overview

Glyph JS ships with 24 built-in UI components that transform YAML payloads inside fenced code blocks into rich, interactive visualizations. Each component has a Zod schema that validates its YAML at compile time, producing clear diagnostics if anything is wrong.

Authoring syntax

All components use the same fenced-code-block pattern. Write a fenced code block whose info string is ui: followed by the component name, and place valid YAML inside:

```ui:callout
type: info
content: This is an informational callout.
```

The YAML inside the block is parsed and validated by @glyphjs/compiler against the component Zod schema defined in @glyphjs/schemas.

Component catalog

Layout

ComponentTypeDescription
Columnsui:columnsPlace blocks side by side with proportional column widths.
Rowsui:rowsStack blocks vertically with gap control and optional ratio.
Panelui:panelWrap a block in a styled card, bordered, elevated, or ghost container.

Nest ui:columns and ui:rows recursively to build any 2D layout. See the Layouts guide for patterns and examples.

Content & Structure

ComponentTypeDescription
Calloutui:calloutHighlighted info, warning, error, and tip blocks for narrative structuring.
Tabsui:tabsTabbed content containers with switchable panels.
Stepsui:stepsSequential step-by-step guides with progress indication.
Accordionui:accordionCollapsible content sections with expand/collapse interaction.
Cardui:cardGrid of cards with titles, descriptions, and optional actions.
KPIui:kpiKey performance indicator metrics with trends and formatting.

Data & Comparison

ComponentTypeDescription
Tableui:tableSortable, filterable, aggregatable data tables.
Chartui:chartLine, bar, area, and OHLC financial charts.
Comparisonui:comparisonSide-by-side feature comparison tables.
CodeDiffui:codediffSyntax-highlighted code diffs with line-level changes.

Diagrams & Visualization

ComponentTypeDescription
Graphui:graphDAGs, flowcharts, mind maps, and force-directed graphs.
Relationui:relationEntity-relationship diagrams with cardinality annotations.
Flowchartui:flowchartProcess flowcharts with decision nodes and directional edges.
Sequenceui:sequenceSequence diagrams for message passing between actors.
MindMapui:mindmapHierarchical mind map diagrams with radial layout.
Architectureui:architectureSystem architecture diagrams with grouped nodes and connections.
FileTreeui:filetreeInteractive file and directory tree views.

Narrative & Interactive

ComponentTypeDescription
Timelineui:timelineChronological event sequences on a visual timeline.
Infographicui:infographicMulti-section visual infographics with icons and stats.
Equationui:equationStep-by-step mathematical equations with annotations.
Quizui:quizInteractive quizzes with multiple-choice questions and feedback.

Reserved YAML keys

Three top-level YAML keys are reserved and processed by the compiler before schema validation:

  • glyph-id — An explicit, user-assigned block ID that overrides the auto-generated ID. Enables stable cross-block references.
  • refs — An array of reference objects ({ target, type, label }) that declare relationships between blocks.
  • interactive — When set to true, enables interaction event emission for this block. The runtime injects an onInteraction callback that the component calls when the user interacts (clicks, sorts, selects, etc.).

These keys are stripped from the component data before it reaches the component schema.

Interaction events

Components marked with interactive: true can emit events when users interact with them. The following components support interaction events:

ComponentEvent kindPayload
Quizquiz-submitquestionIndex, question, selected, correct, score
Tabletable-sortstate (sort column, direction, filters, visible rows)
Tabletable-filterstate (sort column, direction, filters, visible rows)
Tabstab-selecttabIndex, tabLabel
Accordionaccordion-togglesectionIndex, sectionTitle, expanded
FileTreefiletree-selectpath, type (file/directory), expanded
Graphgraph-node-clicknodeId, nodeLabel
Chartchart-selectseriesIndex, dataIndex, label, value
Comparisoncomparison-selectoptionIndex, optionName

See the Authoring Guide for usage details and the Plugin API for the TypeScript types.

Container components

ui:tabs and ui:steps are container components whose children are expressed as Markdown strings inside the YAML content fields. The compiler re-parses each content field recursively, producing child Block[] entries in the IR. This allows tabs and steps to contain rich Markdown (paragraphs, lists, code blocks) but not nested ui: components in v1.

Layout components

ui:columns, ui:rows, and ui:panel are layout components that arrange other blocks in 2D space. Their children are suppressed block variables — blocks defined with =_name that are compiled but not rendered directly. The layout component resolves these names at compile time and stores them in block.children. The runtime renders each child via BlockRenderer inside the layout’s grid or container. See the Layouts guide for usage.