Coral UI

Overview

Framework-agnostic UI specification format for design systems

Introduction

Coral is a specification format for describing UI components in a framework-agnostic way. Define your component structure, styling, variants, interactivity, and responsive behavior in a portable JSON format that can be transformed into various output formats.

Why Coral?

  • Framework Agnostic - Define once, generate for React, Vue, HTML, or any framework
  • Design System Ready - Built-in support for variants, tokens, and composition
  • Type Safe - Full TypeScript support with Zod validation
  • Tool Friendly - JSON format works with any tool or language

Key Features

Component Variants

CVA-style variant definitions with per-node style responses:

{
  "componentVariants": {
    "axes": [
      { "name": "intent", "values": ["primary", "secondary"], "default": "primary" },
      { "name": "size", "values": ["sm", "md", "lg"], "default": "md" }
    ]
  },
  "variantStyles": {
    "intent": {
      "primary": { "backgroundColor": "#007bff" },
      "secondary": { "backgroundColor": "#6c757d" }
    }
  }
}

Package System

Organize your design system with coral.config.json:

coral init my-design-system
coral add component Button
coral validate
coral build --target types

Component Composition

Embed components within components:

{
  "type": "COMPONENT_INSTANCE",
  "$component": { "ref": "./button/button.coral.json" },
  "propBindings": { "intent": "primary" }
}

Typed Props & Events

Full type definitions for component APIs:

{
  "props": {
    "label": { "type": "string", "required": true },
    "disabled": { "type": "boolean", "default": false }
  },
  "events": {
    "onClick": { "parameters": [{ "name": "event", "type": "React.MouseEvent" }] }
  }
}

Quick Start

Packages

PackageDescriptionDocumentation
@reallygoodwork/coral-coreCore types, schemas, CLI, and utilitiesCore Package Docs
@reallygoodwork/coral-to-reactGenerate React components from Coral specsCoral to React Docs
@reallygoodwork/coral-to-htmlGenerate HTML from Coral specsCoral to HTML Docs
@reallygoodwork/react-to-coralParse React components to Coral specsReact to Coral Docs
@reallygoodwork/coral-tw2cssConvert Tailwind classes to CSSTailwind to CSS Docs
@reallygoodwork/style-to-tailwindConvert CSS styles to Tailwind classesStyle to Tailwind Docs

Example

Here's a complete button component with variants, props, and events:

{
  "$schema": "https://coral.design/schema.json",
  "name": "Button",
  "elementType": "button",

  "$meta": {
    "name": "Button",
    "version": "1.0.0",
    "status": "stable"
  },

  "componentVariants": {
    "axes": [
      { "name": "intent", "values": ["primary", "secondary", "destructive"], "default": "primary" },
      { "name": "size", "values": ["sm", "md", "lg"], "default": "md" }
    ]
  },

  "props": {
    "label": { "type": "string", "required": true }
  },

  "events": {
    "onClick": { "description": "Button click handler" }
  },

  "styles": {
    "display": "inline-flex",
    "borderRadius": "6px",
    "fontWeight": "500"
  },

  "variantStyles": {
    "intent": {
      "primary": { "backgroundColor": "#007bff", "color": "#fff" },
      "secondary": { "backgroundColor": "#6c757d", "color": "#fff" },
      "destructive": { "backgroundColor": "#dc3545", "color": "#fff" }
    },
    "size": {
      "sm": { "padding": "4px 8px", "fontSize": "12px" },
      "md": { "padding": "8px 16px", "fontSize": "14px" },
      "lg": { "padding": "12px 24px", "fontSize": "16px" }
    }
  },

  "textContent": { "$prop": "label" }
}

Documentation Structure

Coral documentation is organized into two main sections:

Concept Guides (/docs/guides/)

In-depth explanations of core concepts with examples:

API Documentation (/docs/packages/)

Reference documentation for packages and APIs:

Tip: Start with the Getting Started guide to learn concepts, then refer to API documentation for specific implementation details.

Community

On this page