YAML Spec Format

Every yamlCase file starts with a view definition. The view has a name, optional imports, and a body containing a tree of components.

Single-File View

The basic structure of a yamlCase view definition.

YAML Input
- type: panel
  id: overview
  title: Overview
  body:
    - type: grid
      columns: 3
      children:
        - type: metric_card
          label: Users
          value: "1,234"
        - type: metric_card
          label: Revenue
          value: "$5.6K"
        - type: metric_card
          label: Growth
          value: "+12%"
Generated TSX
<div className="hhd-panel" id="overview">
  <div className="panel-header" onClick={() => toggleSection("overview")}>
    <div className="panel-title-group">
      <h3 className="panel-title">Overview</h3>
    </div>
    {!collapsedSections.has("overview") && <span className="panel-toggle panel-toggle--open" aria-hidden="true"></span>}
    {collapsedSections.has("overview") && <span className="panel-toggle" aria-hidden="true"></span>}
  </div>
  {!collapsedSections.has("overview") && (
    <div className="panel-body">
        <div className="yc-s-80a3cb29">
                    <div className="hhd-metric">
                      <div className="hhd-label">Users</div>
                      <div className="hhd-value">1,234</div>
                    </div>
                    <div className="hhd-metric">
                      <div className="hhd-label">Revenue</div>
                      <div className="hhd-value">$5.6K</div>
                    </div>
                    <div className="hhd-metric">
                      <div className="hhd-label">Growth</div>
                      <div className="hhd-value">+12%</div>
                    </div>
        </div>
    </div>
  )}
</div>
Rendered Output

Overview

Users
1,234
Revenue
$5.6K
Growth
+12%

Component Types

Available Components

yamlCase provides 33 component types across two categories.

Python Components (13)

TypeDescription
panelContainer with title and body
gridCSS grid layout with columns
chartRecharts-based data visualization
tableData table with columns and rows
metric_cardKPI display with trend
badgeInline label/tag
conditionalif/else rendering
loopIterate over data arrays
customArbitrary JSX rendering

Template Components (22)

TypeKey Props
cardtitle, subtitle, footer
herotitle, subtitle, background
sidebartitle, collapsed, width
navbartitle, logo
tabsactiveTab
accordiontitle, defaultOpen
alertvariant, title, message
formtitle, submitLabel
headingtext, level, subtitle
textcontent, variant
code_blockcode, language, title
code_exampletitle, yaml_code, tsx_code

CSS-in-YAML

CSS-in-YAML System

yamlCase lets you define CSS directly inside your YAML views using the styles block. No separate CSS files needed. Your styles are compiled into the view CSS automatically.

YAML Gotcha

Values containing # must be quoted in YAML. For example: background: "#1a1a2e" (not background: #1a1a2e). YAML treats unquoted # as a comment.

Basic Syntax

Add a styles block at the top level of your view definition, alongside name, title, and body.

yamlBasic styles block
view:
  name: Dashboard
  styles:
    .card:
      padding: 1.5rem
      borderRadius: 8px
      background: white
    .sidebar:
      width: 260px
      background: "#1a1a2e"
  body:
    - type: section
      className: card
      children:
        - type: text
          content: Styled with YAML!

Nesting and Pseudo-selectors

Use & for pseudo-selectors and hover states. Use quoted child selectors for nested elements.

yamlNesting examples
styles:
  .nav-item:
    padding: 0.75rem 1rem
    color: white
    transition: all 0.2s ease
    "&:hover":                # .nav-item:hover
      background: rgba(255,255,255,0.1)
      transform: translateX(4px)
    "&.active":               # .nav-item.active
      borderLeft: 3px solid white
      fontWeight: 600
    ".icon":                  # .nav-item .icon
      marginRight: 0.5rem
      fontSize: 1.2em

Media Queries

Responsive styles are defined using @media blocks inside the styles section.

yamlResponsive design
styles:
  .dashboard:
    display: grid
    gridTemplateColumns: 260px 1fr
    gap: 1rem
  "@media (max-width: 768px)":
    .dashboard:
      gridTemplateColumns: 1fr
    .sidebar:
      display: none

Keyframe Animations

Define CSS keyframe animations directly in YAML.

yamlAnimations
styles:
  "@keyframes fadeIn":
    from:
      opacity: 0
      transform: translateY(-10px)
    to:
      opacity: 1
      transform: translateY(0)
  "@keyframes slideIn":
    "0%":
      transform: translateX(-100%)
    "100%":
      transform: translateX(0)
  .panel:
    animation: fadeIn 0.3s ease-out

CSS Variables

Define CSS custom properties (variables) using the :root selector.

yamlCSS Variables
styles:
  ":root":
    --primary: "#1a73e8"
    --secondary: "#5f6368"
    --sidebar-width: 260px
    --border-radius: 8px
  .button:
    background: var(--primary)
    borderRadius: var(--border-radius)

CSS Imports

Import external CSS files into your view using the css_imports block.

yamlExternal CSS imports
view:
  name: Dashboard
  css_imports:
    - ./shared/reset.css
    - ./shared/utilities.css
    - ./themes/dark.css
  body:
    - type: text
      content: External styles are imported!

camelCase to kebab-case

yamlCase automatically converts camelCase property names to kebab-case CSS. Both formats work.

YAML (camelCase)CSS Output (kebab-case)
backgroundColorbackground-color
borderRadiusborder-radius
fontSizefont-size
gridTemplateColumnsgrid-template-columns
boxShadowbox-shadow

State Management

State Management

yamlCase views can declare local state variables using the state block. Each variable becomes a React useState hook with automatic setter generation.

Local State

Define state variables as key-value pairs. The key is the variable name, the value is the default.

yamlDeclaring state variables
view:
  name: Counter
  state:
    count: 0
    name: '"hello"'
    isOpen: false
    items: '[]'
  body:
    - type: text
      content: "{count}"
Generated Code

Each state variable generates a useState hook. For example, count: 0 becomes const [count, setCount] = useState(0); in the generated TypeScript.

Using State in Components

Reference state variables using curly braces in component props. Use the setter function (setVariableName) in handlers.

yamlState with interactive components
view:
  name: TodoApp
  state:
    task: '""'
    tasks: '[]'
  handlers:
    - name: addTask
      body: |
        setTasks([...tasks, task]);
        setTask("");
  body:
    - type: input
      inputType: text
      placeholder: Enter a task
      value: "{task}"
      onChange: "(e) => setTask(e.target.value)"
    - type: button
      text: Add Task
      onClick: "{addTask}"

Event Handlers

Event Handlers

Define reusable handler functions in the handlers block. Each handler has a name, optional parameters, and a body of JavaScript code.

yamlDefining handlers
view:
  name: Dashboard
  state:
    selectedTab: '"overview"'
    data: '[]'
  handlers:
    - name: handleTabChange
      params: "(tab: string)"
      body: |
        setSelectedTab(tab);
    - name: handleRefresh
      body: |
        fetch('/api/data')
          .then(res => res.json())
          .then(d => setData(d));
    - name: handleDelete
      params: "(id: number)"
      body: |
        setData(data.filter(item => item.id !== id));
  body:
    - type: button
      text: Overview
      onClick: "{() => handleTabChange('overview')}"
    - type: button
      text: Refresh
      onClick: "{handleRefresh}"

Conditional Rendering

Conditional Rendering

Show or hide components based on conditions using the conditional component type. Supports when, condition, and if as aliases.

yamlConditional rendering
# Show/hide based on state
- type: conditional
  when: "{isLoggedIn}"
  children:
    - type: text
      content: Welcome back!

# With else branch
- type: conditional
  condition: "{user !== null}"
  children:
    - type: heading
      text: "Hello, {user.name}!"
  else:
    - type: text
      content: Please log in.

# Using 'if' alias
- type: conditional
  if: "{items.length > 0}"
  children:
    - type: loop
      items: "{items}"
      as: item
      template:
        - type: card
          title: "{item.name}"

Loops

Loops and Iteration

Iterate over arrays using the loop component type. Each item is rendered using the template.

yamlLoop examples
# Basic loop
- type: loop
  items: "{products}"
  as: product
  template:
    - type: card
      title: "{product.name}"
      subtitle: "Price: {product.price}"

# Loop with index
- type: loop
  items: "{steps}"
  as: step
  indexAs: i
  template:
    - type: text
      content: "Step {i + 1}: {step.title}"

View Structure

View Structure Reference

Every YAML file defines a single view. Here is the complete view structure with all available fields.

yamlComplete view structure
view:
  name: MyView              # Required: component name (PascalCase)
  icon: "H"                 # Sidebar icon: short text label or CSS/SVG icon, no emoji
  group: "Section"          # Navigation group
  title: My View            # Display title

  styles:                   # CSS-in-YAML scoped styles
    .my-class:
      color: blue
      font-size: 14px

  extra_imports:            # Additional TypeScript imports
    - "import { MyLib } from './myLib'"

  state:                    # Local state declarations
    count: "0"
    items: "[] as string[]"
    name: "'default'"

  handlers:                 # Event handler functions
    - name: increment
      body: |
        setCount(count + 1);
    - name: addItem
      params: "(item: string)"
      body: |
        setItems([...items, item]);

  effects:                  # Side effects (useEffect)
    - dependencies: "[count]"
      body: |
        document.title = `Count: ${count}`;

  body:                     # Component tree (required)
    - type: text
      content: "Count: {count}"
    - type: button
      label: Add
      on_click: "() => increment()"

name (required)

The view name becomes the React component name. Use PascalCase (MyPage, UserProfile). This is used for imports and routing.

icon

Unicode symbol for sidebar navigation. Use a short text label or a CSS/SVG icon; avoid emoji and pictographic Unicode glyphs, which some platforms render as emoji.

group

Navigation group name. Views with the same group appear together in the sidebar. Examples: Intro, Reference, Tools.

styles

Scoped CSS defined in YAML. Supports nesting, pseudo-selectors, media queries, keyframes, and CSS variables. See the CSS-in-YAML section above for full syntax.

extra_imports

Array of TypeScript import statements added to the generated component file. Use for external libraries, shared data, or CSS files.

state

Key-value pairs that become React useState hooks. Values are TypeScript expressions. Each key generates a state variable and setter (e.g., count becomes count and setCount).

handlers

Array of function definitions. Each handler has a name, optional params, and a body containing TypeScript code. Handlers can access state variables and setters.

effects

Array of useEffect definitions. Each effect has a dependencies array and a body. Use for side effects like API calls, timers, or DOM updates.


Handlers & Effects

Handler Patterns

Handlers are the primary way to add interactivity. They become regular functions inside the React component.

yamlHandler examples
handlers:
  # Simple handler (no params)
  - name: toggleMenu
    body: |
      setMenuOpen(!menuOpen);

  # Handler with parameters
  - name: updateField
    params: "(field: string, value: string)"
    body: |
      setFormData({...formData, [field]: value});

  # Async handler
  - name: fetchData
    params: "()"
    body: |
      const response = await fetch('/api/data');
      const data = await response.json();
      setItems(data);

  # Handler with DOM event
  - name: handleSubmit
    params: "(e: React.FormEvent)"
    body: |
      e.preventDefault();
      submitForm(formData);

Inline vs Named Handlers

For simple one-liner actions, use inline handlers directly on components. For complex logic, define named handlers.

yamlInline vs named
# Inline (simple actions)
- type: button
  label: Increment
  on_click: "() => setCount(count + 1)"

# Named (complex logic)
- type: button
  label: Submit
  on_click: "() => handleSubmit()"

Effect Patterns

Effects run after render. Use dependencies to control when they fire.

yamlEffect examples
effects:
  # Run once on mount
  - dependencies: "[]"
    body: |
      fetchInitialData();

  # Run when dependency changes
  - dependencies: "[searchQuery]"
    body: |
      const results = filterItems(searchQuery);
      setFilteredItems(results);

  # Cleanup on unmount
  - dependencies: "[]"
    body: |
      const timer = setInterval(() => tick(), 1000);
      return () => clearInterval(timer);

Expressions

Expressions & Interpolation

yamlCase supports JavaScript expressions inside curly braces. These are compiled to JSX expressions in the output.

yamlExpression syntax
# Simple variable
- type: text
  content: "Hello, {userName}!"

# Computed expression
- type: text
  content: "Total: {items.length} items"

# Ternary
- type: text
  content: "{isLoggedIn ? 'Welcome back' : 'Please log in'}"

# Function call
- type: text
  content: "{formatDate(createdAt)}"

# Template literal in style
- type: section
  style: "background: {isDark ? '#1e1e2e' : '#ffffff'}"

Expression Contexts

Expressions work in content, style, className, conditions, items, and event handlers.

yamlExpressions in different contexts
# In content
- type: text
  content: "{user.name}"

# In className (dynamic classes)
- type: section
  className: "card {isActive ? 'active' : ''}"

# In style (dynamic styling)
- type: section
  style: "opacity: {isVisible ? 1 : 0.5}"

# In conditional
- type: conditional
  condition: "items.length > 0"

# In each/loop items
- type: each
  items: "filteredItems"

Assembly

Multi-View Assembly

Multiple YAML views assemble into a complete React application with routing, navigation, and shared styles.

Project Config

The yamlcase.config.yaml file configures your project:

yamlyamlcase.config.yaml
project:
  name: My App           # App title (sidebar header)
  version: 1.0.0
build:
  output: src/generated  # Where compiled TSX goes
  style: sidebar         # Navigation style: sidebar or tabs

Assembly Commands

Compilation and assembly are managed by yamlCase. The workflow is:

bashCompilation workflow
# Managed compilation workflow
# 1. Prepare YAML views and templates.
# 2. Compile using approved yamlCase access.
# 3. Review the generated TSX, styles and routing.
# 4. Run project checks before deploying React output.

What Assembly Generates

Assembly can generate App.tsx, routing and shared styles for your views. The examples describe compiler output; they do not provide local compiler access.


Patterns

Common YAML Patterns

Frequently used patterns for building yamlCase interfaces.

Card Grid

- type: flex
  direction: row
  style: "flex-wrap: wrap; gap: 1rem"
  children:
    - type: each
      items: "cards"
      itemName: card
      children:
        - type: card
          title: "{card.title}"
          children:
            - type: text
              content: "{card.description}"

Form with Validation

- type: section
  children:
    - type: input
      placeholder: "Email"
      name: email
      on_change: "(e: any) => setEmail(e.target.value)"
    - type: conditional
      condition: "email && !email.includes('@')"
      children:
        - type: text
          content: "Please enter a valid email"
          style: "color: #ef4444; font-size: 13px"
    - type: button
      label: Submit
      on_click: "() => handleSubmit()"
      style: "margin-top: 1rem"

Tabbed Content

state:
  activeTab: "'overview'"
body:
  - type: flex
    direction: row
    style: "gap: 0; border-bottom: 2px solid #e2e8f0"
    children:
      - type: button
        label: Overview
        variant: "{activeTab === 'overview' ? 'primary' : 'ghost'}"
        on_click: "() => setActiveTab('overview')"
      - type: button
        label: Details
        variant: "{activeTab === 'details' ? 'primary' : 'ghost'}"
        on_click: "() => setActiveTab('details')"
  - type: conditional
    condition: "activeTab === 'overview'"
    children:
      - type: text
        content: "Overview content here"
  - type: conditional
    condition: "activeTab === 'details'"
    children:
      - type: text
        content: "Details content here"

Search Filter

state:
  query: "''"
body:
  - type: input
    placeholder: "Search..."
    name: query
    on_change: "(e: any) => setQuery(e.target.value)"
  - type: each
    items: "items.filter((item: any) => item.name.toLowerCase().includes(query.toLowerCase()))"
    itemName: item
    children:
      - type: text
        content: "{item.name}"

Gotchas

YAML Gotchas & Edge Cases

Common pitfalls when writing yamlCase and how to avoid them.

Quote Your Expressions

YAML interprets bare curly braces as objects. Always quote strings containing {expressions}.

yamlQuoting rules
# WRONG - YAML parses {name} as an object
content: Hello {name}

# CORRECT - quoted string
content: "Hello {name}"

# CORRECT - also works
content: 'Hello {name}'

Special Characters

Colons, hash signs, and other YAML-special characters need quoting.

yamlSpecial characters
# WRONG - colon breaks YAML parsing
content: Note: this will fail

# CORRECT - quote the value
content: "Note: this works fine"

# WRONG - hash starts a comment
style: color: #333

# CORRECT - quote the value
style: "color: #333"

Multi-line Strings

Use YAML block scalars (| or >) for multi-line content like handler bodies and long text.

yamlBlock scalars
# Literal block (preserves newlines)
body: |
  const x = 1;
  const y = 2;
  setResult(x + y);

# Folded block (joins lines)
content: >
  This is a very long paragraph
  that will be joined into a
  single line with spaces.

Boolean Gotcha

YAML parses yes, no, true, false, on, off as booleans. Quote them if you mean strings.

yamlBoolean gotcha
# YAML interprets as boolean true
label: yes

# Quote to keep as string
label: "yes"

# Same issue with 'on' and 'off'
status: "on"

Emoji in YAML

PyYAML may reject multi-byte emoji characters. Use Unicode symbols instead for icons.

yamlIcons
# May fail with PyYAML
icon: ""

# ASCII labels (no emoji or pictographic Unicode glyphs)
icon: "H"    # house
icon: "G"    # gear
icon: "S"    # star
icon: ">"    # play (ASCII; U+25B6 renders as an emoji on some platforms)

Complete YAML Reference

This covers the core YAML features. For advanced topics like global state, themes, form validation, testing, and storybook generation, see the Advanced page.