Get user theme directly in lightning component

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












In lightning, is there a way / global event that we can directly get user ui themeDisplayed without calling an apex method.










share|improve this question





























    up vote
    1
    down vote

    favorite












    In lightning, is there a way / global event that we can directly get user ui themeDisplayed without calling an apex method.










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      In lightning, is there a way / global event that we can directly get user ui themeDisplayed without calling an apex method.










      share|improve this question















      In lightning, is there a way / global event that we can directly get user ui themeDisplayed without calling an apex method.







      lightning-components






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 34 mins ago









      Robs

      1,110424




      1,110424










      asked 2 hours ago









      Pino Cao

      61




      61




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote













          As of today (and as far as I know of), there's no direct way of getting the UI Theme in a Lightning Component without implementing a server side controller.



          The Salesforce Developers Blog on the topic Introducing UI Theme Detection for Lightning Experience mentions this, excerpt below:




          You can’t determine the user’s UI theme directly within a Lightning Component because it only has access to a limited set of global values. You must implement an Apex server-side controller to provide this information.







          share|improve this answer



























            up vote
            1
            down vote













            I wouldn't recommend it, but you could look through the DOM for the data-aura-rendered-by property.



            document.querySelectorAll('[data-aura-rendered-by]');


            If you find it, you're in Lightning Experience.



            There's no guarantee this won't change, so...be ready for your code to break!



            I would always use an Apex controller instead, caching the response to lighten the load.



            String theme = UserInfo.getUiThemeDisplayed();


            More info, including working sample code here:



            https://developer.salesforce.com/blogs/isv/2016/04/introducing-ui-theme-detection-for-lightning-experience.html






            share|improve this answer






















              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "459"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f234395%2fget-user-theme-directly-in-lightning-component%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              3
              down vote













              As of today (and as far as I know of), there's no direct way of getting the UI Theme in a Lightning Component without implementing a server side controller.



              The Salesforce Developers Blog on the topic Introducing UI Theme Detection for Lightning Experience mentions this, excerpt below:




              You can’t determine the user’s UI theme directly within a Lightning Component because it only has access to a limited set of global values. You must implement an Apex server-side controller to provide this information.







              share|improve this answer
























                up vote
                3
                down vote













                As of today (and as far as I know of), there's no direct way of getting the UI Theme in a Lightning Component without implementing a server side controller.



                The Salesforce Developers Blog on the topic Introducing UI Theme Detection for Lightning Experience mentions this, excerpt below:




                You can’t determine the user’s UI theme directly within a Lightning Component because it only has access to a limited set of global values. You must implement an Apex server-side controller to provide this information.







                share|improve this answer






















                  up vote
                  3
                  down vote










                  up vote
                  3
                  down vote









                  As of today (and as far as I know of), there's no direct way of getting the UI Theme in a Lightning Component without implementing a server side controller.



                  The Salesforce Developers Blog on the topic Introducing UI Theme Detection for Lightning Experience mentions this, excerpt below:




                  You can’t determine the user’s UI theme directly within a Lightning Component because it only has access to a limited set of global values. You must implement an Apex server-side controller to provide this information.







                  share|improve this answer












                  As of today (and as far as I know of), there's no direct way of getting the UI Theme in a Lightning Component without implementing a server side controller.



                  The Salesforce Developers Blog on the topic Introducing UI Theme Detection for Lightning Experience mentions this, excerpt below:




                  You can’t determine the user’s UI theme directly within a Lightning Component because it only has access to a limited set of global values. You must implement an Apex server-side controller to provide this information.








                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  Jayant Das

                  6,9352320




                  6,9352320






















                      up vote
                      1
                      down vote













                      I wouldn't recommend it, but you could look through the DOM for the data-aura-rendered-by property.



                      document.querySelectorAll('[data-aura-rendered-by]');


                      If you find it, you're in Lightning Experience.



                      There's no guarantee this won't change, so...be ready for your code to break!



                      I would always use an Apex controller instead, caching the response to lighten the load.



                      String theme = UserInfo.getUiThemeDisplayed();


                      More info, including working sample code here:



                      https://developer.salesforce.com/blogs/isv/2016/04/introducing-ui-theme-detection-for-lightning-experience.html






                      share|improve this answer


























                        up vote
                        1
                        down vote













                        I wouldn't recommend it, but you could look through the DOM for the data-aura-rendered-by property.



                        document.querySelectorAll('[data-aura-rendered-by]');


                        If you find it, you're in Lightning Experience.



                        There's no guarantee this won't change, so...be ready for your code to break!



                        I would always use an Apex controller instead, caching the response to lighten the load.



                        String theme = UserInfo.getUiThemeDisplayed();


                        More info, including working sample code here:



                        https://developer.salesforce.com/blogs/isv/2016/04/introducing-ui-theme-detection-for-lightning-experience.html






                        share|improve this answer
























                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          I wouldn't recommend it, but you could look through the DOM for the data-aura-rendered-by property.



                          document.querySelectorAll('[data-aura-rendered-by]');


                          If you find it, you're in Lightning Experience.



                          There's no guarantee this won't change, so...be ready for your code to break!



                          I would always use an Apex controller instead, caching the response to lighten the load.



                          String theme = UserInfo.getUiThemeDisplayed();


                          More info, including working sample code here:



                          https://developer.salesforce.com/blogs/isv/2016/04/introducing-ui-theme-detection-for-lightning-experience.html






                          share|improve this answer














                          I wouldn't recommend it, but you could look through the DOM for the data-aura-rendered-by property.



                          document.querySelectorAll('[data-aura-rendered-by]');


                          If you find it, you're in Lightning Experience.



                          There's no guarantee this won't change, so...be ready for your code to break!



                          I would always use an Apex controller instead, caching the response to lighten the load.



                          String theme = UserInfo.getUiThemeDisplayed();


                          More info, including working sample code here:



                          https://developer.salesforce.com/blogs/isv/2016/04/introducing-ui-theme-detection-for-lightning-experience.html







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 2 mins ago

























                          answered 39 mins ago









                          Shane Steinfeld

                          1,122418




                          1,122418



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f234395%2fget-user-theme-directly-in-lightning-component%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Comments

                              Popular posts from this blog

                              Long meetings (6-7 hours a day): Being “babysat” by supervisor

                              Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                              Confectionery