Theming PrimeNG with alternative styling approaches.
The term unstyled is used to define an alternative styling approach instead of the default theming with design tokens. In unstyled mode the css variables of the design tokens and the css rule sets that utilize them are not included. Here is an example of an Unstyled Select, the core functionality and accessibility is provided whereas styling is not included.
Unstyled mode is enabled for the whole suite by enabling unstyled option during PrimeNG installation.
Alternatively even in the default styled mode, a particular component can still be used as unstyled by adding the unstyled prop of the component.
Unstyled components require styling using your preferred approach. We recommend using Tailwind CSS with PassThrough attributes, a combination that works seamlessly together. The tailwindcss-primeui even provides special variants such as p-outlined:, p-vertical for the PrimeNG components.
The example below demonstrates how to style a toggleswitch component with Tailwind CSS using PassThrough attributes. Before you begin, refer to the pass through section in the toggleswitch documentation to familiarize yourself with the component's internal structure and PassThrough attributes. In this example, we'll target the root, slider and handle elements to craft an amber square variant.
A global configuration can be created at application level to avoid repetition via the global pt option so that the styles can be shared from a single location. A particular component can still override a global configuration with its own pt property.