I'm looking to apply specific themes to individual items on a page - a different theme to the rest of the page.

I realise this seems quite obscure, but the general premise is similar to a styleguide.

A themed page/site which describes the behaviour of a paragraph/block, with a rendered version of the paragraph/block, using a second theme - from a site where it's previously been used.

I know there are ways to set a theme per page (ThemeNegotiator) but I'm at a loss for where to begin with a component…

  • 2
    Conceptually that doesn't really make sense (in terms of Drupal's theme system I mean). I'd be surprised if you find anything that allows you to arbitrarily switch themes in the middle of a render pipeline. How are you planning to manage the inevitable CSS craziness when the styles from one theme are overriding the styles from another in an unpredictable way, for example?
    – Clive
    Nov 15, 2018 at 12:35
  • 1
    It feels like you'd be better off creating separate pages for these components, using the theme negotiator to swap the theme for those pages, exclude the headers/footers (just render the content), and iframe them into the other page
    – Clive
    Nov 15, 2018 at 12:39
  • 1
    Doesn’t really make sense outside of either iframing or providing CSS sheets per paragraph
    – Kevin
    Nov 15, 2018 at 12:52
  • I think you should think broader in your implementation. The goal, it seems, is to have a wildly different look based on a particular piece of content. I think that CSS does this natively with its selectors so a different, but related question might be how to apply different (dynamic? static?) selectors to your paragraph blocks so that a different look and feel can be applied to those. You can also add in an arbitrary library (css/js) for a given render array so that would help style it. And there is the styleguide module if you're looking for a styleguide.
    – mradcliffe
    Nov 15, 2018 at 14:59
  • Thanks for you thoughts guys, you've raised all the concerns I had. The idea of attaching a library (as per @mradcliffe) crossed my mind, but there would be the same issue of "inevitable CSS craziness" as @clive so nicely puts it. Nov 15, 2018 at 16:17


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.