AI Chat styling
tng-ai-chat ships a professional token-driven default surface with stable data slots and CSS custom properties. Replace only the header or message parts your product owns.
Styling boundary
Customize semantic TailNG tokens, documented data-slot regions, and variables such as --tng-ai-chat-radius, --tng-ai-chat-min-height, and --tng-ai-chat-transcript-max-height. Keep CSS classes out of canonical messages.
Recommended presentation states include message status, author role, streaming state, tool-call lifecycle, approval state, error state, focus visibility, and reduced motion.
Renderer policy
Register trusted local Angular components for exact namespaced extensions. Agent content can supply extension data, but it cannot select a component class, selector, module, or URL.
Register an extension renderer
ts
import { TNG_AI_MESSAGE_PART_CONTEXT, type TngAiMessagePartRenderer } from '@tailng-ui/ai';
readonly partRenderers: readonly TngAiMessagePartRenderer[] = [{
match: { type: 'extension', name: 'acme.dev/release-card' },
component: ReleaseCardPartComponent,
}];
// ReleaseCardPartComponent injects TNG_AI_MESSAGE_PART_CONTEXT.Accessibility
- Keep the transcript navigable as ordinary document content; do not force it into a live region.
- Announce concise run-state changes in a separate polite status region, not every streamed token.
- Keep focus in the composer after submit and preserve focus when virtualized rows are recycled.
- Expose stop, retry, feedback, and approval actions as named native buttons.
- Make tool approvals explicit, reversible where possible, and fully keyboard operable.
- Respect reduced motion, forced colors, zoom, large text, and right-to-left layouts.
Security defaults
- Sanitize Markdown output; never bind model text directly as trusted HTML.
- Allowlist URL protocols before rendering source, file, or citation links.
- Require an explicit user action before approving a tool call.
- Render unsupported and extension payloads as data, not executable templates.
- Apply byte, depth, entry, attachment, and tool-input limits at the boundary.
Sanitize rendered Markdown
ts
// Keep transport data as text until it passes your rendering policy.
const html = markdownToHtml(textPart.text);
const safeHtml = sanitize(html);
// Bind only safeHtml in the presentation layer.