{"id":15606505,"url":"https://github.com/gobeli/css-var-theme","last_synced_at":"2026-01-20T00:07:31.696Z","repository":{"id":42855817,"uuid":"260680536","full_name":"gobeli/css-var-theme","owner":"gobeli","description":"small, dependency-free utility to enable efficient theming with css variables.","archived":false,"fork":false,"pushed_at":"2023-01-06T04:48:50.000Z","size":1198,"stargazers_count":1,"open_issues_count":14,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-06T22:43:00.119Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://gobeli.github.io/css-var-theme/","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/gobeli.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}},"created_at":"2020-05-02T12:17:19.000Z","updated_at":"2020-12-30T15:25:34.000Z","dependencies_parsed_at":"2023-02-05T08:46:27.958Z","dependency_job_id":null,"html_url":"https://github.com/gobeli/css-var-theme","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gobeli/css-var-theme","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobeli%2Fcss-var-theme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobeli%2Fcss-var-theme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobeli%2Fcss-var-theme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobeli%2Fcss-var-theme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gobeli","download_url":"https://codeload.github.com/gobeli/css-var-theme/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobeli%2Fcss-var-theme/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28590676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T00:01:37.455Z","status":"ssl_error","status_checked_at":"2026-01-19T23:58:17.328Z","response_time":67,"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":[],"created_at":"2024-10-03T04:40:34.529Z","updated_at":"2026-01-20T00:07:31.682Z","avatar_url":"https://github.com/gobeli.png","language":"TypeScript","readme":"# css-var-theme\n\n![build](https://github.com/gobeli/css-var-theme/workflows/build/badge.svg)\n\nA small, dependency-free utility to enable efficient theming with css variables.\n\n[Repo](https://github.com/gobeli/css-var-theme) /\n[Demo](https://gobeli.github.io/css-var-theme/) /\n[npm](https://www.npmjs.com/package/css-var-theme)\n\n## Installation\n\n`npm i css-var-theme`\n\n## Usage\n\nA theme is basically a JS object implementing the `Theme` interface:\n\n```ts\nexport interface Theme {\n  meta?: object\n  theme: object\n}\n```\n\nIt contains optional `meta` information (like a name) and the actual `theme` which can be any JS object.\n\nOnce a theme is defined the `css-var-theme` utility can be initialized with it:\n\n```ts\nimport { useTheme } from 'css-var-theme'\n\nconst my_theme = {\n  meta: {\n    name: 'my theme',\n  },\n  theme: {\n    color: {\n      background: '#eee',\n      text: '#333',\n    },\n  },\n}\n\nconst theme_store = useTheme({ initial: my_theme })\n```\n\nDuring initialization a `\u003cstyle\u003e`-Tag is added to the head which will map this theme to the following css-variables:\n\n```css\n:root {\n  --color-background: #eee;\n  --color-text: #333;\n}\n```\n\nwith `theme_store.set(new_theme)` the current theme can be changed and `theme_store.subscribe(() =\u003e ...)` you can subscribe to updates on the theme.\n\n## API\n\nThe `useTheme` function consumes an object implementing the `ThemingOptions` interface:\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eParameter\u003c/th\u003e\n      \u003cth\u003eType\u003c/th\u003e\n      \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003einitial\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eTheme\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eInitial theme to be used.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003edark?\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eTheme\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        Optional, overrides the initial theme if user prefers darkmode.\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003elight?\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eTheme\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        Optional, overrides the initial theme if user prefers lightmode.\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eid?\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        Optional, id of the style element used to set the css variables.\n        Will be generated if not set.\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobeli%2Fcss-var-theme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgobeli%2Fcss-var-theme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobeli%2Fcss-var-theme/lists"}