TemplateBuilder
Props, styling and a live TemplateBuilder example.
TemplateBuilder
Sample data
@polymorfa/react
Customize
TemplateBuilderExample.jsx
npm install @polymorfa/react@dev @polymorfa/browser@devimport { PolymorfaProvider, TemplateBuilder } from "@polymorfa/react";
const appearance = { theme: "light", variables: { colorPrimary: "#635bff" } };
export function TemplateBuilderExample({ builder }) {
return (
<PolymorfaProvider tokenEndpoint="/api/polymorfa/token" appearance={appearance}>
<TemplateBuilder
controller={builder}
/>
</PolymorfaProvider>
);
}TemplateBuilder from @polymorfa/react. Choose props and styles above; the preview stays visible in every code view.
Props#
renderPreview(preview: RenderedTemplate) => ReactNodeReplaces the preview region without replacing editor state.
classNamestringRoot class and slot classes.
classNamesSlotClassNamesRoot class and slot classes.
controllerTemplateBuilderControllerTemplate state.
createController() => TemplateBuilderControllerFactory for a controller the component owns.
Styling#
Use className, classNames (a class for any slot, typed SlotClassNames), appearance variables and element styles. The Style panel applies changes to the live component. See Appearance.
Setup#
Use the provider and server route for your application. The preview above uses local sample data and controllers. Chat controllers and inbox data sources keep your data separate from the UI.