Render registered widgets from supplied JSX
Preparing preview…
Renders registered components and plain data expressions from streamed JSX through an optional parser.
Preparing preview…
Preparing preview…
npm install @noorddev/vlak-react react-jsx-parser@^2.4.1 acorn@^8.15.0 acorn-jsx@^5.3.2
Load the stylesheet once at your app root, then import the components you use.
import "@noorddev/vlak-react/css";
import { JSXPreview } from "@noorddev/vlak-react/components/jsx-preview";Per-component imports are available at @noorddev/vlak-react/components/jsx-preview.
npx @noorddev/vlak-cli add jsx-preview
Adds the component to components/vlak/. Follow the StyleX setup to compile the source in your application.
npx shadcn add https://vlak.dev/r/jsx-preview.json
Installs the same source through the shadcn CLI.
import { JSXPreview } from "@noorddev/vlak-react/components/jsx-preview";
<JSXPreview jsx={'<section aria-label="Review summary"><p>{count} findings are ready.</p></section>'} bindings={{ count: 3 }} />See the integration example to compose these components with your application's model and data.
Optional Acorn-validated JSX data renderer. This is not a general JavaScript sandbox.
| Prop | Type | Default | Description |
|---|---|---|---|
jsxrequired | string | ||
streaming | boolean | false | |
components | Record<string, ElementType<any, keyof JSX.IntrinsicElements>> | {} | Trusted, display-only application components. Do not expose components that execute operations during render. |
bindings | Record<string, unknown> | Plain data only. Calls, functions, accessors and prototype access are rejected. | |
onError | (error: Error) => void | ||
fallback | ReactNode | ((error: Error) => ReactNode) |
Also accepts Omit<HTMLAttributes<HTMLDivElement>, "children" | "onError">.
The ref reaches HTMLDivElement.
| Keys | Does |
|---|---|
| Tab | Tab follows the normal order of controls and safe links produced by registered components. |
| Enter, Space | Keyboard behavior inside a registered component belongs to that component. |
The same styles are available as CSS. Native HTML provides the static presentation; React or application code supplies state updates and actions.
npm install @noorddev/vlak
import "@noorddev/vlak/css";
<div class="rs-jsx-preview"><div class="rs-jsx-preview-content"><section aria-label="Review summary"><p>3 findings are ready for review.</p></section></div></div>