{"id":27163799,"url":"https://github.com/preachjs/themes","last_synced_at":"2026-03-05T00:03:08.031Z","repository":{"id":284942872,"uuid":"956557080","full_name":"preachjs/themes","owner":"preachjs","description":"Simple, lightweight theme management for Preact applications","archived":false,"fork":false,"pushed_at":"2025-04-01T05:52:14.000Z","size":193,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-01T03:08:28.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://preachjs.github.io/themes/","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/preachjs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-28T13:05:12.000Z","updated_at":"2025-04-01T05:51:52.000Z","dependencies_parsed_at":"2025-03-28T14:31:06.938Z","dependency_job_id":"3c6026eb-1613-4b0c-8b5a-a22c0bbe05e4","html_url":"https://github.com/preachjs/themes","commit_stats":null,"previous_names":["preachjs/themes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/preachjs/themes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preachjs%2Fthemes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preachjs%2Fthemes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preachjs%2Fthemes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preachjs%2Fthemes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/preachjs","download_url":"https://codeload.github.com/preachjs/themes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preachjs%2Fthemes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30101688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T23:59:36.199Z","status":"ssl_error","status_checked_at":"2026-03-04T23:56:48.556Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":"2025-04-09T01:51:38.278Z","updated_at":"2026-03-05T00:03:07.984Z","avatar_url":"https://github.com/preachjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @preachjs/themes\n\n\u003e Simple, lightweight theme management for Preact applications\n\n[![NPM](https://img.shields.io/npm/v/@preachjs/themes.svg)](https://www.npmjs.com/package/@preachjs/themes)\n\n[Demo \u0026rarr;](https://preachjs.github.io/themes/)\n\n## Highlights\n\n- 📦 Tiny bundle size (~413B GZipped)\n- 🤌 Simple API\n- No FOUC (in cases where preact isn't loaded on network)\n- Based on [@dumbjs/persona](https://github.com/dumbjs/persona)\n\n## Install\n\n```sh\n# npm\nnpm install @preachjs/themes\n\n# yarn\nyarn add @preachjs/themes\n\n# pnpm\npnpm add @preachjs/themes\n```\n\n## Usage\n\n```jsx\nimport { ThemeProvider, useTheme } from '@preachjs/themes'\n\nconst Main = () =\u003e {\n  return (\n    \u003cThemeProvider\u003e\n      \u003cApp /\u003e\n    \u003c/ThemeProvider\u003e\n  )\n}\n\nconst App = () =\u003e {\n  const { theme, setTheme } = useTheme('system')\n\n  return (\n    \u003c\u003e\n      \u003cp\u003eCurrent Theme: {theme}\u003c/p\u003e\n      \u003cbutton\n        onClick={() =\u003e {\n          setTheme('light')\n        }}\n      \u003e\n        Light\n      \u003c/button\u003e\n      \u003cbutton\n        onClick={() =\u003e {\n          setTheme('dark')\n        }}\n      \u003e\n        Dark\n      \u003c/button\u003e\n      \u003cbutton\n        onClick={() =\u003e {\n          setTheme('system')\n        }}\n      \u003e\n        System\n      \u003c/button\u003e\n    \u003c/\u003e\n  )\n}\n```\n\n## Configuration\n\nThe `ThemeProvider` component accepts the following props:\n\n- `defaultTheme`: The initial theme to use (`'light'`, `'dark'`, or `'system'`).\n  Defaults to `'system'`.\n- `storageKey`: The key used to persist theme preference in localStorage.\n  Defaults to `'theme'`.\n\n```jsx\n\u003cThemeProvider defaultTheme=\"dark\" storageKey=\"my-app-theme\"\u003e\n  \u003cApp /\u003e\n\u003c/ThemeProvider\u003e\n```\n\n## Theme Options\n\nThree theme options are available:\n\n- `light`: Forces light theme\n- `dark`: Forces dark theme\n- `system`: Automatically switches between light and dark based on system\n  preferences\n\n## API Reference\n\n### useTheme(defaultTheme?: string)\n\nReact hook that provides theme management functionality.\n\nReturns:\n\n- `theme`: Current theme value (`'light'`, `'dark'`, or `'system'`)\n- `setTheme`: Function to update the theme\n\nExample:\n\n```jsx\nconst { theme, setTheme } = useTheme('system')\n```\n\n### ThemeProvider\n\nContext provider component that must wrap your application.\n\nProps:\n\n- `defaultTheme`: Initial theme (optional)\n- `storageKey`: localStorage key for persistence (optional)\n- `children`: React nodes\n\nExample:\n\n```jsx\n\u003cThemeProvider defaultTheme=\"system\"\u003e\n  \u003cApp /\u003e\n\u003c/ThemeProvider\u003e\n```\n\n### Advanced Usage\n\nFor Advanced use cases like multiple themes and different default states, you\ncan write your own context and use\n[@dumbjs/persona](https://github.com/dumbjs/persona) that abstracts the browser\nAPIs to make it simpler for you to use.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreachjs%2Fthemes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpreachjs%2Fthemes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreachjs%2Fthemes/lists"}