{"id":15693645,"url":"https://github.com/chanced/schemable-svelte","last_synced_at":"2025-07-16T08:11:55.515Z","repository":{"id":65493344,"uuid":"415481722","full_name":"chanced/schemable-svelte","owner":"chanced","description":"svelte action for class decoration derived from media queries or user preferences.","archived":false,"fork":false,"pushed_at":"2021-10-11T19:32:33.000Z","size":64,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-10T12:14:21.624Z","etag":null,"topics":["dark-mode","light-mode","media-queries","scheme","svelte"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chanced.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-10T04:04:24.000Z","updated_at":"2024-03-23T03:00:26.000Z","dependencies_parsed_at":"2023-01-26T02:32:05.415Z","dependency_job_id":null,"html_url":"https://github.com/chanced/schemable-svelte","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chanced/schemable-svelte","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanced%2Fschemable-svelte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanced%2Fschemable-svelte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanced%2Fschemable-svelte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanced%2Fschemable-svelte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chanced","download_url":"https://codeload.github.com/chanced/schemable-svelte/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanced%2Fschemable-svelte/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265495603,"owners_count":23776648,"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":["dark-mode","light-mode","media-queries","scheme","svelte"],"created_at":"2024-10-03T18:46:52.018Z","updated_at":"2025-07-16T08:11:55.460Z","avatar_url":"https://github.com/chanced.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# schemable-svelte\n\nSvelte action which sets the class of an element based, reactively, on either\nthe media feature `prefers-color-scheme` or a provided preference.\n\n-   No dependencies beyond svelte\n-   SSR ready, packaged with svelte kit\n\n```bash\npnpm add -D schemable-svelte\n# npm install -D schemable-svelte\n# yarn add -D schemable-svelte\n```\n\n## Usage\n\n```html\n\u003cscript\u003e\n\timport { schemable } from \"schemable-svelte\";\n\u003c/script\u003e\n\n\u003csvelte:body use:schemable /\u003e\n```\n\nUpon first initialization, scheamble creates a store which fetches the value of\n`prefers-color-scheme` and sets it in context. The store wires up event\nlisteners for changes to the media query. If preference is not provided, the\nvalue of `prefers-color-scheme` is used to lookup the class to assign to the\n`Element` with the action (likely `\u003csvelte:body\u003e`).\n\nIf a value for preference is passed to the option, it is considered an override\nand promoted to the new value. `preference` can either be a `string` or a\nreadable store.\n\nIf the value of `preference` is a `string`, a new store is created that persists\nthe value to localstorage.\n\nThe media query store is available as `mediaSchemeStore`. If the `localStorage`\nvariant is utilized, it is avaiable as`schemePreferenceStore`.\n\n### Options\n\n| Option          | Description                                                                                            |\n| :-------------- | :----------------------------------------------------------------------------------------------------- |\n| `preference`    | Overrides `prefers-color-scheme`. This can either be a value or a readable store.                      |\n| `defaultScheme` | Default value to utilize if `prefers-color-scheme` does not have a value and `preferences` is not set. |\n| `dark`          | class to use for dark schemes. Defaults to `\"dark\"`                                                    |\n| `light`         | class to use for light schemes. Defaults to `\"light\"`                                                  |\n\n### Events\n\n| Event                        | Description                                                                                                             |         `detail` |\n| :--------------------------- | :---------------------------------------------------------------------------------------------------------------------- | ---------------: |\n| `\"preferscolorschemechange\"` | the value of `prefers-color-scheme` has changed.                                                                        |         `string` |\n| `\"colorschemechange\"`        | the color scheme has changed, either through the provided `preference` or from the media feature `prefers-color-scheme` | `string \\| null` |\n\n## Contributing\n\nPull requests are always welcome.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanced%2Fschemable-svelte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanced%2Fschemable-svelte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanced%2Fschemable-svelte/lists"}