JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 141
  • Score
    100M100P100Q92467F
  • License MIT

Media queries directly in your Marko templates.

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@marko-tags/match-media) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme


    @marko-tags/match-media
    API Stability NPM Version Downloads

    Media queries directly in your Marko templates.

    Note: version 1.0.0 of this module requires Marko >= 4.14.20 as it uses the new tag parameter syntax

    Installation

    npm install @marko-tags/match-media

    Example

    <match-media|{ mobile, tablet, desktop }|
      mobile="(max-width: 767px)"
      tablet="(min-width: 768px) and (max-width: 1024px)"
      desktop="(min-width: 1025px)"
    >
    
      <if(mobile)>
        <!-- Mobile version -->
      </if>
      <else-if(tablet)>
        <!-- Tablet version -->
      </else-if>
      <else-if(desktop)>
        <!-- Desktop version -->
      </else-if>
      <else>
        <!-- Handle server side render (no media queries match) -->
      </else>
    
    </match-media>

    Full media query support

    <match-media|{ portrait, landscape }|
      portrait="(orientation: portrait)"
      landscape="(orientation: landscape)"
    >
    
      <!-- Render based on portrait or landscape -->
    
    </match-media>