Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createShadowRootUi styles not taking effect in shadow DOM (wxt + naive-ui) #1536

Open
5 tasks done
shijunpeng15 opened this issue Mar 27, 2025 · 1 comment
Open
5 tasks done
Labels
pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug

Comments

@shijunpeng15
Copy link

Describe the bug

I'm using the wxt framework and naive-ui's createShadowRootUi method to create a shadow DOM interface, but the styles aren't taking effect.
naive-ui inline styles not applying in Shadow DOM via createShadowRootUi (wxt)

// App.vue
<template>
  <NConfigProvider>
    <NMessageProvider>
      <NDialogProvider>
        <NNotificationProvider>
          <NButton type="info"> Info </NButton>
        </NNotificationProvider>
      </NDialogProvider>
    </NMessageProvider>
  </NConfigProvider>
</template>
<script lang="ts" setup>
import {
  NButton,
  NConfigProvider,
  NDialogProvider,
  NMessageProvider,
  NNotificationProvider,
} from 'naive-ui';
</script>

<style scoped></style>

// content.ts
import { createApp } from 'vue';
import { createShadowRootUi } from 'wxt/client';
import { defineContentScript } from 'wxt/sandbox';
import App from '../contentui/goods/App.vue';
import '../contentui/goods/content.css';  // content.css is empty

export default defineContentScript({
  matches: ['<all_urls>'],
  cssInjectionMode: 'ui',
  async main(ctx) {
    const ui = await createShadowRootUi(ctx, {
      name: 'naive-ui-container',
      position: 'inline',
      anchor: 'body',
      onMount: (container) => {
        const app = createApp(App);
        app.mount(container);
        return app;
      },
      onRemove: (app) => {
        app?.unmount();
      },
    });
    ui.mount();
  },
});


Reproduction

..

Steps to reproduce

No response

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13600K
    Memory: 16.99 GB / 31.75 GB
  Binaries:
    Node: 23.10.0 - ~\AppData\Roaming\fnm\aliases\default\node.EXE
    npm: 10.9.2 - ~\AppData\Roaming\fnm\aliases\default\npm.CMD
    pnpm: 10.6.5 - ~\AppData\Roaming\fnm\aliases\default\pnpm.CMD
  Browsers:
    Edge: Chromium (128.0.2739.67)
    Internet Explorer: 11.0.26100.1882

Used Package Manager

pnpm

Validations

@shijunpeng15 shijunpeng15 added the pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug label Mar 27, 2025
@aklinker1
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug
Projects
None yet
Development

No branches or pull requests

2 participants