From bd47f88bd48c7123bd5b2abb1d21a1fcea72828b Mon Sep 17 00:00:00 2001 From: lukeocodes Date: Thu, 7 May 2026 09:41:19 +0100 Subject: [PATCH] fix(ui): namespace tailwind utilities under dg: prefix to stop host-page collisions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 0.1.1 release scoped Tailwind preflight to [data-dg-agent] via tailwindcss-scoped-preflight, but utility classes (.flex, .prose, .container, .max-w-none, .gap-2, .px-3, .text-sm, .border, etc) and component classes from the typography plugin (.prose) still ship unprefixed. When the bundle loads on a host page that also uses Tailwind, the bundle's class rules win on source order and visibly break host layout. The most common symptom is .prose snapping content to max-width: 65ch the moment the widget mounts. Switching to `@import "tailwindcss" prefix(dg)` namespaces every generated class under a dg: variant, so .flex becomes .dg\:flex, .prose becomes .dg\:prose, .max-w-none becomes .dg\:max-w-none, and so on. Class names in this package's components are updated to match (class="dg:flex dg:items-center" rather than class="flex items-center"). The scoped preflight plugin keeps doing its job for the universal selector reset. After this change the bundle ships: - 0 unprefixed Tailwind utility class rules (was 42 collisions with Fern docs alone, more with arbitrary host pages) - 353 prefixed .dg\: utility rules - 76 scoped :where([data-dg-agent], …) preflight rules - 33 .dg-* custom component classes (unchanged) Bundle size: 167.5 KB -> 188.9 KB (+21 KB) from the additional generated CSS now that Tailwind sees the prefixed class usages and emits rules for them. Previously these classes were silently dropped because they weren't matching the prefix-less convention. Refs: - https://tailwindcss.com/docs/styling-with-utility-classes#using-a-prefix - deepgram/agent#48 (the scoped preflight 0.1.1 work that this completes) - deepgram/dx-stack#4 (will gain a "scoping utilities, not just preflight" gotcha) --- .../ui/src/components/AgentConversation.tsx | 24 +++++++-------- .../src/components/AgentMicrophoneButton.tsx | 10 +++---- .../ui/src/components/AgentSpeakerButton.tsx | 10 +++---- .../ui/src/components/AgentStartButton.tsx | 4 +-- packages/ui/src/components/AgentStatus.tsx | 2 +- packages/ui/src/components/AgentTextInput.tsx | 8 ++--- packages/ui/src/components/MicSelector.tsx | 2 +- packages/ui/src/components/Response.tsx | 6 ++-- packages/ui/src/components/VoiceButton.tsx | 26 ++++++++-------- packages/ui/src/components/ui/button.tsx | 22 +++++++------- packages/ui/src/components/ui/scroll-area.tsx | 12 ++++---- packages/ui/src/components/ui/select.tsx | 30 +++++++++---------- packages/ui/src/components/ui/textarea.tsx | 2 +- packages/ui/src/components/ui/toggle.tsx | 12 ++++---- packages/ui/src/styles.css | 28 +++++++++-------- 15 files changed, 100 insertions(+), 98 deletions(-) diff --git a/packages/ui/src/components/AgentConversation.tsx b/packages/ui/src/components/AgentConversation.tsx index d162fad..d2b3380 100644 --- a/packages/ui/src/components/AgentConversation.tsx +++ b/packages/ui/src/components/AgentConversation.tsx @@ -26,13 +26,13 @@ export function AgentConversation({ return (
-
+
{children} @@ -67,28 +67,28 @@ export function AgentMessage({
{/* Role label */} {showRole && ( - + {isUser ? "You" : "Agent"} )} {/* Avatar + bubble */}
{/* Gradient avatar — assistant only */} {!isUser && (