{"id":19728467,"url":"https://github.com/vizeat/storybook-addon-responsive-views","last_synced_at":"2025-06-18T03:32:32.669Z","repository":{"id":34933244,"uuid":"180763068","full_name":"vizeat/storybook-addon-responsive-views","owner":"vizeat","description":"View your Storybook stories in a range of responsive viewports","archived":false,"fork":false,"pushed_at":"2022-03-02T14:35:37.000Z","size":465,"stargazers_count":41,"open_issues_count":3,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-07T09:07:32.495Z","etag":null,"topics":[],"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/vizeat.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-04-11T09:49:48.000Z","updated_at":"2025-02-05T02:06:53.000Z","dependencies_parsed_at":"2022-08-08T03:00:48.066Z","dependency_job_id":null,"html_url":"https://github.com/vizeat/storybook-addon-responsive-views","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/vizeat/storybook-addon-responsive-views","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vizeat%2Fstorybook-addon-responsive-views","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vizeat%2Fstorybook-addon-responsive-views/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vizeat%2Fstorybook-addon-responsive-views/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vizeat%2Fstorybook-addon-responsive-views/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vizeat","download_url":"https://codeload.github.com/vizeat/storybook-addon-responsive-views/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vizeat%2Fstorybook-addon-responsive-views/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260481693,"owners_count":23015779,"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":[],"created_at":"2024-11-12T00:01:26.909Z","updated_at":"2025-06-18T03:32:27.654Z","avatar_url":"https://github.com/vizeat.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# storybook-addon-responsive-views\nView your Storybook stories in a range of responsive viewports\n\nWhen developing responsive applications, it's often the edges of breakpoints which cause the most issues. This Storybook addon lets you preview your components/stories at a variety of breakpoints, so that you can be sure that your webapp will look great no matter what screen size ✨\n\n![Screenshot of 'Responsive Views' Storybook addon](https://github.com/vizeat/storybook-addon-responsive-views/blob/master/docs/viewport.png)\n\n**Compatibility:** currently this addon works with React only. You can voice support for Angular and other frameworks in [#6](https://github.com/vizeat/storybook-addon-responsive-views/issues/6), or even better: send a PR adding support for it.\n\n\n## Installation\nInstall the following npm module\n\n```\nyarn add storybook-addon-responsive-views\n```\n\n## Basic usage\n\n`withResponsiveViews` is added as a decorator to your stories.\n\nFirst, register the addon in `addons.js`. This gives you access to toggle the views on/off in the Storybook toolbar.\n\n```js\nimport 'storybook-addon-responsive-views/register'\n```\n\nThen you can either add it globally to all stories, or to a story individually\n\n```js\n// Globally in .storybook/config.js\nimport { addDecorator } from '@storybook/react'\nimport { withResponsiveViews } from 'storybook-addon-responsive-views'\n\naddDecorator(withResponsiveViews)\n```\n\nor\n\n```js\n// In a .story file\nimport { withResponsiveViews } from 'storybook-addon-responsive-views'\n\nstoriesOf('Component', module)\n  .addDecorator(withResponsiveViews)\n  .add(...)\n```\n\n## Breakpoint config\n\nBy default, there are two breakpoints set: tablet at 768px, and desktop at 1024px. For each breakpoint, `withResponsiveViews` will create a view at 1px below the breakpoint and the breakpoint itself, as well as a 320px minimum view.\n\nTo set your own breakpoints, pass an object to the `withResponsiveViews` decorator. This can be done both on the global or local level by passing in a breakpoints object. You can add as many breakpoints as you like, with any key name you want. The key name is used in the view title. An example:\n\n```js\naddDecorator(\n  withResponsiveViews({\n    mobile: 425,\n    tablet: 750,\n    desktop: 1000,\n    large: 1200,  \n  })\n)\n```\n\n## Responsive views\n\nYour responsive views will appear beneath your story component, so that you can see how it looks at various sizes. To toggle the views on/off, use the Responsive Views toggle in the Storybook toolbar\n\n## Accessing document and window\n\nEach responsive view is rendered within an iFrame. To access the `document` and `window` properties for each iFrame, you'll need to import context into your story, and pass the document/window as a prop. For example:\n\n```js\nimport { ResponsiveViewContextConsumer } from 'storybook-addon-responsive-views'\n\nstoriesOf('Component', module)\n  .add(\n    'MediaQuery',\n      () =\u003e {\n        return (\n          \u003cResponsiveViewContextConsumer\u003e\n            {({ document, window }) =\u003e \u003cComponent window={window} /\u003e}\n          \u003c/ResponsiveViewContextConsumer\u003e\n        )\n      }\n    )\n  )\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvizeat%2Fstorybook-addon-responsive-views","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvizeat%2Fstorybook-addon-responsive-views","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvizeat%2Fstorybook-addon-responsive-views/lists"}