Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-mq-store

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-mq-store

📱 Create any media-query store in Svelte

  • 2.2.17
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

svelte-mq-store

npm-version npm-license npm-download-month npm-min-size ci.yml website

📱 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

Keywords

FAQs

Package last updated on 19 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc