{"id":28383723,"url":"https://github.com/pierrecapo/react-native-theme-style","last_synced_at":"2026-03-15T08:11:32.240Z","repository":{"id":34892987,"uuid":"187710173","full_name":"PierreCapo/react-native-theme-style","owner":"PierreCapo","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-03T22:18:36.000Z","size":1238,"stargazers_count":5,"open_issues_count":15,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-06T07:24:57.506Z","etag":null,"topics":["react-native","theming"],"latest_commit_sha":null,"homepage":null,"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/PierreCapo.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-05-20T20:40:00.000Z","updated_at":"2020-03-08T00:24:18.000Z","dependencies_parsed_at":"2023-01-15T10:15:24.292Z","dependency_job_id":null,"html_url":"https://github.com/PierreCapo/react-native-theme-style","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PierreCapo/react-native-theme-style","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreCapo%2Freact-native-theme-style","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreCapo%2Freact-native-theme-style/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreCapo%2Freact-native-theme-style/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreCapo%2Freact-native-theme-style/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PierreCapo","download_url":"https://codeload.github.com/PierreCapo/react-native-theme-style/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreCapo%2Freact-native-theme-style/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261891641,"owners_count":23225761,"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":["react-native","theming"],"created_at":"2025-05-30T07:11:58.265Z","updated_at":"2026-03-15T08:11:32.202Z","avatar_url":"https://github.com/PierreCapo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-theme-style\n\n## The problem\n\nYou want to:\n\n- Apply styles to your react-native component according to a theme\n- not use styled-components because of various reasons (Jest/Flow/etc issues)\n- have a fully typed theme (Flow and Typescript support)\n- A lightweight solution which is plain React and use the power of Hooks and context\n\nWelcome to react-native-theme-style.\n\n## Usage\n\nYou must have **React-Native 0.59+** installed\n\n1. Install\n\n```bash\nyarn add react-native-theme-style\n```\n\n2. Create your theme context\n\n```jsx\n// ./src/theme.jsx\n\nimport * as React from \"react\";\nimport { configureTheme } from \"react-native-theme-style\";\n\nconst defaultTheme = { color: \"red\" };\nexport const ThemeContext = React.createContext(defaultTheme);\n\nexport const useTheme = configureTheme(ThemeContext);\n```\n\n3. Wrap your app within the theme context\n\n```jsx\n//./App.jsx\n// ... imports going here\nimport {ThemeContext} from \"./src/theme\";\n\n//... App class going here\nrender() {\n    return (\n    \u003cThemeContext.Provider\u003e\n      \u003cApp /\u003e\n    \u003c/ThemeContext.Provider\u003e\n    );\n}\n```\n\nAnd then in your **functional components** (on class components it won't work because of hooks running behind the hood) you can do:\n\n```jsx\n// ./src/Foo.component.jsx\nimport { Text, View } from \"react-native\";\nimport { useTheme } from \"./theme\";\n\nexport const Foo = () =\u003e {\n  const stylings = useTheme(styles);\n  return (\n    \u003cView\u003e\n      \u003cText style={stylings.bar}\u003eHello React native\u003c/Text\u003e\n      \u003cText style={stylings.foo}\u003eHello Theme\u003c/Text\u003e\n    \u003c/View\u003e\n  );\n};\n\nconst styles = {\n  bar: {\n    color: \"yellow\"\n  },\n  foo: theme =\u003e ({\n    color: theme.color\n  })\n};\n```\n\nOptionally, if you want to evaluate the styles according to some value, you can pass a second parameter to useTheme:\n\n```jsx\n// ./src/Foo.component.jsx\nimport { Text, View } from \"react-native\";\nimport { useTheme } from \"./theme\";\n\nexport const Foo = () =\u003e {\n  const stylings = useTheme(styles, { isActive: true });\n  return (\n    \u003cView\u003e\n      \u003cText style={stylings.bar}\u003eHello React native\u003c/Text\u003e\n      \u003cText style={stylings.foo}\u003eHello Theme\u003c/Text\u003e\n    \u003c/View\u003e\n  );\n};\n\nconst styles = {\n  bar: {\n    color: \"yellow\"\n  },\n  foo: (theme, params) =\u003e ({\n    color: params.isActive ? theme.color : \"brown\"\n  })\n};\n```\n\n## Typescript/flow\n\n```tsx\n// ./src/theme.tsx\n\nimport * as React from \"react\";\nimport { configureTheme, ThemeStyle } from \"react-native-theme-style\";\n\nconst defaultTheme = { color: \"red\" };\nconst ThemeContext = React.useContext(defaultTheme);\n\nexport const useTheme = configureTheme(ThemeContext);\n\n// Typings support\nexport type ThemeType\u003cT\u003e = ThemeStyle\u003c{ color: string }, T\u003e;\n```\n\nand then:\n\n```tsx\n// ./src/Foo.component.jsx\nimport { Text, View } from \"react-native\";\nimport { useTheme, ThemeType } from \"./theme\";\n\nexport const Foo = () =\u003e {\n  const stylings = useTheme(styles, { isActive: true });\n  return (\n    \u003cView\u003e\n      \u003cText style={stylings.bar}\u003eHello React native\u003c/Text\u003e\n      \u003cText style={stylings.foo}\u003eHello Theme\u003c/Text\u003e\n    \u003c/View\u003e\n  );\n};\n\nconst styles: ThemeType\u003c{ isActive: boolean }\u003e = {\n  bar: {\n    color: \"yellow\"\n  },\n  foo: (theme, params) =\u003e ({\n    color: params.isActive ? theme.color : \"brown\"\n  })\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierrecapo%2Freact-native-theme-style","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpierrecapo%2Freact-native-theme-style","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierrecapo%2Freact-native-theme-style/lists"}