{"id":15069896,"url":"https://github.com/ryanmorr/scoped","last_synced_at":"2025-04-10T17:05:16.256Z","repository":{"id":43924679,"uuid":"284087484","full_name":"ryanmorr/scoped","owner":"ryanmorr","description":"Scoped CSS for DOM trees","archived":false,"fork":false,"pushed_at":"2025-02-20T01:42:01.000Z","size":255,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-24T14:46:17.532Z","etag":null,"topics":["css","javascript","scoped-css"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanmorr.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}},"created_at":"2020-07-31T17:00:42.000Z","updated_at":"2024-11-17T17:15:36.000Z","dependencies_parsed_at":"2025-02-17T16:46:40.821Z","dependency_job_id":null,"html_url":"https://github.com/ryanmorr/scoped","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanmorr%2Fscoped","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanmorr%2Fscoped/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanmorr%2Fscoped/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanmorr%2Fscoped/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanmorr","download_url":"https://codeload.github.com/ryanmorr/scoped/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247856543,"owners_count":21007621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["css","javascript","scoped-css"],"created_at":"2024-09-25T01:45:24.693Z","updated_at":"2025-04-10T17:05:16.237Z","avatar_url":"https://github.com/ryanmorr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scoped\n\n[![Version Badge][version-image]][project-url]\n[![License][license-image]][license-url]\n[![Build Status][build-image]][build-url]\n\n\u003e Scoped CSS for DOM trees\n\n## Install\n\nDownload the [CJS](https://github.com/ryanmorr/scoped/raw/master/dist/cjs/scoped.js), [ESM](https://github.com/ryanmorr/scoped/raw/master/dist/esm/scoped.js), [UMD](https://github.com/ryanmorr/scoped/raw/master/dist/umd/scoped.js) versions or install via NPM:\n\n```sh\nnpm install @ryanmorr/scoped\n```\n\n## Usage\n\nImport the library:\n\n```javascript\nimport scoped from '@ryanmorr/scoped';\n```\n\nCreate a scoped stylesheet by providing the CSS as a string. The selectors of the CSS will be automatically converted to include a unique attribute. The styles can only take affect when an element also possesses that unique attribute. It returns a function that will apply the unique attribute to all elements of a DOM tree:\n\n```javascript\nconst applyStyles = scoped(`\n    .foo {\n        width: 100px;\n        height: 100px;\n    }\n\n    .bar {\n        width: 200px;\n        height: 200px;\n    }\n`);\n\napplyStyles(element);\n```\n\nYou can provide the unique attribute yourself via an optional second argument:\n\n```javascript\nconst applyStyles = scoped(`\n    div {\n        color: red;\n    }\n`, 'scoped');\n\napplyStyles(element);\nelement.hasAttribute('scoped'); //=\u003e true\n```\n\nIt supports all CSS selectors, properties, and at-rules, including keyframes and media queries:\n\n```javascript\nconst applyStyles = scoped(`\n    .foo {\n        background-color: red;\n        animation-name: slide-in 1s ease-in;\n    }\n\n    @keyframes slide-in {\n        from {\n            transform: translateX(0%);\n        }\n        to {\n            transform: translateX(100%);\n        }\n    }\n\n    @media screen and (max-width: 600px) {\n        .foo {\n            background-color: blue;\n        }\n    }\n`);\n```\n\n## License\n\nThis project is dedicated to the public domain as described by the [Unlicense](http://unlicense.org/).\n\n[project-url]: https://github.com/ryanmorr/scoped\n[version-image]: https://img.shields.io/github/package-json/v/ryanmorr/scoped?color=blue\u0026style=flat-square\n[build-url]: https://github.com/ryanmorr/scoped/actions\n[build-image]: https://img.shields.io/github/actions/workflow/status/ryanmorr/scoped/node.js.yml?style=flat-square\n[license-image]: https://img.shields.io/github/license/ryanmorr/scoped?color=blue\u0026style=flat-square\n[license-url]: UNLICENSE","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanmorr%2Fscoped","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanmorr%2Fscoped","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanmorr%2Fscoped/lists"}