{"id":13810511,"url":"https://github.com/fedorovvvv/svelte-media-queries","last_synced_at":"2025-10-25T00:30:28.228Z","repository":{"id":37037327,"uuid":"503860619","full_name":"fedorovvvv/svelte-media-queries","owner":"fedorovvvv","description":"A ✨light✨ and magical Svelte component for CSS media queries🐹","archived":false,"fork":false,"pushed_at":"2023-10-13T16:19:27.000Z","size":274,"stargazers_count":37,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-29T11:58:53.995Z","etag":null,"topics":["css","css-media","css-media-queries","media","media-query","queries","query","svelte","svelte-component","svelte-v3","svelte3","sveltejs"],"latest_commit_sha":null,"homepage":"https://svelte.dev/repl/7e97f1a1d1654701a0661e076037d160?version=3.48.0","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/fedorovvvv.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-06-15T17:24:37.000Z","updated_at":"2024-09-23T16:45:19.000Z","dependencies_parsed_at":"2024-01-15T13:33:40.693Z","dependency_job_id":null,"html_url":"https://github.com/fedorovvvv/svelte-media-queries","commit_stats":{"total_commits":94,"total_committers":3,"mean_commits":"31.333333333333332","dds":"0.46808510638297873","last_synced_commit":"6ca729c2b6a67363e5251bcdf09d09dd9b9b7cb7"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fedorovvvv%2Fsvelte-media-queries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fedorovvvv%2Fsvelte-media-queries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fedorovvvv%2Fsvelte-media-queries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fedorovvvv%2Fsvelte-media-queries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fedorovvvv","download_url":"https://codeload.github.com/fedorovvvv/svelte-media-queries/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219867388,"owners_count":16555891,"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":["css","css-media","css-media-queries","media","media-query","queries","query","svelte","svelte-component","svelte-v3","svelte3","sveltejs"],"created_at":"2024-08-04T02:00:57.293Z","updated_at":"2025-10-25T00:30:27.931Z","avatar_url":"https://github.com/fedorovvvv.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Svelte CSS media queries 🐥 \n\n[![npm version](http://img.shields.io/npm/v/svelte-media-queries.svg)](https://www.npmjs.com/package/svelte-media-queries)\n[![npm downloads](https://img.shields.io/npm/dm/svelte-media-queries.svg)](https://www.npmjs.com/package/svelte-media-queries)\n![license](https://img.shields.io/npm/l/svelte-media-queries)\n\n### [Demo - Svelte REPL](https://svelte.dev/repl/7e97f1a1d1654701a0661e076037d160?version=3.48.0)\n### Lightweight, comfortable, like Svelte🐣 | Svelte store / Svelte component\nWith TypeScript support💙  \n\n[![Rate this package](https://badges.openbase.com/js/rating/svelte-media-queries.svg?style=openbase\u0026token=myaBaR9V2YuM2LLiUs0nOTMlrXb1fGC6F9XuQa3Y0sw=)](https://openbase.com/js/svelte-media-queries?utm_source=embedded\u0026amp;utm_medium=badge\u0026amp;utm_campaign=rate-badge)\n\n## how to install\n```npm\nnpm i svelte-media-queries\n```\n### What can I do?\n\n```js\nquery = {\n  \"mobile\": \"(max-width: 480px)\",\n  \"tablet\": \"(min-width: 480px) and (max-width: 768px)\",\n  \"largeTablet\": \"(min-width: 768px) and (max-width: 1200px)\",\n  \"desktop\": \"(min-width: 1200px)\",\n  \"other\": [\n    \"(min-width: 1200px)\",\n    \"(max-height: 900px)\"\n  ],\n  \"themes\": {\n    \"dark\": \"(prefers-color-scheme: dark)\",\n    \"light\": \"(prefers-color-scheme: light)\"\n  }\n} // \n```\n```js\nmatches = {\n  \"mobile\": false,\n  \"tablet\": true,\n  \"largeTablet\": false,\n  \"desktop\": false,\n  \"other\": [\n    false,\n    true\n  ],\n  \"themes\": {\n    \"dark\": false,\n    \"light\": true\n  }\n}\n```\n\u003cimg src=\"https://media.giphy.com/media/oYtVHSxngR3lC/giphy-tumblr.gif\" width=\"350\"/\u003e\n\nYes, yes, and it's all recursive and reactive🐹  \nTry it in [Svelte REPL](https://svelte.dev/repl/7e97f1a1d1654701a0661e076037d160?version=3.48.0)  \n\n## How to use\n\n### Query? Yes, just like in CSS🙊\n```js\nquery='(min-width: 768px) and (max-width: 1280px)'\n```\n### Matches? This is your result\n#### Component (`bind:` directive)\n```\nbind:matches\n------------------\nbind:matches={foo}\n```\n#### Slot (`let:` directive)\n```\nlet:matches\n------------------\nlet:matches={foo}\n```\n### Examples\n#### Store\n```js\n\u003cscript\u003e\n  import { onDestroy } from 'svelte'\n  import { createMediaStore } from 'svelte-media-queries'\n  \n  const matches = createMediaStore(query) //The type of the store will completely repeat the query\n  \n  onDestroy(() =\u003e matches.destroy()) //Stop events for calculation\n\u003c/script\u003e\n```\n[query example](https://github.com/fedorovvvv/svelte-media-queries#what-can-i-do)\n#### Slot\n```svelte\n\u003cscript\u003e\n  import MediaQuery from 'svelte-media-queries'\n\u003c/script\u003e\n\n\u003cMediaQuery query='(max-width: 480px)' let:matches\u003e\n  {#if matches}\n    mobile!!\n  {/if}\n\u003c/MediaQuery\u003e\n```\n#### Bind\n```svelte\n\u003cscript\u003e\n  import MediaQuery from 'svelte-media-queries'\n\n  let matches\n\u003c/script\u003e\n\n\u003cMediaQuery query='(max-width: 480px)' bind:matches/\u003e\n\n{#if matches}\n  mobile!!\n{/if}\n\n{#if matches}\n  Oh my God, it's really mobile\n{/if}\n```\n\n### That's not all!\n#### You can use an array from `query`\n```js\nquery={['(max-width: 1200px)', '(min-width: 800px)']}\n```\nWhat about matches?  \nMatches will take everything from `query` in order  \n```js\nmatches=[boolean, boolean]\n```\n#### You can test this in [Svelte REPL](https://svelte.dev/repl/7e97f1a1d1654701a0661e076037d160?version=3.48.0)🐥\n#### Example\n```svelte\n\u003cscript\u003e\n  import MediaQuery from 'svelte-media-queries'\n\u003c/script\u003e\n\n\u003cMediaQuery query={['(max-width: 768px)', '(min-width: 768px) and (max-width: 1280px)', '(min-width: 1280px)']} let:matches\u003e\n  {@const [mobile, tablet, desktop] = matches}\n  \u003ch5\u003e\n    mobile: '(max-width: 768px)' = {mobile}\n    tablet: '(max-width: 1280px)' = {tablet}\n    desktop: '(min-width: 1280px)' = {desktop}\n  \u003c/h5\u003e\n\u003c/MediaQuery\u003e\n```\n`{@const}` - [Svelte Docs](https://svelte.dev/docs#template-syntax-const)🐹  \nYou can also use it through the array index `tablet = matches[1]`  \nWith `bind:`, everything is the same🐥\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffedorovvvv%2Fsvelte-media-queries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffedorovvvv%2Fsvelte-media-queries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffedorovvvv%2Fsvelte-media-queries/lists"}