Theme
LightSwitch

Automatically sets a light or dark theme based on the OS settings. Put it in your template like:

<pe:lightSwitch selected="\#{userBean.theme}"/>

userBean should be a session scoped bean with a String type theme property (with both getter and setter). Then set the theme in your web.xml like:

<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>\#{userBean.theme}</param-value>
</context-param>

This showcase uses the LightSwitch component.

See also the PrimeFaces themes documentation.

OmniFaces CombinedResourceHandler

With combined resources, we cannot find the theme link in the DOM tree. Therefor we need to add a node for the new theme.
Important: this node will be added as the last element in the body. If you added a custom style sheet with overrides, make sure to use more specific rules. Equal rules will be overruled by the switched theme.

Components and more
Documentation pe:lightSwitch
Attributes (move mouse over the names to see data types)
Name Description
id Unique identifier of the component in a namingContainer.
rendered Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding An el expression referring to a server side UIComponent instance in a backing bean.
widgetVar Name of the client side widget.
selected Selected theme. Should point to a value in a session scoped bean which you should also use as the context param 'primefaces.THEME'.
light Light theme. Default 'saga'.
dark Dark theme. Default 'arya'.
automatic Flag indicating to switch to the theme based on the OS setting automatically. Default true.
Events (move mouse over the names to see classes)
Name Description
switchfires on switch
PrimeFaces Extensions Showcase - © 2011-2021,PrimeFaces: 10.0.0,PrimeFaces Extensions: 10.0.5,JSF: Apache MyFaces JSF-2.3 Core API 2.3.9,Server: jetty/9.4.36.v20210114,Build time: 2021-08-28 16:46
occured!