Control editing capabilities in UI Builder by restricting specific operations like variable editing, page creation, and page deletion. Perfect for production environments, content-only editing, and role-based access control.
UI Builder provides three boolean props to control editing permissions:
tsx1<UIBuilder 2 allowVariableEditing={false} // Disable variable CRUD operations 3 allowPagesCreation={false} // Disable creating new pages 4 allowPagesDeletion={false} // Disable deleting pages 5 componentRegistry={myComponentRegistry} 6/>
| Prop | Default | Description |
|---|---|---|
allowVariableEditing | true | Controls variable add/edit/delete in Variables panel |
allowPagesCreation | true | Controls ability to create new pages |
allowPagesDeletion | true | Controls ability to delete existing pages |
Experience all read-only modes in one interactive demo:
Allow content editing while preventing structural changes:
tsx1<UIBuilder 2 allowPagesCreation={false} // Lock page structure 3 allowPagesDeletion={false} // Prevent accidental page loss 4 allowVariableEditing={true} // Allow content variable updates 5 componentRegistry={myComponentRegistry} 6/>
Use case: Content teams updating copy, images, and variable content without changing page layouts.
Lock down all structural changes:
tsx1<UIBuilder 2 allowVariableEditing={false} // Lock system variables 3 allowPagesCreation={false} // No new pages 4 allowPagesDeletion={false} // No page deletion 5 initialLayers={templatePages} 6 initialVariables={systemVariables} 7 componentRegistry={myComponentRegistry} 8/>
Use case: Previewing templates in production with system-controlled variables.
Different permissions based on user roles:
tsx1function RoleBasedEditor({ user, template }) { 2 const canEditVariables = user.role === 'admin' || user.role === 'developer'; 3 const canManagePages = user.role === 'admin'; 4 5 return ( 6 <UIBuilder 7 allowVariableEditing={canEditVariables} 8 allowPagesCreation={canManagePages} 9 allowPagesDeletion={canManagePages} 10 initialLayers={template.pages} 11 initialVariables={template.variables} 12 componentRegistry={myComponentRegistry} 13 /> 14 ); 15}
When creating templates with variable references, use the correct format:
tsx1// ✅ Correct: Variable binding in component props 2const templateLayer: ComponentLayer = { 3 id: "title", 4 type: "span", 5 name: "Title", 6 props: { 7 className: "text-2xl font-bold", 8 children: { __variableRef: "pageTitle" } // Correct format 9 }, 10 children: [] 11}; 12 13// ❌ Incorrect: Variable binding directly in children 14const badTemplate: ComponentLayer = { 15 id: "title", 16 type: "span", 17 name: "Title", 18 props: { 19 className: "text-2xl font-bold" 20 }, 21 children: { __variableRef: "pageTitle" } // Wrong - causes TypeScript errors 22};
Key points:
props object__variableRef (without quotes) as the property namechildren: [] when using variable bindingSee the immutable pages example that demonstrates locked page structure:
allowPagesCreation={false} and allowPagesDeletion={false}See the immutable bindings example that demonstrates locked variables:
allowVariableEditing={false}Even with restrictions enabled, users can still:
✅ Visual Component Editing: Add, remove, and modify components on the canvas
✅ Props Panel: Configure component properties and bind to existing variables
✅ Appearance Panel: Modify themes and styling
✅ Layer Navigation: Select and organize components in the layers panel
✅ Undo/Redo: Full history navigation
✅ Code Generation: Export React code
For pure display without any editing interface, use LayerRenderer:
tsx1import LayerRenderer from '@/components/ui/ui-builder/layer-renderer'; 2 3function DisplayOnlyPage({ pageData, variables, userValues }) { 4 return ( 5 <LayerRenderer 6 page={pageData} 7 componentRegistry={myComponentRegistry} 8 variables={variables} 9 variableValues={userValues} // Runtime data injection 10 /> 11 ); 12}
Choose LayerRenderer when:
Choose restricted UIBuilder when:
tsx1function ConfigurableEditor({ 2 template, 3 user, 4 environment 5}) { 6 const permissions = { 7 allowVariableEditing: environment !== 'production' && user.canEditVariables, 8 allowPagesCreation: user.role === 'admin', 9 allowPagesDeletion: user.role === 'admin' 10 }; 11 12 return ( 13 <UIBuilder 14 {...permissions} 15 initialLayers={template.pages} 16 initialVariables={template.variables} 17 componentRegistry={myComponentRegistry} 18 persistLayerStore={environment === 'development'} 19 /> 20 ); 21}