question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to set <body> classes?

See original GitHub issue

Hello! Is there way to set <body> (inside <iframe>) class(es)? (except using finddomnode) Thank you

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

16reactions
vidal7commented, Jan 18, 2019

Creating a file named preview-head.html in your config directory containing this seems to have worked out for me.

<script>setTimeout(function () { document.body.classList.add("yourClass"); }, 0);</script>

Check the documentation here : https://storybook.js.org/configurations/add-custom-head-tags/

8reactions
LiranBricommented, Dec 14, 2018

you can add file config.js to .storybook dir with something likes this:

import { configure } from '@storybook/react'

function loadStories () {
  document.body.className += ' ' + 'hasHover'
}

configure(loadStories, module)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add a class to body tag? - jquery - Stack Overflow
This should do it: var newClass = window.location.href; newClass = newClass.substring(newClass.lastIndexOf('/')+1, 5); $('body').
Read more >
body_class() | Function - WordPress Developer Resources
This function gives the body element different classes and can be added, typically, in the header.php's HTML body tag. ... The following example...
Read more >
Adding to the Body Class in WordPress - Web Design TutsPlus
The body class in WordPress is a class or series of classes that are applied to the HTML body element. This is useful...
Read more >
HTML body class Attribute - Dofactory
The class attribute assigns one or more classnames to the <body> tag. Classnames are defined in a stylesheet or in a local <style>...
Read more >
Add a class to the Body element using JavaScript | bobbyhadz
Add a class to the Body element using JavaScript #. Use the classList.add() method to add a class to the body element, e.g....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found