← ClaudeAtlas

building-chat-widgetslisted

Build interactive AI chat widgets with buttons, forms, and bidirectional actions. Use when creating agentic UIs with clickable widgets, entity tagging (@mentions), composer tools, or server-handled widget actions. Covers full widget lifecycle. NOT when building simple text-only chat without interactive elements.
aiskillstore/marketplace · ★ 329 · AI & Automation · score 79
Install: claude install-skill aiskillstore/marketplace
# Building Chat Widgets Create interactive widgets for AI chat with actions and entity tagging. ## Quick Start ```typescript const chatkit = useChatKit({ api: { url: API_URL, domainKey: DOMAIN_KEY }, widgets: { onAction: async (action, widgetItem) => { if (action.type === "view_details") { navigate(`/details/${action.payload.id}`); } }, }, }); ``` --- ## Action Handler Types | Handler | Defined In | Processed By | Use Case | |---------|------------|--------------|----------| | `"client"` | Widget template | Frontend `onAction` | Navigation, local state | | `"server"` | Widget template | Backend `action()` | Data mutation, widget replacement | --- ## Widget Lifecycle ``` 1. Agent tool generates widget → yield WidgetItem 2. Widget renders in chat with action buttons 3. User clicks action → action dispatched 4. Handler processes action: - client: onAction callback in frontend - server: action() method in ChatKitServer 5. Optional: Widget replaced with updated state ``` --- ## Core Patterns ### 1. Widget Templates Define reusable widget layouts with dynamic data: ```json { "type": "ListView", "children": [ { "type": "ListViewItem", "key": "item-1", "onClickAction": { "type": "item.select", "handler": "client", "payload": { "itemId": "item-1" } }, "children": [ { "type": "Row",