Seitu - Type-Safe Utilities
Web

Media Query

createMediaQuery()

Creates a handle for a media query.

Examples

Vanilla

media-query.ts
import {  } from 'seitu/web'
import {  } from 'seitu/react'

const  = ({ : '(min-width: 768px)' })

// Usage with subscribe
.( => {
  .()
})

const  = .()
.()

React

page.tsx
import {  } from 'seitu/web'
import {  } from 'seitu/react'

const  = ({ : '(min-width: 768px)' })

// Usage with some function component
function () {
  const  = ()
  return  ? 'i am desktop' : 'i am mobile'
}

Errors

import {  } from 'seitu/web'
import {  } from 'seitu/react'

({ query: '(min-width: ' })
Type '"(min-width: "' is not assignable to type '`(min-width: ${number}px)` | `(min-width: ${number}em)` | `(min-width: ${number}rem)` | `(min-width: ${number}vw)` | `(min-width: ${number}vh)` | `(min-width: ${number}dvw)` | `(min-width: ${number}dvh)` | `(min-width: ${number}svw)` | `(min-width: ${number}svh)` | `(min-width: ${number}lvw)` | `(min-width: ${number...'.
({ query: '(min-width: 768' })
Type '"(min-width: 768"' is not assignable to type '"(min-width: 768px)" | "(min-width: 768em)" | "(min-width: 768rem)" | "(min-width: 768vw)" | "(min-width: 768vh)" | "(min-width: 768dvw)" | "(min-width: 768dvh)" | "(min-width: 768svw)" | ... 11 more ... | "(min-width: 768pc)"'. Did you mean '"(min-width: 768px)"'?

On this page