12k

@json-render/shadcn-svelte

Pre-built shadcn-svelte components for json-render. 36 components built on Svelte 5 + Tailwind CSS, ready to use with defineCatalog and defineRegistry.

Installation#

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

Your app must have Tailwind CSS configured.

Entry Points#

Entry PointExportsUse For
@json-render/shadcn-svelteshadcnComponents, shadcnComponentDefinitionsSvelte implementations + catalog schemas
@json-render/shadcn-svelte/catalogshadcnComponentDefinitionsCatalog schemas only (no Svelte 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/svelte/schema";
import { shadcnComponentDefinitions } from "@json-render/shadcn-svelte/catalog";
import { defineRegistry } from "@json-render/svelte";
import { shadcnComponents } from "@json-render/shadcn-svelte";

// 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,
  },
});

Then render in your Svelte component:

<script lang="ts">
  import { Renderer, JsonUIProvider } from "@json-render/svelte";

  export let spec;
  export let registry;
</script>

<JsonUIProvider initialState={spec?.state ?? {}}>
  <Renderer {spec} {registry} />
</JsonUIProvider>

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 Svelte dependency -- use it for server-side prompt generation
  • Components use Tailwind CSS classes -- your app must have Tailwind configured
  • Component implementations use bundled shadcn-svelte primitives (not your app's $lib/components/ui/)
  • Form inputs support checks for validation (type + message pairs) and validateOn for timing
  • Events: inputs emit change/submit/focus/blur; buttons emit press; selects emit change/select