@oliver (Oliver) posted a new topic, subject "Breakpoints in templates: already there, somewhere?". It read:

   I would like to know wether it's possible to react to breakpoint changes in a template without having to rely on CSS classes but instead handling a breakpoint like a platform variable (breakpoints and platforms are - bare with me - interdependent?). Similar to what's in the docs already for CSS utilites: http://ionicframework.com/docs/theming/css-utilities/#setting-attributes-dynamically \- essentially allowing to change the view layout entirely based on the breakpoint dimensions, not just device platforms.
    
    The grid uses breakpoints based on css classes, but that's CSS only (as far as I understand) and I can't check for a breakpoint at runtime, can I? Is there already a function available that spits out the currently active breakpoint or something similar? Anyboy done that and got the shirt? 
    
    I want to explore the PWA aspects of Ionic 2++ and for that, it seems that it's almost impossible to get far without some sort of breakpoint implementation that can be used within templates.

@JeffreyChen (jeffrey) replied

    I am facing this problem, too.
    
    I want to change my grid align when the breakpoints is different.
    
    But don't know how to get the breakpoint status in TS file.

@mhartington (Mike Hartington) replied

    Hey folks!
    
    So for the example in the doc
    [code] 
        <div [attr.text-center]="isMD ? '' : null">I will be centered when isMD is true.</div>
        
    [/code]
    
    The class would look something like…
    [code] 
        class myClass {
        
          public isMD: boolean
          constructor(
            public platform: Platfrom
          ) {
            this.isMD = this.platform.is('android')
          }
        }
        
    [/code]

After which, @JeffreyChen (jeffrey) added

    Is it possible to do something like with ionic's api?
    [code] 
        this.platform.is('xl') // get screen width > 1200px
        this.platform.is('sm') // get screen width > 576px
        
    [/code]

After which, @mhartington (Mike Hartington) added

    Not with platform, since `is` pull from a pre-defined list of values.
    
    But you could do something like …
    [code] 
        if (window.matchMedia("(min-width: 400px)").matches) {
          /* the viewport is at least 400 pixels wide */
        } else {
          /* the viewport is less than 400 pixels wide */
        }
        
    [/code]


{'source': 'discourse', 'url': 'https://forum.ionicframework.com/t/breakpoints-in-templates-already-there-somewhere/95868', 'title': 'Breakpoints in templates: already there, somewhere?', 'views': 1374, 'has_accepted_answer': False, 'word_count': 315, 'like_count': 1, 'reply_count': 3, 'participant_count': 3, 'posts': 5, 'tags': '', 'author': '@oliver (Oliver)', 'participants': '@oliver (Oliver), @JeffreyChen (jeffrey), @mhartington (Mike Hartington)', 'image_url': [None], 'created_at': '2017-06-26T18:39:06.998Z', 'last_posted_at': '2017-10-05T13:40:26.984Z'}