{"id":19267771,"url":"https://github.com/jhta/react-use-theme","last_synced_at":"2026-05-06T01:31:11.413Z","repository":{"id":57347221,"uuid":"170151752","full_name":"jhta/react-use-theme","owner":"jhta","description":"React Hook for consume styled component `theme`","archived":false,"fork":false,"pushed_at":"2019-02-11T15:53:25.000Z","size":6,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-05T12:27:45.006Z","etag":null,"topics":["hooks","react","styled-components","styled-system"],"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/jhta.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":"2019-02-11T15:24:02.000Z","updated_at":"2019-11-27T14:30:04.000Z","dependencies_parsed_at":"2022-09-18T10:43:00.764Z","dependency_job_id":null,"html_url":"https://github.com/jhta/react-use-theme","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhta%2Freact-use-theme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhta%2Freact-use-theme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhta%2Freact-use-theme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhta%2Freact-use-theme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhta","download_url":"https://codeload.github.com/jhta/react-use-theme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240371735,"owners_count":19790888,"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":["hooks","react","styled-components","styled-system"],"created_at":"2024-11-09T20:14:01.787Z","updated_at":"2026-05-06T01:31:11.361Z","avatar_url":"https://github.com/jhta.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-use-theme\nReact Hook for consume Styled Component `theme`\n\n## Install\n\n`yarn add react-use-theme`\n\n## How to use it? \n\nGet any attribute from theme in React Components\n\n````jsx\n  const myColor = useTheme('colors.myColor')\n\n````\nExample\n\n````jsx\n\nimport React from 'react'\nimport styled, { ThemeProvider } from 'styled-components'\nimport useTheme from 'react-use-theme'\n\nconst theme = {\n  colors: {\n    myCustomColor: '#07c'\n  }\n}\n\n// You have to provide a Context theme\nconst App = () =\u003e {\n  return (\n    \u003cThemeProvider theme={theme}\u003e\n        \u003cMyComponent /\u003e\n    \u003c/ThemeProvider\u003e\n  )\n}\n\n// then you can access to theme with useTheme hook\nconst MyComponent = () =\u003e {\n  const titleColor = useTheme('colors.myCustomColor')\n  \n  // you can pass default values\n  const defaultColor = 'red'\n  const subtitleColor = useTheme('colors.anotherColor', defaultColor)\n  \n  return (\n    \u003cdiv\u003e\n      \u003cTitle color={titleColor}\u003eHello World\u003c/Title\u003e\n    \u003c/div\u003e\n  )\n\n}\n\nconst Title = styled.h1`\n  color: ${p =\u003e p.color};\n`\n\n\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhta%2Freact-use-theme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhta%2Freact-use-theme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhta%2Freact-use-theme/lists"}