{"id":50686854,"url":"https://github.com/alextompkins/vite-plugin-shadow-styles","last_synced_at":"2026-06-08T23:37:07.413Z","repository":{"id":315489895,"uuid":"1059723873","full_name":"alextompkins/vite-plugin-shadow-styles","owner":"alextompkins","description":"A Vite plugin that provides some handy utilities to inject styles into a shadow root.","archived":false,"fork":false,"pushed_at":"2026-04-24T09:19:41.000Z","size":91,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-08T23:37:06.248Z","etag":null,"topics":["custom-elements","shadow-dom","stylesheets","vite"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vite-plugin-shadow-styles","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alextompkins.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-18T21:11:00.000Z","updated_at":"2026-04-24T09:19:46.000Z","dependencies_parsed_at":"2025-09-18T23:50:23.588Z","dependency_job_id":"83582738-a3b4-4242-8378-69be5b81790a","html_url":"https://github.com/alextompkins/vite-plugin-shadow-styles","commit_stats":null,"previous_names":["alextompkins/vite-plugin-shadow-styles"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/alextompkins/vite-plugin-shadow-styles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextompkins%2Fvite-plugin-shadow-styles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextompkins%2Fvite-plugin-shadow-styles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextompkins%2Fvite-plugin-shadow-styles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextompkins%2Fvite-plugin-shadow-styles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alextompkins","download_url":"https://codeload.github.com/alextompkins/vite-plugin-shadow-styles/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextompkins%2Fvite-plugin-shadow-styles/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34085321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-elements","shadow-dom","stylesheets","vite"],"created_at":"2026-06-08T23:37:06.760Z","updated_at":"2026-06-08T23:37:07.409Z","avatar_url":"https://github.com/alextompkins.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `vite-plugin-shadow-styles`\n\nA plugin that provides some handy utilities to inject styles into a shadow root.\n\n## Usage\n\nFirst, include the plugin in your Vite config:\n\n```typescript\nimport type { defineConfig, UserConfig } from 'vite';\nimport { shadowStylesPlugin } from 'vite-plugin-shadow-styles';\n\nexport default defineConfig(async ({ command, mode }) =\u003e ({\n  build: {\n    // must be false, since all CSS files are concatenated into the virtual styles\n    cssCodeSplit: false,\n  },\n  plugins: [shadowStylesPlugin(command, mode)],\n}));\n```\n\nIf using Typescript, you'll also need to include the virtual module types. Make a file called `shadow-styles.d.ts` and include the following:\n\n```ts\n/// \u003creference types=\"vite-plugin-shadow-styles/virtual\" /\u003e\n```\n\n---\n\nThen, choose one of these methods:\n\n### `stylesheets`\n\n```typescript\nimport { stylesheets } from 'virtual:shadow-styles/stylesheets';\n\nconst webComponent = document.querySelector('my-web-component');\nwebComponent.shadowRoot.adoptedStyleSheets = stylesheets;\n```\n\nOn HMR, the contents of `stylesheets` will be mutated to reflect the style tags in `\u003chead\u003e`.\n\n### `injectCss`\n\n```typescript\nimport { injectCss } from 'virtual:shadow-styles/inject';\n\nconst webComponent = document.querySelector('my-web-component');\ninjectCss(webComponent.shadowRoot);\n```\n\nOn HMR, style tags will be copied from `\u003chead\u003e` into the shadow root.\n\n### `styles`\n\n```typescript\nimport { css } from 'virtual:shadow-styles/styles';\n\nconst styleTag = document.createElement('style');\nstyleTag.innerHTML = css;\n\nconst webComponent = document.querySelector('my-web-component');\nwebComponent.shadowRoot.appendChild(styleTag);\n```\n\nNote: `css` will _not_ update on HMR using this method.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falextompkins%2Fvite-plugin-shadow-styles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falextompkins%2Fvite-plugin-shadow-styles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falextompkins%2Fvite-plugin-shadow-styles/lists"}