@json-render/shadcn

Pre-built shadcn/ui components for json-render. 36 components built on Radix UI + Tailwind CSS, ready to use with defineCatalog and defineRegistry.

Installation

npm install @json-render/shadcn @json-render/core @json-render/react zod

Your app must have Tailwind CSS configured.

Entry Points

Entry PointExportsUse For
@json-render/shadcnshadcnComponentsReact implementations
@json-render/shadcn/catalogshadcnComponentDefinitionsCatalog schemas (no React dependency, safe for server)

Usage

Pick the components you need from the standard definitions:

import { defineCatalog } from "@json-render/core";
import { schema } from "@json-render/react/schema";
import { shadcnComponentDefinitions } from "@json-render/shadcn/catalog";
import { defineRegistry } from "@json-render/react";
import { shadcnComponents } from "@json-render/shadcn";

// Catalog: pick definitions
const catalog = defineCatalog(schema, {
  components: {
    Card: shadcnComponentDefinitions.Card,
    Stack: shadcnComponentDefinitions.Stack,
    Heading: shadcnComponentDefinitions.Heading,
    Button: shadcnComponentDefinitions.Button,
    Input: shadcnComponentDefinitions.Input,
  },
  actions: {},
});

// Registry: pick matching implementations
const { registry } = defineRegistry(catalog, {
  components: {
    Card: shadcnComponents.Card,
    Stack: shadcnComponents.Stack,
    Heading: shadcnComponents.Heading,
    Button: shadcnComponents.Button,
    Input: shadcnComponents.Input,
  },
});

State actions (setState, pushState, removeState) are built into the React schema and handled by ActionProvider automatically. You don't need to declare them in your catalog.

Extending with Custom Components

Add custom components alongside standard ones:

import { z } from "zod";

const catalog = defineCatalog(schema, {
  components: {
    // Standard
    Card: shadcnComponentDefinitions.Card,
    Stack: shadcnComponentDefinitions.Stack,
    Button: shadcnComponentDefinitions.Button,

    // Custom
    Metric: {
      props: z.object({
        label: z.string(),
        value: z.string(),
        trend: z.enum(["up", "down", "neutral"]).nullable(),
      }),
      description: "KPI metric display",
    },
  },
  actions: {},
});

const { registry } = defineRegistry(catalog, {
  components: {
    Card: shadcnComponents.Card,
    Stack: shadcnComponents.Stack,
    Button: shadcnComponents.Button,
    Metric: ({ props }) => (
      <div>
        <span>{props.label}</span>
        <span>{props.value}</span>
      </div>
    ),
  },
});

Available Components

Layout

ComponentDescription
CardContainer card with optional title, description, maxWidth, centered
StackFlex container with direction, gap, align, justify
GridGrid layout with columns (1-6) and gap
SeparatorVisual separator line with orientation
ComponentDescription
TabsTabbed navigation with tabs array, defaultValue, value
AccordionCollapsible sections with items array and type (single/multiple)
CollapsibleSingle collapsible section with title and defaultOpen
PaginationPage navigation with totalPages and page

Overlay

ComponentDescription
DialogModal dialog with title, description, openPath
DrawerBottom drawer with title, description, openPath
TooltipHover tooltip with content and text
PopoverClick-triggered popover with trigger and content
DropdownMenuDropdown menu with label and items array

Content

ComponentDescription
HeadingHeading text with level (h1-h4)
TextParagraph with variant (body, caption, muted, lead, code)
ImageImage with alt, width, height
AvatarUser avatar with src, name, size
BadgeStatus badge with text and variant
AlertAlert banner with title, message, type
CarouselHorizontally scrollable carousel with items
TableData table with columns and rows

Feedback

ComponentDescription
ProgressProgress bar with value, max, label
SkeletonLoading placeholder with width, height, rounded
SpinnerLoading spinner with size and label

Input

ComponentDescription
ButtonClickable button with label, variant, disabled
LinkAnchor link with label and href
InputText input with label, name, type, placeholder, value, checks
TextareaMulti-line text input with label, name, placeholder, rows, value, checks
SelectDropdown select with label, name, options, value, checks
CheckboxCheckbox with label, name, checked
RadioRadio button group with label, name, options, value
SwitchToggle switch with label, name, checked
SliderRange slider with label, min, max, step, value
ToggleToggle button with label, pressed, variant
ToggleGroupGroup of toggle buttons with items, type, value
ButtonGroupGroup of buttons with buttons array and selected

Notes

  • The /catalog entry point has no React dependency -- use it for server-side prompt generation
  • Components use Tailwind CSS classes -- your app must have Tailwind configured
  • Component implementations use bundled shadcn/ui primitives (not your app's components/ui/)
  • Form inputs support checks for validation (type + message pairs)
  • Events: inputs emit change/submit/focus/blur; buttons emit press; selects emit change/select