2.2.14 ā€¢ Published 12 days ago

svelte-mq-store v2.2.14

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

svelte-mq-store

šŸ“± Create any media-query store in Svelte

Demo

Installation

npm i svelte-mq-store

Usage

Use the listen to subscribe to the contents of any media query.

<script>
  import { listen } from 'svelte-mq-store'

  const isDark = listen('(prefers-color-scheme: dark)')
</script>

{#if $isDark}
  Device is dark mode
{:else}
  Device is light mode
{/if}

Fallback in Server

Media queries are available only in the browser.
The fallback value used by the server during SSR can be specified as the second argument. (default is undefined).

import { listen } from 'svelte-mq-store'

const isDark = listen(
  '(prefers-color-scheme: dark)',
  false // fallback value
)

License

MIT

2.2.14

12 days ago

2.2.13

23 days ago

2.2.12

1 month ago

2.2.11

1 month ago

2.2.10

2 months ago

2.2.9

2 months ago

2.2.8

3 months ago

2.2.7

3 months ago

2.2.6

3 months ago

2.2.5

4 months ago

2.2.4

4 months ago

2.2.3

4 months ago

2.2.2

5 months ago

2.2.1

5 months ago

2.2.0

5 months ago

2.1.1

5 months ago

2.1.0

5 months ago

2.0.0

5 months ago

1.0.0

6 months ago

0.0.1

6 months ago