I would like to change CSS for different site areas and page layouts depending upon contextual information such as the user role or the type of content being displayed. The types of changes would include font, color, and background options. I can think of several ways to approach this, but could really benefit from the experiences of others.

Some options:

  • Use Views or panels to identify context and then associate styles with them. This is limited because some of the elements are not directly associated with content, such as menu background, colors, etc.
  • Create a custom module to identify the user, content type or other context criteria and then modify the render array. This sounds feasible, but the render array is pretty cryptic, and I'm not clear on what needs to change. IF you've tried this, what have you done.
  • Create custom code in a theme to identify the context and then assign div class values to isolate the affected sections.

If you have tried this or other options, what did you do and how effective was it?

1 Answer 1


We have been using the theme key module to switch between different styles and (sub-) themes for different situations.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.