+ Note: In upcoming versions, theming architecture will be redesigned to utilize CSS variables instead of SCSS variables in a backward compatible way for a dynamic approach. In addition, a new Unstyled mode + will be provided as an optional approach to replace default styling so that CSS libraries like Tailwind or Bootstrap can be used to style the components. This work is planned to be completed by the end of Q2 2023. +
- PrimeVue is a design agnostic library so unlike other UI libraries it does not enforce a certain styling such as material or bootstrap. In order to achieve this, styling has been separated into two parts, core and theme. Core resides - inside PrimeVue to implement the structure of the components such as positioning whereas theme brings the colors, paddings and margins. vVarious free themes and premium themes are available along with premium templates that provide an - application layout as well. All the free themes are built with the Theme Designer and the npm package brings the compiled CSS output of the theme whereas SCSS is kept as a premium - feature in the designer. + PrimeVue is a design agnostic library so unlike other UI libraries it does not enforce a certain styling such as material or bootstrap. In order to achieve this, styling has been separated into two parts, core and theme. The core resides + inside PrimeVue to implement the structure of the components such as positioning whereas theme brings the colors and spacing.
PrimeVue ships with various free themes to choose from. The list below states all the available themes in the npm distribution with import paths.
++ PrimeVue ships with various free themes to choose from. The list below states all the available themes in the npm distribution with import paths. For a live preview, use the configurator + at the topbar to switch themes. +
Each PrimeVue theme exports numerous CSS variables, refer to
+ Themes are created with SASS using the primevue-sass-theme project available at github. This repository contains all the scss files for the components and the variables + of the built-in themes so that you may customize an existing theme or create your own. The scss variables used in a theme are available at the SASS API documentation. +
++ There are 3 alternatives to create your own theme. First option is using the Visual Editor, second one is compiling a theme with command line sass and final alternative is embedding scss files within your project to let your build + environment do the compilation. In all cases, the generated theme file should be imported to your project. +
+ ++ Visual Editor is an easy way to quickly customize an existing theme without dealing with the details of the SASS API. The editor allows changing common settings like primary color for built-in + themes. Once you have completed the design, click the download button to access the generated theme.css file and import it to your project as an asset. In near future, an advanced UI Designer will be available with the ability to + edit all variables and components where you'll also be able to save your themes when accessed with an account. +
+ ++ The theme scss is availabe as open source at primevue-sass-theme repository. The base folder contains the theming structure of the components, themes under + themes folder define the SCSS variables and import the base to define a theme. The themes folder contains all the built-in themes so you can customize their code as well. +
++ To create your own theme, clone the primevue-sass-theme repository and access the themes/mytheme folder. The sass variables to customize are available under the + variables folder. The _fonts file can be used to define a custom font for your project whereas the optional _extensions file is provided to add overrides to the components designs. The theme.scss file imports + the theme files along with the base folder at the root to combine everything together. Next step would be compilation of the scss that can either be command line or within your project. +
+ +Once your theme is ready run the following command to compile it. Note that sass command should be available in your terminal.
++ Then copy and import the theme.css file in your application. For example, in a Vite based template like create-vue, you may place theme.css under assets folder and then import it an + main.js. +
++ This approach eliminates the manual compilation by delegating it to your build environment that has the ability to compile SCSS. Clone primevue-sass-theme and copy the + base folder along with themes/mytheme folder to your application where assets reside. At a suitable location like main.js or App.vue, import the theme.scss from assets/themes/mytheme. That would + be it, during build time, your project will compile the sass and import the theme. Any changes to your theme will be reflected instantly. +
+- CSS of the themes share the same license as PrimeVue which is MIT, this means the generated CSS can be customized per your needs however this should be avoided if your customizations are not simple. For instance even to change a primary - color, since there is no variable a find and replace should be performed various times. On the other hand, this can be achieved by changing a single variable e.g. $primaryColor. Visit the{' '} - SASS API for the documentation of available customization options. -
- -- Designer is the ultimate tool to create your own PrimeVue experience powered by a SASS based theme engine with 500+ variables and a Visual Designer. PrimeVue only ships the - generated CSS of the themes whereas Designer provides full access to the whole SASS structure and the variables of these pre-built themes for easier customization. -
- -Whether you have your own style guide or just need a custom theme, Designer is the right tool to design and bring them to existence.
- -Visit Designer Website for more information and live demos.
- - - -Here is an example to demonstrate how to align 3 buttons horizontally on bigger screens and display them as stacked on smaller ones.
-- A named class is bound to the class property of a component and the CSS is included with an import. Note that, the css still is still bundled globally so prefer this approach if your application doesn't have a built-in solution to - do CSS scoping. -
+Scoped CSS allows overriding the styles of a particular PrimeVue component using scoped SFC style and :deep.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@@ -24,10 +21,15 @@ export default {
code1: {
basic: `
`
},
@@ -35,7 +37,7 @@ export default {
code2: {
basic: `
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
@@ -50,8 +52,13 @@ export default {
diff --git a/doc/theming/SwitchThemesDoc.vue b/doc/theming/SwitchThemesDoc.vue
new file mode 100644
index 000000000..74aa1a64b
--- /dev/null
+++ b/doc/theming/SwitchThemesDoc.vue
@@ -0,0 +1,73 @@
+
+
+ Solution below works however there is room for improvement. The upcoming styling api will greatly improve dynamic theme switching ability, eliminates the prerequisites with the introduction of CSS variables and dynamic imports.
+
+ Themes can be dynamically changed using the PrimeVue.changeTheme function. For this feature to work, there are two prerequisites. To begin with, the themes should be publicly available under the public folder in your project
+ by copying them from PrimeVue resources/themes folder. Second part is making the theme.css accessible via a link element so that the id of the link can be provided as the 3rd parameter to the changeTheme function.
+ In a Vite based project like create-vue, the link can be placed at index.html. Nuxt applications can configure the link element using nuxt.config.js.p-invalid
Applies the invalid style to a text or a form field.
-
-
p-text-secondary
- Applies the text color of the theme with the secondary priority.
-
{{ doc.description }}