Adding an offscreen content area with a toggle to a Genesis Theme

The latest Genesis Infinity Pro theme has a top right toggle icon which allows for some off screen content to come into prominence in the viewport, this can be great for lead capture, ecommerce, contact details etc

offscreen-content-genesis

Here is how you can add this to the Sample Theme, also should work ok in other Genesis themes too.

Basically you’ll need to add some snippets to functions.php, some CSS styles to style.css and add and enqueue a javascript file.

Add in OffScreen Content Functions

Here the scripts are being registered for the Ionicons and for the Javascript – offscreen.js

A widget area is being registered ‘offscreen-content’ which will appear in the Widgets area ready to add in whatever content you want – this will be the offscreen content that can be toggled.

The third function adds the markup only if the widget area is populated, you can also change the icons in here by adjusting the code, you don’t have to use Ioncions you can equally use fontawesome or dashicons.

Add in OffScreen CSS

Add in the offscreen content CSS in your themes style.css

Add in OffScreen Javascript

This is the javascript for which you will have to make a file in your theme’s /js folder called offscreen.js and add in the JS code.

That’s it, the code used is from Infinity Pro with a couple of tweaks, the usage works well in mobile as well as desktop.

Example Genesis Sample site

16 Comments

  1. Rahat Ali on May 23, 2021 at 3:18 pm

    I added categories list in offscreen widget and I want to close offcreen widget when we will clicked on category link or any link.

    please give some js or css snippet for this. Thank you.

  2. Tia on September 16, 2019 at 10:57 am

    Hi,

    Thank you for this tutorial.
    Is there a way to be able to also trigger the opening of this offscreen content from a button placed on the site?

  3. Umesh on January 13, 2018 at 7:47 am

    Nice Tutorial,
    Please also do for OffScreen Mobile Menu, like its in Business Pro Theme

  4. Jake Faulstich on October 16, 2017 at 1:12 am

    Hey Neil –

    After implementing this, I have the offscreen content working on the home page + blog pages, but the menu button doesn’t seem to be triggering on standard pages.

    I’ve tried to kill all custom CSS and extra code I have in functions.php and no dice.

    You can see the dev site at http://dev-jkf.ww-stage.com/ (p: seethework) and a page where the toggle isn’t working at http://dev-jkf.ww-stage.com/z_test/ (p: seethework).

    Using the Monochrome theme / WP & all plugins up to date.

    Any help is much appreciated!!

    • Neil Gowran on October 16, 2017 at 1:49 am

      I can see the offscreen on that page with the toggle working – maybe clear any caches

  5. Jake Faulstich on September 10, 2017 at 5:02 pm

    This is an awesome post! One of the better modern features in Genesis themes.

    Question – where would you add in text (like “Menu”) to have it appear to the right of the icon where all is clickable to load the overlay?

    (ex –> “[icon] Menu”

    Thanks!

    • Neil Gowran on September 10, 2017 at 10:37 pm

      You can add text in between the <i class="icon ion-toggle-filled"></i> and <i class="icon ion-toggle"></i> or after it and you’ll most probably need a bit of CSS to style the text.

      • Jake Faulstich on September 11, 2017 at 1:25 am

        Excellent, thank you! I’ll give that a try.

  6. Cathy Larkin on December 15, 2016 at 8:03 pm

    Sorry to seem naive – but can you give an example or a site where this is implemented. I don’t understand what type of content you would put there, and how would the average site visitor know it is there to trigger it? or is it where a pop up lives, after or before it is set to pop up., so someone can access it again?

    Thanks

    • Neil Gowran on December 15, 2016 at 11:01 pm

      There is a link in the post of an example site

  7. James Burgos on November 17, 2016 at 12:40 pm

    Hi there,

    Thanks for this. I’ve been trying to implement something like this for a while. I do have one question on a mod.

    I’d like to add genesis_header and genesis_footer to the offscreen overlay above and below the widget area when it’s clicked, but I’m not sure how to instantiate the hooks within the markup. How should I approach this?

    Any insights would be appreciated.

    • Neil Gowran on November 21, 2016 at 9:29 pm

      I don’t think this would be the best approach as the hooks have already loaded as it is one and the same page – the offscreen content is just initially hidden – so really best off to add additional content in a similar way, as in the widget area.

      • James Burgos on December 5, 2016 at 7:48 pm

        Thank you for replying. Let me rephrase. What I’m actually interested in doing is including my site title above and my footer information below. They don’t necessarily have to reside within their corresponding hooks, but that’s how I imagined it might work. It seems like the code I need could be injected around line 30 and again at line 35. What do you think?

  8. Paul on November 13, 2016 at 11:35 am

    Hi Neil,

    This is awesome. I have to do exactly this next week on a site. Very timely. However in my case the icon is to reveal hidden full screen nav.

    I wonder if I could ask your opinion… I am trying to be a bit more accessibility aware in the last few sites I made (yes… Late to the party, but recently I have made some efforts)…

    Anyway, my hidden offscreen content is main nav. So it’s kind of essential content.

    I saw you put the screen-reader-text class on the button for your hidden content, so I learned a bit there thanks.

    However, with my widget being essential content (nav), would you suggest that instead of using display none, that I use again the screen-reader-text class on the whole widget abd Aria hidden on the launch button?

    The key difference with my situation being my content is essential for navigating the site.

    Thanks again for yet another excellent tutorial.

    Cheers

    • Neil Gowran on November 13, 2016 at 9:35 pm

      Hi Paul, yes I would use some aria attributes on the toggle and screen-reader-text class above the nav

      • Paul Lacey on November 13, 2016 at 10:07 pm

        Oh thanks Neil. Much appreciated having your input on that! I’ll tweet you the result when done.
        Cheers, and have a nice week.
        Paul

Leave all Comment