Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"class-variance-authority": "0.7.1",
"clsx": "2.1.1",
"lucide-react": "1.11.0",
"tailwind-merge": "3.5.0"
"tailwind-merge": "3.5.0",
"tailwindcss-scoped-preflight": "^4.0.6"
},
"peerDependencies": {
"react": ">=18.0.0",
Expand Down
28 changes: 25 additions & 3 deletions packages/ui/src/styles.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
@import "tailwindcss";
/* Tailwind v4 imports, granular so we can scope preflight.
*
* The full `@import "tailwindcss";` shortcut pulls preflight in at the global
* scope, which uses universal selectors (`*, ::before, ::after`, `html`, `body`)
* that bleed onto any host page that loads the bundle. The
* `tailwindcss-scoped-preflight` plugin rewrites every preflight rule with a
* `[data-dg-agent]` ancestor, so the reset only applies to widget descendants.
*
* Theme tokens and utilities stay global so embedders building their own
* widget layouts with @deepgram/ui components continue to get class-based
* styling via Tailwind utilities.
*
* Do NOT add `@import "tailwindcss";` back. Granular imports + the plugin are
* the contract that keeps the host page untouched.
*/
@layer theme, base, components, utilities;
@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/utilities.css" layer(utilities);
@plugin "@tailwindcss/typography";
@plugin "tailwindcss-scoped-preflight" {
isolation-strategy: inside;
selector: [data-dg-agent];
}

/* Explicitly tell Tailwind v4 to scan component source files for class usage.
Without this, auto-detection may miss files in sibling repos / outside the project root. */
Expand Down Expand Up @@ -97,8 +118,9 @@
color-scheme: light;
}

/* Extended tokens without direct shadcn equivalents */
:root {
/* Extended tokens without direct shadcn equivalents.
* Scoped to [data-dg-agent] (not :root) so they do not leak to the host. */
[data-dg-agent] {
--primary-hover: color-mix(in srgb, var(--color-primary) 85%, #000);
--primary-active: color-mix(in srgb, var(--color-primary) 70%, #000);
--accent-active: #f3f4f6;
Expand Down