{"id":16787471,"url":"https://github.com/ben-rogerson/mezz","last_synced_at":"2025-07-29T21:43:11.016Z","repository":{"id":188051682,"uuid":"675994298","full_name":"ben-rogerson/mezz","owner":"ben-rogerson","description":"📐👁️ React hooks for building responsive and adaptable web interfaces","archived":false,"fork":false,"pushed_at":"2024-04-24T06:13:26.000Z","size":207,"stargazers_count":35,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-27T02:11:56.990Z","etag":null,"topics":["hooks","react","resizeobserver"],"latest_commit_sha":null,"homepage":"https://mezz.benrogerson.dev","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/ben-rogerson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-08-08T07:37:15.000Z","updated_at":"2025-01-23T14:20:34.000Z","dependencies_parsed_at":"2024-10-26T21:13:06.802Z","dependency_job_id":"4e6bac99-cc35-44ed-8199-be4f72357244","html_url":"https://github.com/ben-rogerson/mezz","commit_stats":null,"previous_names":["ben-rogerson/mezz"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-rogerson%2Fmezz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-rogerson%2Fmezz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-rogerson%2Fmezz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-rogerson%2Fmezz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ben-rogerson","download_url":"https://codeload.github.com/ben-rogerson/mezz/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243735818,"owners_count":20339535,"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","resizeobserver"],"created_at":"2024-10-13T08:15:01.978Z","updated_at":"2025-03-15T13:31:04.653Z","avatar_url":"https://github.com/ben-rogerson.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/benrogerson"],"categories":[],"sub_categories":[],"readme":"# Mezz\n\n[![npm](https://img.shields.io/npm/v/mezz?colorA=fdbe90\u0026colorB=fffaeb)](https://www.npmjs.com/package/mezz)\n[![downloads](https://img.shields.io/npm/dm/mezz?colorA=fdbe90\u0026colorB=fffaeb)](https://www.npmjs.com/package/mezz)\n[![minzip package size](https://img.shields.io/bundlephobia/minzip/mezz?label=minzip%20size\u0026colorA=fdbe90\u0026colorB=fffaeb)](https://bundlephobia.com/package/mezz)\n\n📐 Mezz is a set of React hooks for building responsive and adaptable web interfaces.\n\nThe hooks observe the size of elements and match the breakpoints you supply — simple, type-safe, and fast.\n\n\u003cp\u003e\u003cimg src=\"./.github/preview-usewidth.png\" width=\"650\" alt=\"Typesafe completions screenshot\" /\u003e\u003c/p\u003e\n\n- 💪 Type-safe breakpoint auto-completions\n- ✨ Uses the modern [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) browser API\n- ⚡️ Customizable breakpoint naming\n- 🌐 Works in all modern browsers\n\n[👉 **Demos and examples \u0026rsaquo;**](https://mezz.benrogerson.dev/)\n\n## Install\n\n```shell\npnpm install mezz\n```\n\n## Use\n\nThe **useWidth** hook:\n\n```tsx\nimport { useWidth } from 'mezz'\n\nfunction BlueBox() {\n  const width = useWidth({ lg: 500 })\n  return \u003cdiv ref={width.ref}\u003e{width.lg ? 'Large' : 'Small'}\u003c/div\u003e\n}\n```\n\nThe **useWidthHeight** hook:\n\n```tsx\nimport { useWidthHeight } from 'mezz'\n\nfunction GreenBox() {\n  const size = useWidthHeight({\n    width: { sm: 0, md: 400, lg: 500 },\n    height: { lg: 950 },\n  })\n\n  return (\n    \u003cdiv ref={size.ref}\u003e\n      {size.width.sm \u0026\u0026 'Small'}\n      {size.width.md \u0026\u0026 'Medium'}\n      {size.width.lg \u0026\u0026 'Large'}\n      {size.height.lg \u0026\u0026 'Larger height'}\n    \u003c/div\u003e\n  )\n}\n```\n\nThe **useBodyWidth** hook:\n\n```tsx\nimport { useBodyWidth } from 'mezz'\n\nfunction App() {\n  const body = useBodyWidth({ lg: 500 })\n  return body.lg ? 'Large' : 'Small'\n}\n```\n\n[👉 **More demos and examples \u0026rsaquo;**](https://mezz.benrogerson.dev/)\n\n---\n\n[Consider donating some 🍕 if you enjoy!](https://www.buymeacoffee.com/benrogerson)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fben-rogerson%2Fmezz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fben-rogerson%2Fmezz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fben-rogerson%2Fmezz/lists"}