Interactive React component for JSON Schema documentation. Used by the Deckard CLI for consistent schema documentation across CLI and web applications.
- 🎯 Zero configuration - Works out of the box with sensible defaults
- 🎨 Modern design - Clean, compact interface that scales from simple to complex schemas
- ⚡ Interactive - Collapsible sections, search, keyboard shortcuts
- 🔍 Search - Real-time property search with auto-expansion
- 📱 Responsive - Mobile-friendly design
- ♿ Accessible - Full keyboard navigation and screen reader support
- 🎠Themeable - Light/dark mode with CSS custom properties
- đź“‹ Copy-friendly - Click any code snippet to copy to clipboard
- 🏗️ TypeScript - Full TypeScript support with comprehensive type definitions
npm install @peridio/deckard-reactImport both the component and CSS styles:
import { DeckardSchema } from '@peridio/deckard-react';
import '@peridio/deckard-react/dist/style.css';
function MyApp() {
const schema = {
type: 'object',
properties: {
name: { type: 'string' },
age: { type: 'number' }
}
};
return <DeckardSchema schema={schema} />;
}Important: You must import the CSS file for proper styling.
Or for development, clone and build:
git clone https://github.com/peridio/deckard-react.git
cd deckard-react
npm install
npm run buildimport React from 'react';
import { DeckardSchema } from '@peridio/deckard-react';
const schema = {
type: 'object',
properties: {
name: {
type: 'string',
description: 'User name',
minLength: 2,
maxLength: 50
},
email: {
type: 'string',
format: 'email',
description: 'User email address'
},
age: {
type: 'integer',
minimum: 0,
maximum: 120,
examples: [25, 30, 45]
}
},
required: ['name', 'email']
};
function App() {
return (
<div>
<DeckardSchema schema={schema} />
</div>
);
}| Prop | Type | Default | Description |
|---|---|---|---|
schema |
JsonSchema |
Required | The JSON schema to render |
options |
DeckardOptions |
{} |
Configuration options |
className |
string |
'' |
Additional CSS class names |
interface DeckardOptions {
includeHeader?: boolean; // Show schema title/description (true)
includePropertiesTitle?: boolean; // Show "Properties" heading (true)
includeDefinitions?: boolean; // Show definitions section (false)
includeExamples?: boolean; // Show examples in 2-column layout (false)
searchable?: boolean; // Enable search functionality (true)
collapsible?: boolean; // Enable expand/collapse (true)
autoExpand?: boolean; // Auto-expand all properties (false)
theme?: 'light' | 'dark' | 'auto'; // Color theme (auto)
}Full JSON Schema Draft 7 support including:
interface JsonSchema {
type?: 'null' | 'boolean' | 'object' | 'array' | 'number' | 'integer' | 'string';
properties?: Record<string, JsonSchema>;
items?: JsonSchema | JsonSchema[];
required?: string[];
enum?: any[];
const?: any;
default?: any;
examples?: any[];
format?: string;
pattern?: string;
minimum?: number;
maximum?: number;
minLength?: number;
maxLength?: number;
minItems?: number;
maxItems?: number;
// ... and many more
}The component uses CSS custom properties for theming:
.schema-container {
--schema-accent-primary: #3b82f6;
--schema-surface: rgba(0, 0, 0, 0.02);
--schema-border: rgba(0, 0, 0, 0.08);
/* ... many more variables available */
}import { DeckardSchema } from '@peridio/deckard-react';
const complexSchema = {
title: "User Profile API",
description: "Schema for user profile management",
type: "object",
properties: {
user: {
type: "object",
description: "User information",
properties: {
profile: {
type: "object",
properties: {
firstName: { type: "string", minLength: 1 },
lastName: { type: "string", minLength: 1 },
avatar: {
type: "string",
format: "uri",
examples: ["https://example.com/avatar.jpg"]
}
},
required: ["firstName", "lastName"]
},
preferences: {
type: "object",
properties: {
theme: {
type: "string",
enum: ["light", "dark", "auto"],
default: "auto"
},
notifications: {
type: "boolean",
default: true,
description: "Enable email notifications"
}
}
}
},
required: ["profile"]
}
},
required: ["user"]
};
function AdvancedExample() {
return (
<DeckardSchema
schema={complexSchema}
options={{
includeExamples: true,
includeDefinitions: true,
autoExpand: false
}}
/>
);
}/- Focus searchh- Navigate left (collapse section or move to parent)j- Navigate down (next property)k- Navigate up (previous property)l- Navigate right (expand section or move to first child)Ctrl/Cmd + E- Expand all propertiesCtrl/Cmd + Shift + E- Collapse all propertiesEscape- Clear searchEnter/Space- Toggle property expansion- Click any
codeelement to copy to clipboard
The component supports vim-style hjkl navigation similar to Linear and Chrome DevTools:
- Selected properties are highlighted with a blue border and background
- Navigation prevents page scrolling
- Works seamlessly with collapsible sections and search filtering
- Full keyboard navigation support
- Screen reader friendly with proper ARIA attributes
- High contrast mode support
- Respects
prefers-reduced-motion - Focus indicators for all interactive elements
- Chrome/Edge 88+
- Firefox 78+
- Safari 14+
- iOS Safari 14+
- Android Chrome 88+
# Install dependencies
npm install
# Build the package
npm run build
# Run tests
npm test
# Lint code
npm run lintIf you're migrating from the Rust CLI version:
// Old: Generate HTML with CLI and include separately
// deckard convert schema.json --with-examples > output.html
// New: Use React component directly
import { DeckardSchema } from '@peridio/deckard-react';
import schema from './schema.json';
function MyComponent() {
return (
<DeckardSchema
schema={schema}
options={{ includeExamples: true }}
/>
);
}- Deckard CLI - Command-line tool that uses this component for interactive HTML generation
Apache-2.0
Issues and PRs welcome!