Toggle readonly mode at runtime with customizable indicator badges and configurable interaction controls
Toggle readonly mode and configure options to see the widget behavior change in real-time.
// Initialize widget
const widget = window.NexusChatWidget.init({
experienceId: "your-experience-id",
apiUrl: "undefined"
});
// Simple enable/disable
widget.setReadOnly(true);
widget.setReadOnly(false);
// With indicator badge
widget.setReadOnly(true, {
indicator: {
show: true,
text: "Maintenance Mode",
backgroundColor: "#FEF3C7",
textColor: "#92400E"
}
});
// Disable copy button in readonly mode
widget.setReadOnly(true, {
allowCopy: false
});
// Listen for state changes
widget.on('readOnlyChange', (data) => {
console.log('Readonly:', data.readOnly);
console.log('Indicator:', data.indicator);
});Toggle readonly mode to see events...
Disable interactions during backend maintenance while users can still read previous conversations.
Allow supervisors to review chat sessions without accidentally sending messages.
Temporarily disable input when rate limits are hit, showing an indicator with remaining wait time.
Show a read-only preview of the chat widget before users sign in or complete onboarding.