{"id":46896823,"url":"https://github.com/joslarson/remedia","last_synced_at":"2026-03-10T23:32:44.561Z","repository":{"id":43704939,"uuid":"279767159","full_name":"joslarson/remedia","owner":"joslarson","description":"A remedy for media queries in React \u0026 CSS-in-JS","archived":false,"fork":false,"pushed_at":"2024-03-24T06:05:23.000Z","size":854,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-02T06:13:55.005Z","etag":null,"topics":["media-queries","react","typescript"],"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/joslarson.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":"2020-07-15T04:52:08.000Z","updated_at":"2023-03-16T06:54:47.000Z","dependencies_parsed_at":"2022-09-12T02:30:17.002Z","dependency_job_id":null,"html_url":"https://github.com/joslarson/remedia","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/joslarson/remedia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joslarson%2Fremedia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joslarson%2Fremedia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joslarson%2Fremedia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joslarson%2Fremedia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joslarson","download_url":"https://codeload.github.com/joslarson/remedia/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joslarson%2Fremedia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30362120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"ssl_error","status_checked_at":"2026-03-10T21:40:59.357Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["media-queries","react","typescript"],"created_at":"2026-03-10T23:32:44.437Z","updated_at":"2026-03-10T23:32:44.544Z","avatar_url":"https://github.com/joslarson.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Remedia\n\nA remedy for media queries in React.\n\nRemedia provides an API for Media Queries that treats JavaScript and React as a first class citizens with CSS. Rather than being defined as strings, Media Queries are defined as `MediaQuery` objects that can later be combined to make new Media Queries or who's values can be referenced in other contexts.\n\nRemedia is written in TypeScript providing a type safe API and a great developer experience. It makes use of generics and literal types to make it easy to inspect a query's underlying data just by looking at its type information:\n\n![type information](https://github.com/joslarson/remedia/raw/master/docs/type-information.png)\n\n## Installation\n\n```\nnpm install remedia\n```\n\n## Usage\n\n### 1. Create a `MediaQuery` instance\n\n```js\nimport remedia from 'remedia';\n\nconst phoneLargeMin = remedia({ minWidth: 321 });\n```\n\n### 2. Use a `MediaQuery` in CSS\n\n```ts\nconst style = css`\n  font-size: 12px;\n\n  @media ${phoneLargeMin} {\n    font-size: 16px;\n  }\n`;\n```\n\n\u003e `MediaQuery` instances become actual media query strings when they are interpolated, which calls the `toString()` method underneath\n\n### 3. Subscribe to a `MediaQuery` in React with the `use` method hook\n\n```tsx\nconst MyComponent: React.FC = () =\u003e {\n  // `use` method defaults to false\n  const matchesPhoneLargeMin = phoneLargeMin.use()\n  // but you can pass true to default to true\n  const matchesPhoneLargeMax = phoneLargeMin.use(true)\n  ...\n}\n```\n\n### 4. Build new queries from existing ones\n\n```tsx\nconst tabletLandscapeMin = remedia({ minWidth: 769 });\nconst tabletLandscapeMax = remedia({ maxWidth: 1024 });\n\nconst tabletLandscapeRange = remedia({\n  ...tabletLandscapeMin,\n  ...tabletLandscapeMax,\n});\n```\n\n### 5. \"OR\" multiple queries together\n\nIf you need to **OR** multiple queries together, just pass multiple queries into remedia.\n\n```tsx\n/* small phone portrait: *-320 */\nexport const phoneSmallMax = remedia({ maxWidth: 320 });\n\n/* tablet portrait: 569–768 */\nexport const tabletMin = remedia({ minWidth: 569 });\nexport const tabletMax = remedia({ maxWidth: 768 });\n\n// compound query using OR and built from previous queries: 0-114 or 569-768\nexport const narrowMainContent = remedia(phoneSmallMax, {\n  ...tabletMax,\n  ...tabletMin,\n});\n```\n\n## Prior art and attribution\n\nIn the process of building this library I was inspired by and borrowed ideas \u0026 code from [@jaredpalmer](https://github.com/jaredpalmer)'s [`useMedia`](https://github.com/jaredpalmer/the-platform/blob/master/src/useMedia.tsx) hook.\n\nThis library also includes a forked and modified version of the great [`json2mq`](https://github.com/akiran/json2mq) library by [@kiran](https://github.com/akiran).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoslarson%2Fremedia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoslarson%2Fremedia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoslarson%2Fremedia/lists"}