{"id":17621237,"url":"https://github.com/dev-warner/svelte-theme-switcher","last_synced_at":"2025-07-04T08:38:14.308Z","repository":{"id":40287952,"uuid":"253537875","full_name":"dev-warner/svelte-theme-switcher","owner":"dev-warner","description":"Component and state for switching theme","archived":false,"fork":false,"pushed_at":"2023-01-05T18:40:05.000Z","size":2036,"stargazers_count":4,"open_issues_count":17,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-01T21:04:27.755Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/dev-warner.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-04-06T15:24:13.000Z","updated_at":"2023-09-12T09:17:08.000Z","dependencies_parsed_at":"2023-02-04T10:31:35.081Z","dependency_job_id":null,"html_url":"https://github.com/dev-warner/svelte-theme-switcher","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dev-warner/svelte-theme-switcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-warner%2Fsvelte-theme-switcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-warner%2Fsvelte-theme-switcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-warner%2Fsvelte-theme-switcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-warner%2Fsvelte-theme-switcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev-warner","download_url":"https://codeload.github.com/dev-warner/svelte-theme-switcher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-warner%2Fsvelte-theme-switcher/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263478546,"owners_count":23473021,"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":[],"created_at":"2024-10-22T20:12:00.276Z","updated_at":"2025-07-04T08:38:14.251Z","avatar_url":"https://github.com/dev-warner.png","language":"JavaScript","readme":"# Svelte Theme Switcher\n\n![Test](https://github.com/dev-warner/svelte-theme-switcher/workflows/Test/badge.svg)\n\nA happy little svelte theme switcher to brighten or maybe darken your day 🌞.\n\n- [demo](https://dev-warner.github.io/svelte-theme-switcher/)\n\n## Basic example\n\nApp.svelte\n\n```html\n\u003cscript\u003e\n  import ThemeSwitcher from \"svelte-theme-switcher\";\n\u003c/script\u003e\n\n\u003cstyle\u003e\n  :global(body) {\n    background: var(--background);\n    color: var(--text);\n    transition: 0.6s;\n  }\n\n  :global(.theme-light) {\n    --background: rgb(250, 252, 240);\n    --text: #222;\n  }\n  :global(.theme-dark) {\n    --background: #222;\n    --text: #fff;\n  }\n\u003c/style\u003e\n\n\u003cThemeSwitcher /\u003e\n```\n\n## Installation\n\n```bash\nnpm i svelte-theme-switcher\n```\n\n```\nyarn add svelte-theme-switcher\n```\n\n### Component props\n\n| Property   | default                          | type   | notes              |\n| ---------- | -------------------------------- | ------ | ------------------ |\n| height:    | 30px                             | string | must be a px value |\n| width:     | 60px                             | string |\n| transition | 0.6s                             | string |\n| background | `{ light: #ecf0f1, dark: #333 }` | object |\n\n### Example\n\n```js\n\u003cThemeSwitcher\n  options={{\n    height: \"30px\",\n    width: \"60px\",\n    transition: \"0.6s\",\n    background: {\n      light: \"#ecf0f1\",\n      dark: \"#333\",\n    },\n  }}\n/\u003e\n```\n\n### Accessing state\n\n```javascript\n\u003cscript\u003e\nimport { theme } from \"svelte-theme-switcher\";\n\u003c/script\u003e\n\n\u003ch1\u003e{$theme}\u003c/h1\u003e\n```\n\n## Web Components\n\nIn the head of your document add:\n\n```html\n\u003cscript src=\"https://unpkg.com/svelte-theme-switcher@0.0.11/dist/wc/index.js\" /\u003e\n\u003cstyle\u003e\n  body {\n    background: var(--background);\n    color: var(--text);\n    transition: 0.6s;\n  }\n\n  .theme-light {\n    --background: rgb(250, 252, 240);\n    --text: #222;\n  }\n  .theme-dark {\n    --background: #222;\n    --text: #fff;\n  }\n\u003c/style\u003e\n```\n\nthis ensure's there is no inital flicker\n\nYou can now add the web component to switch between themes.\n\n```html\n\u003ctheme-switcher\u003e\u003c/theme-switcher\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-warner%2Fsvelte-theme-switcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev-warner%2Fsvelte-theme-switcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-warner%2Fsvelte-theme-switcher/lists"}