{"id":18903547,"url":"https://github.com/elchininet/home-assistant-styles-manager","last_synced_at":"2026-04-02T18:27:58.540Z","repository":{"id":261466375,"uuid":"884394486","full_name":"elchininet/home-assistant-styles-manager","owner":"elchininet","description":"Manage Home Assistant styles per DOM elements","archived":false,"fork":false,"pushed_at":"2026-03-22T20:44:14.000Z","size":895,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-23T12:39:00.545Z","etag":null,"topics":["css","home-assistant","javascript-library","library","shadow-dom","shadow-root","styles"],"latest_commit_sha":null,"homepage":"","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/elchininet.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"elchininet"}},"created_at":"2024-11-06T17:09:06.000Z","updated_at":"2026-03-22T20:44:16.000Z","dependencies_parsed_at":"2025-02-23T18:29:59.395Z","dependency_job_id":"fd356714-2fd2-474a-ace6-71dc80099062","html_url":"https://github.com/elchininet/home-assistant-styles-manager","commit_stats":null,"previous_names":["elchininet/home-assistant-styles-manager"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/elchininet/home-assistant-styles-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elchininet%2Fhome-assistant-styles-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elchininet%2Fhome-assistant-styles-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elchininet%2Fhome-assistant-styles-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elchininet%2Fhome-assistant-styles-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elchininet","download_url":"https://codeload.github.com/elchininet/home-assistant-styles-manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elchininet%2Fhome-assistant-styles-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31312871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["css","home-assistant","javascript-library","library","shadow-dom","shadow-root","styles"],"created_at":"2024-11-08T09:05:31.097Z","updated_at":"2026-04-02T18:27:58.518Z","avatar_url":"https://github.com/elchininet.png","language":"TypeScript","funding_links":["https://github.com/sponsors/elchininet"],"categories":[],"sub_categories":[],"readme":"# home-assistant-styles-manager\n\nManage Home Assistant styles per DOM elements\n\n[![Deployment Status](https://github.com/elchininet/home-assistant-styles-manager/actions/workflows/deploy.yaml/badge.svg)](https://github.com/elchininet/home-assistant-styles-manager/actions/workflows/deploy.yaml)\n[![Tests](https://github.com/elchininet/home-assistant-styles-manager/actions/workflows/tests.yaml/badge.svg)](https://github.com/elchininet/home-assistant-styles-manager/actions/workflows/tests.yaml)\n[![Coverage Status](https://coveralls.io/repos/github/elchininet/home-assistant-styles-manager/badge.svg?branch=master)](https://coveralls.io/github/elchininet/home-assistant-styles-manager?branch=master)\n[![npm version](https://badge.fury.io/js/home-assistant-styles-manager.svg)](https://badge.fury.io/js/home-assistant-styles-manager)\n[![downloads](https://img.shields.io/npm/dw/home-assistant-styles-manager)](https://www.npmjs.com/package/home-assistant-styles-manager)\n\n## Install\n\n#### npm\n\n```bash\nnpm install home-assistant-styles-manager\n```\n\n#### yarn\n\n```bash\nyarn add home-assistant-styles-manager\n```\n\n#### PNPM\n\n```bash\npnpm add home-assistant-styles-manager\n```\n\n## API\n\n### Class instantiation\n\nThe `HomeAssistantStylesManager` class can be instantiated sending an optional options object.\n\n```typescript\nnew HomeAssistantStylesManager([options])\n```\n\n#### Options object\n\n| Parameter      | Optional      | Default                         | Description                                         |\n| -------------- | ------------- | ------------------------------- | --------------------------------------------------- |\n| prefix         | yes           | `ha-styles-manager`             | prefix that will be used for the styles ids         |\n| namespace      | yes           | `home-assistant-styles-manager` | namespace that will be used for the warnings        |\n| throwWarnings  | yes           | true                            | indicates if the library should throw warnings      |\n\n### Public methods\n\n#### getStyleElement\n\nGiven an `HTMLElement` or a `ShadowRoot` element, returns the style element associated with it.\n\n```typescript\ngetStyleElement(root: HTMLElement | ShadowRoot): HTMLStyleElement | null\n```\n\n#### addStyle\n\nGiven a CSS string or a CSS object and an `HTMLElement` or a `ShadowRoot` element, it adds a style element containing the CSS string or replace its content with the CSS string if it already exists.\n\n```typescript\naddStyle(\n  css: string | CSSInJs | (string | CSSInJs)[],\n  root: HTMLElement | ShadowRoot\n): void\n```\n\nThe `css` property can be a CSS string but also a CSS-in-JS object or an array of CSS-in-JS objects and strings. Any rule with a `false` value will get hidden.\n\nFor eaxample, the next CSS-in-JS object:\n\n```javascript\n{\n  '.some-rule': {\n    backgroundColor: 'red',\n    SomeVariable: '10px'\n  },\n  '.hide-rule': false,\n  '@supports (display: flex)': {\n    '@media screen and (width \u003e= 900px)': {\n      'nested-rule': {\n        SomeVariable: '20px',\n        display: 'flex'\n      }\n    }\n  }\n}\n```\n\nWill be compiled to:\n\n```css\n.some-rule {\n  background-color: red;\n  --some-variable: 10px\n}\n.hide-rule {\n  display: none !important\n}\n@supports (display: flex) {\n  @media screen and (width \u003e= 900px) {\n    nested-rule {\n      --some-variable: 20px;\n      display: flex\n    }\n  }\n}\n```\n\n#### removeStyle\n\nGiven an `HTMLElement` or a `ShadowRoot` element, it removes the style element associated to it (if it exists).\n\n```typescript\nremoveStyle(root: HTMLElement | ShadowRoot): void\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felchininet%2Fhome-assistant-styles-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felchininet%2Fhome-assistant-styles-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felchininet%2Fhome-assistant-styles-manager/lists"}