An introduction to accessibility and how it translates to Vue UI Components.
++ Accessibility is a major concern of the Prime UI libraries and PrimeVue is no exception. PrimeTek teams have initiated a significant process to review and enhance the + accessibility features of the components. This guide documents the foundation of the general guidelines that PrimeVue will follow and each component documentation will have a separate Accessibility section that states the + keyboard support, screen reader compatibility, the implementation details along with tips to achieve WCAG compliancy. This work has been initiated in Q2 2022 and planned to be completed by early Q3. PrimeVue will be the reference + implementation which then will be ported to PrimeFaces, PrimeNG and PrimeReact. +
+ ++ According to the World Health Organization, 15% of the world population has a disability to some degree. As a result, accessibility features in any context such as a ramp for wheelchair users or a multimedia with captions are crucial + to ensure content can be consumed by anyone. +
+ +Types of disabilities are diverse so you need to know your audience well and how they interact with the content created. There four main categories;
+ ++ Blindness, low-level vision or color blindness are the common types of visual impairments. Screen magnifiers and the color blind mode are usually built-in features of the browsers whereas for people who rely on screen readers, page + developers are required to make sure content is readable by the readers. Popular readers are NVDA, + JAWS and ChromeVox. +
+ ++ Deafness or hearing loss refers to the inability to hear sounds totally or partially. People with hearing impairments use assistive devices however it may not be enough when interacting with a web page. Common implementation is + providing textual alternatives, transcripts and captions for content with audio. +
+ ++ People with mobility impairments have disabilities related to movement due to loss of a limb, paralysis or other varying reasons. Assistive technologies like a head pointer is a device to interact with a screen whereas keyboard or a + trackpad remain as solutions for people who are not able to utilize a mouse. +
+ ++ Cognitive impairments have a wider range that includes people with learning disabilities, depression and dyslexia. A well designed content also leads to better user experience for people without disabilities so designing for cognitive + impairments result in better design for any user. +
+ ++ Correct page structure with the aid of assistive technologies are the core ingridients for an accessible web content. HTML is based on an accessible foundation, form controls can be used by keyboard by default and semantic HTML is + easier to be processed by a screen reader. +
+ ++ WCAG refers to Web Content Accessibility Guideline, a standard managed by the WAI (Web Accessibility Initiative) of W3C (World Wide + Web Consortium). WCAG consists of recommendations for making the web content more accessible. PrimeVue components aim high level of WCAG compliancy in the near future. +
+ ++ Various countries around the globe have governmental policies regarding web accessibility as well. Most well known of these are Section 508 in the US and + Web Accessibility Directive of the European Union. +
+ ++ Native form elements should be preferred instead of elements that are meant for other purposes like presentation. As an example, button below is rendered as a form control by the browser, can receive focus via tabbing and can be used + with space key as well to trigger. +
+
+<button @click="onButtonClick(event)">Click</button>
+
+
+
+ On the other hand, a fancy css based button using a div has no keyboard or screen reader support.
+
+<button class="fancy-button" @click="onButtonClick(event)">Click</button>
+
+
+
+ + tabindex is required to make a div element accessible in addition to use a keydown to bring the keyboard support back. To avoid the overload and implementing functionality that is already provided by the browser, native form + controls should be preferred. +
+
+<div class="fancy-button" @click="onClick(event)" @keydown="onKeyDown(event)" tabindex="0">Click</div>
+
+
+
+ Form components must be related to another element that describes what the form element is used for. This is usually achieved with the label element.
+
+<label for="myinput">Username:</label>
+<input id="myinput" type="text" name="username" />
+
+
+
+ + HTML offers various element to organize content on a web page that screen readers are aware of. Preferring Semantic HTML for good semantics provide out of the box support for reader which is not possible when regular + div elements with classes are used. Consider the following example that do not mean too much for readers. +
+
+<div class="header">
+ <div class="header-text">Header</div>
+</div>
+
+<div class="nav"></div>
+
+<div class="main">
+ <div class="content">
+ </div>
+
+ <div class="sidebar">
+ </div>
+</div>
+
+<div class="footer">
+</div>
+
+
+
+ Same layout can be achieved using the semantic elements with screen reader support built-in.
+
+<header>
+ <h1>Header</h1>
+</header>
+
+<nav></nav>
+
+<main>
+ <article></article>
+
+ <aside></aside>
+</main>
+
+<footer>
+</footer>
+
+
+
+ + ARIA refers to "Accessible Rich Internet Applications" is a suite to fill the gap where semantic HTML is inadequate. These cases are mainly related to rich UI components/widgets. Although browser support for rich UI components such as + a datepicker or colorpicker has been improved over the past years many web developers still utilize UI components derived from standard HTML elements created by them or by other projects like PrimeVue. These types of components must + provide keyboard and screen reader support, the latter case is where the WAI-ARIA is utilized. +
++ ARIA consists of roles, properties and attributes. Roles define what the element is mainly used for e.g. checkbox, dialog, tablist whereas States and Properties define the metadata of the + element like aria-checked, aria-disabled. +
+ +Consider the following case of a native checkbox. It has built-in keyboard and screen reader support.
+
+<input type="checkbox" value="Prime" name="ui" checked>
+
+
+
+ + A fancy checkbox with css animations might look more appealing but accessibility might be lacking. Checkbox below may display a checked font icon with animations however it is not tabbable, cannot be checked with space key and cannot + be read by a reader. +
+
+<div class="fancy-checkbox">
+ <i class="checked-icon" v-if="checked"></i>
+</div>
+
+
+
+ One alternative is using ARIA roles for readers and use javascript for keyboard support. Notice the usage of aria-labelledby as a replacement of the label tag with for.
+
+<span id="chk-label">Remember Me</span>
+<div class="fancy-checkbox" role="checkbox" aria-checked="false" tabindex="0" aria-labelledby="chk-label"
+ @click="toggle" @keydown="onKeyDown(event)">
+ <i class="checked-icon" v-if="checked"></i>
+</div>
+
+
+
+ + However the best practice is combining semantic HTML for accessibility while keeping the design for UX. This approach involves hiding a native checkbox for accessibility and using javascript events to update its state. Notice the + usage of p-sr-only + that hides the elements from the user but not from the screen reader. +
+
+<label for="chkbox">Remember Me</label>
+<div class="fancy-checkbox" @click="toggle">
+ <input class="p-sr-only" type="checkbox" id="chkbox" @focus="updateParentVisuals" @blur="updateParentVisuals"
+ @keydown="onKeyDown(event)">
+ <i class="checked-icon" v-if="checked"></i>
+</div>
+
+
+
+ A working sample is the PrimeVue checkbox that is tabbable, keyboard accessible and is compliant with a screen reader. Instead of ARIA roles it relies on a hidden native checkbox.
+ +Colors on a web page should aim a contrast ratio of at least 4.5:1 and consider a selection of colors that do not cause vibration.
+ +Color contrast between the background and the foreground content should be sufficient enough to ensure readability. Example below displays two cases with good and bad samples.
+ +Color vibration is leads to an illusion of motion due to choosing colors that have low visibility against each other. Color combinations need to be picked with caution to avoid vibration.
+ +Highly saturated colors should be avoided when used within a dark design scheme as they cause eye strain. Instead desaturated colors should be preferred.
+ +
+import Accordion from 'primevue/accordion';
+import AccordionTab from 'primevue/accordiontab';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/accordion/accordion.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/accordiontab/accordiontab.min.js"></script>
+
+
+
+ Accordion element consists of one or more AccordionTab elements. Title of the tab is defined using header attribute.
+
+<Accordion>
+ <AccordionTab header="Header I">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header II">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header III">
+ Content
+ </AccordionTab>
+</Accordion>
+
+
+
+ Visibility of the content is specified with the activeIndex property that supports one or two-way binding.
+
+<Accordion :activeIndex="0">
+ <AccordionTab header="Header I">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header II">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header III">
+ Content
+ </AccordionTab>
+</Accordion>
+
+
+
+ Two-way binding requires v-model.
+
+<Accordion v-model:activeIndex="activeIndex">
+ <AccordionTab header="Header I">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header II">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header III">
+ Content
+ </AccordionTab>
+</Accordion>
+
+
+
+ By default only one tab at a time can be active, enabling multiple property changes this behavior to allow multiple tabs be active at the same time.
+
+<Accordion :multiple="true">
+ <AccordionTab header="Header I">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header II">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header III">
+ Content
+ </AccordionTab>
+</Accordion>
+
+
+
+ A tab can be disabled by setting the disabled property to true.
+
+<Accordion>
+ <AccordionTab header="Header I">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header II">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header III" :disabled="true">
+ Content
+ </AccordionTab>
+</Accordion>
+
+
+
+ Custom content for the title section of a panel is defined using the header template.
+
+<Accordion>
+ <AccordionTab>
+ <template #header>
+ <i class="pi pi-calendar"></i>
+ <span>Header I</span>
+ </template>
+ Content
+ </AccordionTab>
+ <AccordionTab>
+ <template #header>
+ <i class="pi pi-calendar"></i>
+ <span>Header II</span>
+ </template>
+ Content
+ </AccordionTab>
+ <AccordionTab>
+ <template #header>
+ <i class="pi pi-calendar"></i>
+ <span>Header III</span>
+ </template>
+ Content
+ </AccordionTab>
+</Accordion>
+
+
+
+ Tabs can be controlled programmatically using activeIndex property.
+
+<Button @click="active = 0" class="p-button-text" label="Activate 1st" />
+<Button @click="active = 1" class="p-button-text" label="Activate 2nd" />
+<Button @click="active = 2" class="p-button-text" label="Activate 3rd" />
+
+<Accordion :multiple="true" :activeIdex="active">
+ <AccordionTab header="Header I">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header II">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header III">
+ Content
+ </AccordionTab>
+</Accordion>
+
+
+
+
+export default {
+ data() {
+ return {
+ active: 0
+ }
+ }
+}
+
+
+
+ Tabs can be generated dynamically using the standard v-for directive.
+
+<Accordion>
+ <AccordionTab v-for="tab in tabs" :key="tab.title" :header="tab.title">
+ <p>{{tab.content}}</p>
+ </AccordionTab>
+</Accordion>
+
+
+
+
+export default {
+ data() {
+ return {
+ tabs: [
+ {title: 'Title 1', content: 'Content 1'},
+ {title: 'Title 3', content: 'Content 2'},
+ {title: 'Title 3', content: 'Content 3'}
+ ]
+ }
+ }
+}
+
+
+
+ + All tabs are rendered when mounted and inactive tabs are hidden with CSS. Enabling lazy option activates the dynamic mode where a tab is only rendered at DOM when it is active. This option is useful to speed up the initial + rendering performance if there are many tabs. +
+ +
+<Accordion lazy>
+ <AccordionTab header="Header I">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header II">
+ Content
+ </AccordionTab>
+ <AccordionTab header="Header III">
+ Content
+ </AccordionTab>
+</Accordion>
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
header | +string | +null | +Orientation of tab headers. | +
headerStyle | +string | +null | +Inline style of the tab header. | +
headerClass | +string | +null | +Style class of the tab header. | +
headerProps | +object | +null | +Uses to pass all properties of the HTMLDivElement to the tab header. | +
headerActionProps | +object | +null | +Uses to pass all properties of the HTMLAnchorElement to the focusable anchor element inside the tab header. | +
contentStyle | +string | +null | +Inline style of the tab content. | +
contentClass | +string | +null | +Style class of the tab content. | +
contentProps | +object | +null | +Uses to pass all properties of the HTMLDivElement to the tab content. | +
disabled | +boolean | +false | +Whether the tab is disabled. | +
Any property as style and class are passed to the main container element. Following is the additional property to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
multiple | +boolean | +false | +When enabled, multiple tabs can be activated at the same time. | +
activeIndex | +number|array | +null | +Index of the active tab or an array of indexes in multiple mode. | +
lazy | +boolean | +false | +When enabled, hidden tabs are not rendered at all. Defaults to false that hides tabs with css. | +
expandIcon | +string | +pi-chevron-right | +Icon of a collapsed tab. | +
collapseIcon | +string | +pi-chevron-down | +Icon of an expanded tab. | +
tabindex | +number | +0 | +Index of the element in tabbing order. | +
selectOnFocus | +boolean | +false | +When enabled, the focused tab is activated. | +
Name | +Parameters | +Description | +
---|---|---|
tab-open | +
+ event.originalEvent: Browser event + event.index: Opened tab index + |
+ Callback to invoke when a tab gets expanded. | +
tab-close | +
+ event.originalEvent: Browser event + event.index: Closed tab index + |
+ Callback to invoke when an active tab is collapsed by clicking on the header. | +
tab-click | +
+ event.originalEvent: Browser event + event.index: Index of the clicked tab + |
+ Callback to invoke when an active tab is clicked. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-accordion | +Container element. | +
p-accordion-header | +Header of a tab. | +
p-accordion-content | +Container of a tab. | +
+ Accordion header elements have a button role and use aria-controls to define the id of the content section along with aria-expanded for the visibility state. The value to read a header element defaults to the value of + the header property and can be customized by defining an aria-label or aria-labelledby via the headerActionProps property. +
+The content uses region role, defines an id that matches the aria-controls of the header and aria-labelledby referring to the id of the header.
+ +Key | +Function | +
---|---|
+ tab + | +Moves focus to the next the focusable element in the page tab sequence. | +
shift + tab | +Moves focus to the previous the focusable element in the page tab sequence. | +
+ enter + | +Toggles the visibility of the content. | +
+ space + | +Toggles the visibility of the content. | +
+ down arrow + | +Moves focus to the next header. If focus is on the last header, moves focus to the first header. | +
+ up arrow + | +Moves focus to the previous header. If focus is on the first header, moves focus to the last header. | +
+ home + | +Moves focus to the first header. | +
+ end + | +Moves focus to the last header. | +
None.
+Accordion groups a collection of contents in tabs.
++ 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. +
++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo + enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in + culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
++ 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. +
++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo + enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in + culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
++ 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. +
++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo + enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in + culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
++ 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. +
++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo + enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in + culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
+{{ tab.content }}
+
+import AutoComplete from 'primevue/autocomplete';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/autocomplete/autocomplete.min.js"></script>
+
+
+
+ + AutoComplete uses v-model for two-way binding, requires a list of suggestions and a complete method to query for the results. The complete method gets the query text as event.query property and should update the suggestions with the + search results. Example below connects to a remote datasource to fetch the results; +
+
+<AutoComplete v-model="selectedCountry" :suggestions="filteredCountriesBasic" @complete="searchCountry($event)" optionLabel="name" />
+
+
+
+export default {
+ data() {
+ return {
+ selectedCountry: null,
+ filteredCountries: null
+ }
+ },
+ countryService: null,
+ created() {
+ this.countryService = new CountryService();
+ },
+ methods: {
+ searchCountry(event) {
+ this.filteredCountriesBasic = this.countryService.search(event.query);
+ }
+ }
+}
+
+
+
+ + Enabling dropdown property displays a button next to the input field where click behavior of the button is defined using dropdownMode property that takes "blank" or "current" as possible values. "blank" is the default mode to send + a query with an empty string whereas "current" setting sends a query with the current value of the input. +
+
+<AutoComplete v-model="brand" :dropdown="true" :suggestions="filteredBrands" @complete="searchBrand($event)" placeholder="Hint: type 'v' or 'f'" />
+
+
+
+ Multiple mode is enabled using multiple property to select more than one value from the autocomplete. In this case, value reference should be an array.
+
+<AutoComplete :multiple="true" v-model="selectedCountries" :suggestions="filteredCountriesMultiple" @complete="searchCountryMultiple($event)" optionLabel="name" />
+
+
+
+ + AutoComplete can also work with objects using the optionLabel property that defines the label to display as a suggestion. The value passed to the model would still be the object instance of a suggestion. Here is an example with a + Country object that has name and code fields such as {name:"United States",code:"USA"}. +
+
+<AutoComplete optionLabel="label" v-model="selectedCountry" :suggestions="filteredCountriesBasic" @complete="searchCountryBasic($event)" />
+
+
+
+ Options groups are specified with the optionGroupLabel and optionGroupChildren properties.
+
+export default {
+ data() {
+ return {
+ selectedGroupedCity: null,
+ groupedCities: [{
+ label: 'Germany', code: 'DE',
+ items: [
+ {label: 'Berlin', value: 'Berlin'},
+ {label: 'Frankfurt', value: 'Frankfurt'},
+ {label: 'Hamburg', value: 'Hamburg'},
+ {label: 'Munich', value: 'Munich'}
+ ]
+ },
+ {
+ label: 'USA', code: 'US',
+ items: [
+ {label: 'Chicago', value: 'Chicago'},
+ {label: 'Los Angeles', value: 'Los Angeles'},
+ {label: 'New York', value: 'New York'},
+ {label: 'San Francisco', value: 'San Francisco'}
+ ]
+ },
+ {
+ label: 'Japan', code: 'JP',
+ items: [
+ {label: 'Kyoto', value: 'Kyoto'},
+ {label: 'Osaka', value: 'Osaka'},
+ {label: 'Tokyo', value: 'Tokyo'},
+ {label: 'Yokohama', value: 'Yokohama'}
+ ]
+ }]
+ }
+ }
+}
+
+
+
+<AutoComplete v-model="selectedCity" :suggestions="filteredCities" @complete="searchCity($event)"
+ optionLabel="label" optionGroupLabel="label" optionGroupChildren="items"></AutoComplete>
+
+
+
+ + ForceSelection mode validates the manual input to check whether it also exists in the suggestions list, if not the input value is cleared to make sure the value passed to the model is always one of the suggestions. Simply enable + forceSelection to enforce that input is always from the suggestion list. +
+
+<AutoComplete forceSelection v-model="brand" :suggestions="filteredBrands" @complete="searchBrand($event)" />
+
+
+
+ + Item template allows displaying custom content inside the suggestions panel. The slotProps variable passed to the template provides an item property to represent an item in the suggestions collection. In addition optiongroup, + chip, header and footer slots are provided for further customization +
+
+<AutoComplete v-model="brand" :suggestions="filteredBrands" @complete="searchBrand($event)" placeholder="Hint: type 'v' or 'f'" :dropdown="true">
+ <template #item="slotProps">
+ <img :alt="slotProps.item" :src="'demo/images/car/' + slotProps.item + '.png'" />
+ <div>{{slotProps.item}}</div>
+ </template>
+</AutoComplete>
+
+
+
+ Any property of HTMLDivElement are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
suggestions | +array | +null | +An array of suggestions to display. | +
field | +any | +null | +Property name or getter function of a suggested object to resolve and display. *Deprecated since v3.16.0. Use 'optionLabel' property instead. | +
optionLabel | +string | function | +null | +Property name or getter function to use as the label of an option. | +
optionDisabled | +string | function | +null | +Property name or getter function to use as the disabled flag of an option, defaults to false when not defined. | +
optionGroupLabel | +string | +null | +Property name or getter function to use as the label of an option group. | +
optionGroupChildren | +string | +null | +Property name or getter function that refers to the children options of option group. | +
scrollHeight | +string | +200px | +Maximum height of the suggestions panel. | +
dropdown | +boolean | +false | +Displays a button next to the input field when enabled. | +
dropdownMode | +string | +blank | +Specifies the behavior dropdown button. Default "blank" mode sends an empty string and "current" mode sends the input value. | +
autoHighlight | +boolean | +false | +Highlights automatically the first item of the dropdown to be selected. *Deprecated since v3.16.0. | +
multiple | +boolean | +false | +Specifies if multiple values can be selected. | +
placeholder | +string | +null | +Default text to display when no option is selected. | +
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +
dataKey | +string | +null | +A property to uniquely identify an option. | +
minLength | +number | +1 | +Minimum number of characters to initiate a search. | +
delay | +number | +300 | +Delay between keystrokes to wait before sending a query. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. Special keywords are "body" for document body and "self" for the element itself. | +
forceSelection | +boolean | +false | +When present, autocomplete clears the manual input if it does not match of the suggestions to force only accepting values from the suggestions. | +
completeOnFocus | +boolean | +false | +Whether to run a query when input receives focus. | +
inputId | +string | +null | +Identifier of the underlying input element. | +
inputStyle | +any | +null | +Inline style of the input field. | +
inputClass | +string | +null | +Style class of the input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement/HTMLSpanElement to the focusable input element inside the component. | +
panelStyle | +any | +null | +Inline style of the overlay panel. | +
panelClass | +string | +null | +Style class of the overlay panel. | +
panelProps | +object | +null | +Uses to pass all properties of the HTMLDivElement to the overlay panel. | +
loadingIcon | +string | +pi pi-spinner | +Icon class used when loading | +
virtualScrollerOptions | +object | +null | +Whether to use the virtualScroller feature. The properties of |
+
autoOptionFocus | +boolean | +true | +Whether to focus on the first visible or selected element when the overlay panel is shown. | +
selectOnFocus | +boolean | +false | +When enabled, the focused option is selected. | +
searchLocale | +string | +undefined | +Locale to use in searching. The default locale is the host environment's current locale. | +
searchMessage | +string | +{0} results are available | +Text to be displayed in hidden accessible field when filtering returns any results. Defaults to value from PrimeVue locale configuration. | +
selectionMessage | +string | +{0} items selected | +Text to be displayed in hidden accessible field when options are selected. Defaults to value from PrimeVue locale configuration. | +
emptySelectionMessage | +string | +No selected item | +Text to be displayed in hidden accessible field when any option is not selected. Defaults to value from PrimeVue locale configuration. | +
emptySearchMessage | +string | +No results found | +Text to be displayed when filtering does not return any results. Defaults to value from PrimeVue locale configuration. | +
tabindex | +number | +0 | +Index of the element in tabbing order. | +
aria-label | +string | +null | +Defines a string value that labels an interactive element. | +
aria-labelledby | +string | +null | +Establishes relationships between the component and label(s) where its value should be one or more element IDs. | +
Name | +Parameters | +Description | +
---|---|---|
change | +
+ event.originalEvent: Original event + event.value: Selected option value + |
+ Callback to invoke on value change. | +
focus | +event | +Callback to invoke when the component receives focus. | +
blur | +event | +Callback to invoke when the component loses focus. | +
item-select | +
+ event.originalEvent: Browser event + event.value: Selected item + |
+ Callback to invoke when a suggestion is selected. | +
item-unselect | +
+ event.originalEvent: Browser event + event.value: Unselected item + |
+ Callback to invoke when a selected value is removed. | +
dropdown-click | +
+ event.originalEvent: browser event + event.query: Current value of the input field + |
+ Callback to invoke to when dropdown button is clicked. | +
clear | +- | +Callback to invoke when input is cleared by the user. | +
complete | +
+ event.originalEvent: Browser event + event.query: Value to search with + |
+ Callback to invoke to search for suggestions. | +
before-show | +- | +Callback to invoke before the overlay is shown. | +
before-hide | +- | +Callback to invoke before the overlay is hidden. | +
show | +- | +Callback to invoke when the overlay is shown. | +
hide | +- | +Callback to invoke when the overlay is hidden. | +
Name | +Parameters | +
---|---|
chip | +value: A value in the selection | +
header | +
+ value: Value of the component + suggestions: Displayed options + |
+
footer | +
+ value: Value of the component + suggestions: Displayed options + |
+
item *Deprecated since v3.16.0 | +
+ item: Option instance + index: Index of the option + |
+
option | +
+ option: Option instance + index: Index of the option + |
+
optiongroup | +
+ item: OptionGroup instance *Deprecated since v3.16.0 + option: OptionGroup instance + index: Index of the option group + |
+
content | +
+ items: An array of objects to display for virtualscroller + styleClass: Style class of the component + contentRef: Referance of the content + getItemOptions: Options of the items + |
+
loader | +options: Options of the loader items for virtualscroller | +
Following is the list of structural style classes
+Name | +Element | +
---|---|
p-autocomplete | +Container element | +
p-autocomplete-panel | +Overlay panel of suggestions. | +
p-autocomplete-items | +List container of suggestions. | +
p-autocomplete-item | +List item of a suggestion. | +
p-autocomplete-token | +Element of a selected item in multiple mode. | +
p-autocomplete-token-icon | +Close icon element of a selected item in multiple mode. | +
p-autocomplete-token-label | +Label of a selected item in multiple mode. | +
p-overlay-open | +Container element when overlay is visible. | +
+ Value to describe the component can either be provided via label tag combined with inputId prop or using aria-labelledby, aria-label props. The input element has combobox role in addition to + aria-autocomplete, aria-haspopup and aria-expanded attributes. The relation between the input and the popup is created with aria-controls and aria-activedescendant attribute is used to instruct screen + reader which option to read during keyboard navigation within the popup list. +
+In multiple mode, chip list uses listbox role with aria-orientation set to horizontal whereas each chip has the option role with aria-label set to the label of the chip.
++ The popup list has an id that refers to the aria-controls attribute of the input element and uses listbox as the role. Each list item has option role and an id to match the aria-activedescendant of the input + element. +
+ +
+<label for="ac1">Username</label>
+<AutoComplete inputId="ac1" />
+
+<span id="ac2">Email</span>
+<AutoComplete aria-labelledby="ac2" />
+
+<AutoComplete aria-label="City" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the autocomplete element. | +
any printable character | +Opens the popup and moves focus to the first option. | +
Key | +Function | +
---|---|
tab | +Moves focus to the next focusable element in the popup. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. | +
shift + tab | +Moves focus to the previous focusable element in the popup. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. | +
enter | +Selects the focused option and closes the popup, then moves focus to the autocomplete element. | +
space | +Selects the focused option and closes the popup, then moves focus to the autocomplete element. | +
escape | +Closes the popup, then moves focus to the autocomplete element. | +
down arrow | +Moves focus to the next option, if there is none then visual focus does not change. | +
up arrow | +Moves focus to the previous option, if there is none then visual focus does not change. | +
alt + up arrow | +Selects the focused option and closes the popup, then moves focus to the autocomplete element. | +
left arrow | +Removes the visual focus from the current option and moves input cursor to one character left. | +
right arrow | +Removes the visual focus from the current option and moves input cursor to one character right. | +
home | +Moves input cursor at the end, if not then moves focus to the first option. | +
end | +Moves input cursor at the beginning, if not then moves focus to the last option. | +
pageUp | +Jumps visual focus to first option. | +
pageDown | +Jumps visual focus to last option. | +
Key | +Function | +
---|---|
backspace | +Deletes the previous chip if the input field is empty. | +
left arrow | +Moves focus to the previous chip if available and input field is empty. | +
Key | +Function | +
---|---|
left arrow | +Moves focus to the previous chip if available. | +
right arrow | +Moves focus to the next chip, if there is none then input field receives the focus. | +
backspace | +Deletes the chips and adds focus to the input field. | +
None.
+AutoComplete is an input component that provides real-time suggestions when being typed.
+
+import Avatar from 'primevue/avatar';
+import AvatarGroup from 'primevue/avatargroup';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/avatar/avatar.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/avatargroup/avatargroup.min.js"></script>
+
+
+
+ Avatar has three built-in display modes; "label", "icon" and "image".
+
+<Avatar label="P" />
+<Avatar icon="pi pi-search" />
+<Avatar image="user.png" />
+
+
+
+ size property defines the size of the Avatar with "large" and "xlarge" as possible values.
+
+<Avatar label="P" size="large"/>
+
+
+
+ A set of Avatars can be displayed together using the AvatarGroup component.
+
+<AvatarGroup>
+ <Avatar label="P" />
+ <Avatar icon="pi pi-search" />
+ <Avatar image="user.png" />
+ <Avatar label="+2" />
+</AvatarGroup>
+
+
+
+ Avatar comes in two different styles specified with the shape property, "square" is the default and "circle" is the alternative.
+
+<Avatar label="P" shape="circle"/>
+
+
+
+ A badge can be added to an Avatar with the
+<Avatar image="user.png" size="xlarge" v-badge.danger="4" />
+
+
+
+ Content can easily be customized with the default slot instead of using the built-in modes.
+
+<Avatar>
+ Content
+</Avatar>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
label | +string | +null | +Defines the text to display. | +
icon | +string | +null | +Defines the icon to display. | +
image | +string | +null | +Defines the image to display. | +
size | +string | +null | +Size of the element, valid options are "large" and "xlarge". | +
shape | +string | +square | +Shape of the element, valid options are "square" and "circle". | +
Any property as style and class are passed to the main container element. There are no additional properties.
+ +Name | +Parameters | +Description | +
---|---|---|
error | +- | +Triggered when an error occurs while loading an image file. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-avatar | +Container element. | +
p-avatar-image | +Container element in image mode. | +
p-avatar-circle | +Container element with a circle shape. | +
p-avatar-text | +Text of the Avatar. | +
p-avatar-icon | +Icon of the Avatar. | +
p-avatar-lg | +Container element with a large size. | +
p-avatar-xl | +Container element with an xlarge size. | +
Name | +Element | +
---|---|
p-avatar-group | +Container element. | +
None.
+Avatar represents people using icons, labels and images.
+Badge can either be used as a standalone component or as a directive.
+ +
+import Badge from 'primevue/badge';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/badge/badge.min.js"></script>
+
+
+
+ Content of the badge is specified using the value property.
+
+<Badge value="2"></Badge>
+
+
+
+
+import BadgeDirective from 'primevue/badgedirective';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/badgedirective/badgedirective.min.js"></script>
+
+
+
+ When used as a directive, badge needs to be configured at the application with a name of your choice.
+
+import BadgeDirective from 'primevue/badgedirective';
+
+app.directive('badge', BadgeDirective);
+
+
+
+ Next step is attaching it to an element.
+
+<i class="pi pi-bell" v-badge="2"></i>
+
+
+
+ Different color options are available as severity levels. When used as a component use the severity property to apply a severity and use a modifier as the severity value in directive mode.
+ +
+<Badge value="2" severity="success"></Badge>
+
+<i class="pi pi-bell" v-badge.success="2"></i>
+
+
+
+ Buttons provide integrated badge support with the badge and badgeClass properties.
+ +
+<Button type="button" label="Emails" badge="8" />
+<Button type="button" label="Messages" icon="pi pi-users" class="p-button-warning" badge="8" badgeClass="p-badge-danger" />
+
+
+
+ Badge sizes are adjusted with the size property that accepts "large" and "xlarge" as the possible alternatives to the default size. Currently sizes only apply to component mode.
+
+<Badge value="2"></Badge>
+<Badge value="4" size="large" severity="warning"></Badge>
+<Badge value="6" size="xlarge" severity="success"></Badge>
+
+
+
+ In addition, when placed inside another element, badge sizes can also derive their size from their parent.
+
+<h1>Heading 1 <Badge value="New"></Badge></h1>
+<h2>Heading 2 <Badge value="New"></Badge></h2>
+
+
+
+ Content can easily be customized with the default slot instead of using the built-in display.
+
+<Badge>
+ Content
+</Badge>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
value | +any | +null | +Value to display inside the badge. | +
severity | +string | +null | +Severity type of the badge. | +
size | +string | +null | +Size of the badge, valid options are "large" and "xlarge". | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-badge | +Badge element | +
p-overlay-badge | +Wrapper of a badge and its target. | +
p-badge-dot | +Badge element with no value. | +
p-badge-success | +Badge element with success severity. | +
p-badge-info | +Badge element with info severity. | +
p-badge-warning | +Badge element with warning severity. | +
p-badge-danger | +Badge element with danger severity. | +
p-badge-lg | +Large badge element | +
p-badge-xl | +Extra large badge element | +
None.
+Badge is a small status indicator for another element.
+
+import BlockUI from 'primevue/blockui';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/blockui/blockui.min.js"></script>
+
+
+
+ + BlockUI is controlled using the blocked property, by default target element to block is the child component. In example below, panel gets blocked with a mask when blockedPanel is enabled and gets unblock when the bound variable is + set to false. +
+
+<BlockUI :blocked="blockedPanel">
+ <Panel header="Header">
+ Panel Content
+ </Panel>
+</BlockUI>
+
+
+
+
+export default {
+ data() {
+ return {
+ blockedPanel: false
+ }
+ },
+ methods: {
+ blockPanel() {
+ this.blockedPanel = true;
+ },
+ unblockPanel() {
+ this.blockedPanel = false;
+ }
+ }
+}
+
+
+
+ In full screen mode, instead of a particular element, the whole document gets blocked. Set fullScreen as true in order to enable this functionality.
+ +
+<BlockUI :blocked="blockedDocument" :fullScreen="true"></BlockUI>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
blocked | +array | +null | +Controls the blocked state. | +
fullscreen | +menuitem | +null | +When enabled, the whole document gets blocked. | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
autoZIndex | +boolean | +true | +Whether to automatically manage layering. | +
Name | +Parameters | +Description | +
---|---|---|
block | +- | +Fired when the element gets blocked. | +
unblock | +- | +Fired when the element gets unblocked. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-blockui | +Mask element. | +
p-blockui-document | +Mask element in full screen mode. | +
None.
+BlockUI can either block other components or the whole page.
++ The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding. His beloved son Michael has just come home from the war, but does not intend to become part of his father's + business. Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family, kind and benevolent to those who give respect, but given to ruthless + violence whenever anything stands against the good of the family. +
+
+import Breadcrumb from 'primevue/breadcrumb';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/breadcrumb/breadcrumb.min.js"></script>
+
+
+
+ Breadcrumb uses the common MenuModel API to define the items, visit
Breadcrumb requires a collection of menuitems as its model and a home item.
+
+<Breadcrumb :home="home" :model="items" />
+
+
+
+
+export default {
+ data() {
+ return {
+ home: {icon: 'pi pi-home', to: '/'},
+ items: [
+ {label: 'Computer'},
+ {label: 'Notebook'},
+ {label: 'Accessories'},
+ {label: 'Backpacks'},
+ {label: 'Item'}
+ ]
+ }
+ }
+}
+
+
+
+ Breadcrumb offers content customization with the item template that receives the menuitem instance from the model as a parameter.
+
+<Breadcrumb :home="home" :model="items">
+ <template #item="{item}">
+ <a :href="item.url">{{item.label}}</a>
+ </template>
+</Breadcrumb>
+
+
+
+ router-link with route configuration can also be used within templating for further customization.
+
+<Breadcrumb :home="home" :model="items">
+ <template #item="{item}">
+ <router-link :to="item.to" custom v-slot="{href, route, navigate, isActive, isExactActive}">
+ <a :href="href" @click="navigate" :class="{'active-link': isActive, 'active-link-exact": isExactActive}>{{route.fullPath}}</a>
+ </router-link>
+ </template>
+</Breadcrumb>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
model | +array | +null | +An array of menuitems. | +
home | +menuitem | +null | +Configuration for the home icon. | +
exact | +boolean | +true | +Whether to apply 'router-link-active-exact' class if route exactly matches the item path. | +
Name | +Parameters | +
---|---|
item | +item: Menuitem instance | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-breadcrumb | +Container element. | +
p-menuitem | +Menuitem element. | +
p-menuitem-text | +Label of a menuitem. | +
p-breadcrumb-chevron | +Chevron element. | +
None.
+Breadcrumb provides contextual information about page hierarchy.
+
+import Calendar from 'primevue/calendar';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/calendar/calendar.min.js"></script>
+
+
+
+ Two-way value binding is defined using the standard v-model directive referencing to a Date property.
+ +
+<Calendar v-model="value" />
+
+
+
+
+export default {
+ data() {
+ return {
+ value: null
+ }
+ }
+}
+
+
+
+ Calendar is displayed in a popup by default and inline property needs to be enabled for inline mode.
+
+<Calendar v-model="value" :inline="true" />
+
+
+
+ + By default calendar allows selecting one date only whereas multiple dates can be selected by setting selectionMode to multiple. In this case calendar updates the value with an array of dates where optionally number of selectable + dates can be restricted with maxDateCount property. Third alternative is the range mode that allows selecting a range based on an array of two values where first value is the start date and second value is the end date. +
+ +
+<Calendar v-model="value" selectionMode="single || multiple || range" />
+
+
+
+ Default date format is mm/dd/yy, to customize this use dateFormat property or define it at
+<Calendar v-model="value" dateFormat="dd.mm.yy" />
+
+
+
+ Following options can be a part of the format.
+TimePicker is enabled with showTime property and 24 (default) or 12 hour mode is configured using hourFormat option. If you need to use the time picker as standalone, use the timeOnly property.
+
+<Calendar v-model="value" :showTime="true" />
+<Calendar v-model="value" :showTime="true" hourFormat="12" />
+<Calendar v-model="value" :showTime="true" :timeOnly="true" />
+
+
+
+ To disable entering dates manually, set manualInput to false and to restrict selectable dates with the minDate and maxDate options.
+
+<Calendar v-model="value" :minDate="minDateValue" maxDate="maxDateValue" />
+
+
+
+ To disable specific dates or days, restrict selectable dates use disabledDates and/or disabledDays options.
+
+<Calendar v-model="value" :disabledDates="invalidDates" :disabledDays="[0,6]" />
+
+
+
+ Button bar displays today and clear buttons and enabled using showButtonBar property.
+
+<Calendar v-model="value" :showButtonBar="true" />
+
+
+
+ Displaying multiple months is enabled by setting numberOfMonths property to a value greater than 1.
+
+<Calendar v-model="value" :numberOfMonths="3" />
+
+
+
+ Locale for different languages and formats is defined globally, refer to the
Calendar UI accepts custom content using header and footer templates.
+ +
+<Calendar v-model="value">
+ <template #header>Header Content</template>
+ <template #footer>Footer Content</template>
+</Calendar>
+
+
+
+ + In addition, cell contents can be templated using a template named "date". This is a handy feature to highlight specific dates. Note that the date property of the slot props passed to the template is not a date instance but a metadata + object to represent a Date with "day", "month" and "year" properties. Example below changes the background color of dates between 10th and 15th of each month. +
+ +
+<Calendar v-model="value">
+ <template #date="slotProps">
+ <strong v-if="slotProps.date.day > 10 && slotProps.date.day < 15" class="special-day">{{slotProps.date.day}}</strong>
+ <template v-else>{{slotProps.date.day}}</template>
+ </template>
+</Calendar>
+
+
+
+
+.special-day {
+ text-decoration: line-through;
+}
+
+
+
+ Month picker is used to select month and year only without the date, set view mode as "month" to activate month picker.
+
+<Calendar v-model="value" view="month" dateFormat="mm/yy" />
+
+
+
+ Similar to the month picker, year picker can be used to select years only. Set view to "year" to display the year picker.
+
+<Calendar v-model="value" view="year" dateFormat="yy" />
+
+
+
+ Touch UI mode displays the calendar overlay at the center of the screen as optimized for touch devices.
+
+<Calendar v-model="value" :touchUI="true" />
+
+
+
+ Any property such as name and placeholder are passed to the underlying input element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
selectionMode | +string | +single | +Defines the quantity of the selection, valid values are "single", "multiple" and "range". | +
dateFormat | +string | +null | +Format of the date. Defaults to PrimeVue |
+
inline | +boolean | +false | +When enabled, displays the calendar as inline instead of an overlay. | +
disabled | +boolean | +false | +When specified, disables the component. | +
readonly | +boolean | +false | +When present, it specifies that an input field is read-only. | +
showOtherMonths | +boolean | +true | +Whether to display dates in other months (non-selectable) at the start or end of the current month. To make these days selectable use the selectOtherMonths option. | +
selectOtherMonths | +boolean | +false | +Whether days in other months shown before or after the current month are selectable. This only applies if the showOtherMonths option is set to true. | +
showIcon | +boolean | +false | +When enabled, displays a button with icon next to input. | +
icon | +string | +pi pi-calendar | +Icon of the calendar button. | +
numberOfMonths | +number | +1 | +Number of months to display. | +
responsiveOptions | +any | +null | +An array of options for responsive design. | +
view | +string | +date | +Type of view to display, valid values are "date", "month" and "year". | +
touchUI | +boolean | +false | +When enabled, calendar overlay is displayed as optimized for touch devices. | +
monthNavigator | +boolean | +false | +
+ Whether the month should be rendered as a dropdown instead of text. + + Deprecated: Navigator is always on + |
+
yearNavigator | +boolean | +false | +
+ Whether the year should be rendered as a dropdown instead of text. + + Deprecated: Navigator is always on. + |
+
yearRange | +string | +null | +
+ The range of years displayed in the year drop-down in (nnnn:nnnn) format such as (2000:2020). + Deprecated: Years are based on decades by default. + |
+
minDate | +Date | +null | +The minimum selectable date. | +
maxDate | +Date | +null | +The maximum selectable date. | +
disabledDates | +array; | +null | +Array with dates to disable. | +
disabledDays | +array | +null | +Array with disabled weekday numbers. | +
maxDateCount | +number | +null | +Maximum number of selectable dates in multiple mode. | +
showOnFocus | +boolean | +true | +When disabled, datepicker will not be visible with input focus. | +
autoZIndex | +boolean | +true | +Whether to automatically manage layering. | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
showButtonBar | +boolean | +false | +Whether to display today and clear buttons at the footer | +
shortYearCutoff | +string | ++10 | +The cutoff year for determining the century for a date. | +
showTime | +boolean | +false | +Whether to display timepicker. | +
timeOnly | +boolean | +false | +Whether to display timepicker only. | +
hourFormat | +string | +24 | +Specifies 12 or 24 hour format. | +
stepHour | +number | +1 | +Hours to change per step. | +
stepMinute | +number | +1 | +Minutes to change per step. | +
stepSecond | +number | +1 | +Seconds to change per step. | +
showSeconds | +boolean | +false | +Whether to show the seconds in time picker. | +
hideOnDateTimeSelect | +boolean | +false | +Whether to hide the overlay on date selection when showTime is enabled. | +
hideOnRangeSelection | +boolean | +false | +Whether to hide the overlay on date selection is completed when selectionMode is range. | +
timeSeparator | +string | +: | +Separator of time selector. | +
showWeek | +boolean | +false | +When enabled, calendar will show week numbers. | +
manualInput | +boolean | +true | +Wheter to allow prevents entering the date manually via typing. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. Special keywords are "body" for document body and "self" for the element itself. | +
disabled | +boolean | +false | +When present, it specifies that the element should be disabled. | +
readonly | +boolean | +false | +When present, it specifies that an input field is read-only. | +
placeholder | +string | +null | +Default text to display when no option is selected. | +
id | +string | +null | +Unique identifier of the element. | +
inputId | +string | +null | +Style class of the component input field. | +
inputStyle | +any | +null | +Inline style of the input field. | +
inputClass | +string | +null | +Style class of the input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component. | +
panelClass | +string | +null | +Style class of the overlay panel. | +
panelStyle | +string | +null | +Inline style of the overlay panel. | +
panelProps | +object | +null | +Uses to pass all properties of the HTMLDivElement to the overlay panel inside the component. | +
Any valid event such as focus, blur and input are passed to the underlying input element. Following are the additional events to configure the component.
+Name | +Parameters | +Description | +
---|---|---|
input | +event: Input Event | +Callback to invoke when input field is being typed. | +
date-select | +value: Selected value | +Callback to invoke when a date is selected. | +
show | +- | +Callback to invoke when datepicker panel is shown. | +
hide | +- | +Callback to invoke when datepicker panel is hidden. | +
today-click | +date: Today as a date instance | +Callback to invoke when today button is clicked. | +
clear-click | +event: Click event | +Callback to invoke when clear button is clicked. | +
month-change | +
+ event.month: New month + event.year: New year + |
+ Callback to invoke when a month is changed using the navigators. | +
year-change | +
+ event.month: New month + event.year: New year + |
+ Callback to invoke when a year is changed using the navigators. | +
focus | +event: Focus event | +Callback to invoke on focus of input field. | +
blur | +
+ event.originalEvent: Blur event + event.value: Input value + |
+ Callback to invoke on blur of input field. | +
keydown | +event: Keyboard event | +Callback to invoke when a key is pressed. | +
Name | +Parameters | +
---|---|
header | +- | +
footer | +- | +
date | +date: Value of the component | +
decade | +years: An array containing the start and and year of a decade to display at header of the year picker | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-calendar | +Main container element | +
p-calendar-w-btn | +Main container element when button is enabled. | +
p-calendar-timeonly | +Main container element in time picker only mode. | +
p-inputtext | +Input element | +
p-datepicker | +Datepicker element | +
p-datepicker-inline | +Datepicker element in inline mode | +
p-monthpicker | +Datepicker element in month view. | +
p-monthpicker-month | +Month cell in month view mode. | +
p-datepicker-touch-ui | +Datepicker element in touch ui mode. | +
p-datepicker-calendar | +Table containing dates of a month. | +
p-datepicker-current-day | +Cell of selected date. | +
p-datepicker-today | +Cell of today's date. | +
+ Value to describe the component can either be provided via label tag combined with inputId prop or using aria-labelledby, aria-label props. The input element has combobox role in addition to + aria-autocomplete as "none", aria-haspopup as "dialog" and aria-expanded attributes. The relation between the input and the popup is created with aria-controls attribute that refers to the id of the popup. +
+
+ The optional calendar button requires includes aria-haspopup, aria-expanded for states along with aria-controls to define the relation between the popup and the button. The value to read is retrieved from the
+ chooseDate key of the aria property from the
+ Popup has a dialog role along with aria-modal and aria-label. The navigation buttons at the header has an aria-label retrieved from the prevYear, nextYear, prevMonth, nextMonth, + prevDecade and nextDecade keys of the locale aria API. Similarly month picker button uses the chooseMonth and year picker button uses the chooseYear keys. +
+ ++ Main date table uses grid role that contains th elements with col as the scope along with abbr tag resolving to the full name of the month. Each date cell has an aria-label referring to the full date value. + Buttons at the footer utilize their readable labels as aria-label as well. Selected date also receives the aria-selected attribute. +
+ ++ Timepicker spinner buttons get their labels for aria-label from the aria locale API using the prevHour, nextHour, prevMinute, nextMinute, prevSecond, nextSecond, am and + pm keys. +
+ +Calendar also includes a hidden section that is only available to screen readers with aria-live as "polite". This element is updated when the selected date changes to instruct the user about the current date selected.
+ +
+<label for="date1">Date</label>
+<Calendar inputId="date1" />
+
+<span id="date2">Date</span>
+<Calendar aria-labelledby="date2" />
+
+<Calendar aria-label="Date" />
+
+
+
+ Key | +Function | +
---|---|
space | +Opens popup and moves focus to the selected date, if there is none focuses on today. | +
enter | +Opens popup and moves focus to the selected date, if there is none focuses on today. | +
Key | +Function | +
---|---|
escape | +Closes the popup and moves focus to the input element. | +
tab | +Moves focus to the next focusable element within the popup. | +
shift + tab | +Moves focus to the next focusable element within the popup. | +
Key | +Function | +
---|---|
enter | +Triggers the button action. | +
space | +Triggers the button action. | +
Key | +Function | +
---|---|
enter | +Selects the date, closes the popup and moves focus to the input element. | +
space | +Selects the date, closes the popup and moves focus to the input element. | +
up arrow | +Moves focus to the same day of the previous week. | +
down arrow | +Moves focus to the same day of the next week. | +
right arrow | +Moves focus to the next day. | +
left arrow | +Moves focus to the previous day. | +
home | +Moves focus to the first day of the current week. | +
end | +Moves focus to the last day of the current week. | +
page up | +Changes the date to previous month in date picker mode. Moves to previous year in month picker mode and previous decade in year picker. | +
shift + page up | +Changes the date to previous year in date picker mode. Has no effect in month or year picker | +
page down | +Changes the date to next month in date picker mode. Moves to next year in month picker mode and next decade in year picker. | +
shift + page down | +Changes the date to next year in date picker mode. Has no effect in month or year picker | +
Key | +Function | +
---|---|
enter | +Triggers the button action. | +
space | +Triggers the button action. | +
None.
+Calendar is an input component to select a date.
+
+import Card from 'primevue/card';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/card/card.min.js"></script>
+
+
+
+ Card provides header, title, subtitle, content and footer as the named templates to place content.
+
+<Card>
+ <template #header>
+ <img alt="user header" src="demo/images/usercard.png">
+ </template>
+ <template #title>
+ Advanced Card
+ </template>
+ <template #content>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt
+ quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque quas!
+ </template>
+ <template #footer>
+ <Button icon="pi pi-check" label="Save" />
+ <Button icon="pi pi-times" label="Cancel" class="p-button-secondary" style="margin-left: .5em" />
+ </template>
+</Card>
+
+
+
+ Name | +Parameters | +
---|---|
header | +- | +
title | +- | +
subtitle | +- | +
content | +- | +
footer | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-card | +Container element. | +
p-card-title | +Title element. | +
p-card-subtitle | +Subtitle element. | +
p-card-content | +Content of the card. | +
p-card-footer | +Footer of the card. | +
+ A card can be utilized in many use cases as a result no role is enforced, in fact a role may not be necessary if the card is used for presentational purposes only. Any valid attribute is passed to the container element so if you + require to use one of the landmark roles like region, you may use the role property. +
+ +
+<Card role="region">
+ Content
+</Card>
+
+
+
+ Component does not include any interactive elements.
+None.
+Card is a flexible container component.
++ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque + quas! +
+ ++ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque + quas! +
+ + + + + +
+import Carousel from 'primevue/carousel';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/carousel/carousel.min.js"></script>
+
+
+
+ Carousel requires a collection of items as its value along with a template to render each item.
+
+<Carousel :value="cars">
+ <template #item="slotProps">
+ </template>
+</Carousel>
+
+
+
+ Number of items per page is defined using the numVisible property whereas number of items to scroll is defined with the numScroll property.
+
+<Carousel :value="cars" :numVisible="3" :numScroll="1">
+ <template #item="slotProps">
+ </template>
+</Carousel>
+
+
+
+ For responsive design, numVisible and numScroll can be defined using the responsiveOptions property that should be an array of objects whose breakpoint defines the max-width to apply the settings.
+
+<Carousel :value="cars" :numVisible="4" :numScroll="3" :responsiveOptions="responsiveOptions">
+ <template #header>
+ <h2>Basic</h2>
+ </template>
+ <template #item="slotProps">
+ <div class="car-item">
+ <div class="car-content">
+ <div>
+ <img :src="'demo/images/car/' + slotProps.data.brand + '.png'" :alt="slotProps.data.brand" />
+ </div>
+ <div>
+ <div class="car-title">{{slotProps.data.brand}}</div>
+ <div class="car-subtitle">{{slotProps.data.year}} | {{slotProps.data.color}}</div>
+
+ <div class="car-buttons">
+ <Button icon="pi pi-search" class="p-button-secondary" />
+ <Button icon="pi pi-star-fill" class="p-button-secondary" />
+ <Button icon="pi pi-cog" class="p-button-secondary" />
+ </div>
+ </div>
+ </div>
+ </div>
+ </template>
+</Carousel>
+
+
+
+data() {
+ return {
+ responsiveOptions: [
+ {
+ breakpoint: '1024px',
+ numVisible: 3,
+ numScroll: 3
+ },
+ {
+ breakpoint: '600px',
+ numVisible: 2,
+ numScroll: 2
+ },
+ {
+ breakpoint: '480px',
+ numVisible: 1,
+ numScroll: 1
+ }
+ ]
+ }
+},
+
+
+
+ Custom content projection is available using the item, header and footer templates.
+ +
+<Carousel :value="cars" :numVisible="3" :numScroll="1" :responsiveOptions="responsiveOptions">
+ <template #header>
+ <h2>Custom Header</h2>
+ </template>
+ <template #item="slotProps">
+ Content
+ </template>
+ <template #footer>
+ <h2>Custom Footer</h2>
+ </template>
+</Carousel>
+
+
+
+ Default layout of the Carousel is horizontal, other possible option is the vertical mode that is configured with the orientation property.
+
+<Carousel :value="cars" :numVisible="1" :numScroll="1" orientation="vertical" verticalViewPortHeight="330px" :responsiveOptions="responsiveOptions">
+ <template #item="slotProps">
+ Content
+ </template>
+</Carousel>
+
+
+
+ When autoplayInterval is defined in milliseconds, items are scrolled automatically. In addition, for infinite scrolling circular property needs to be enabled. Note that in autoplay mode, circular is enabled by default.
+
+<Carousel :value="cars" :numVisible="3" :numScroll="1" :circular="true" :autoplayInterval="3000">
+ <template #header>
+ <h2>Circular, AutoPlay</h2>
+ </template>
+ <template #item="slotProps">
+ Content
+ </template>
+</Carousel>
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
value | +array | +null | +An array of objects to display. | +
page | +number | +null | +Index of the first item. | +
circular | +boolean | +false | +Defines if scrolling would be infinite. | +
autoplayInterval | +number | +null | +Time in milliseconds to scroll items automatically. | +
numVisible | +number | +1 | +Number of items per page. | +
numScroll | +number | +1 | +Number of items to scroll. | +
responsiveOptions | +any | +null | +An array of options for responsive design. | +
orientation | +string | +horizontal | +Specifies the layout of the component, valid values are "horizontal" and "vertical". | +
verticalViewPortHeight | +string | +300px | +Height of the viewport in vertical layout. | +
contentClass | +string | +null | +Style class of main content. | +
containerClass | +string | +null | +Style class of the viewport container. | +
indicatorsContentClass | +string | +null | +Style class of the indicator items. | +
showNavigators | +boolean | +true | +Whether to display navigation buttons in container. | +
showIndicators | +boolean | +true | +Whether to display indicator container. | +
Name | +Parameters | +
---|---|
header | +- | +
item | +
+ data: Data of the component + index: Index of the item + |
+
footer | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-carousel | +Container element. | +
p-carousel-header | +Header section. | +
p-carousel-footer | +Footer section. | +
p-carousel-content | +Main content element. It contains the container of the viewport. | +
p-carousel-container | +Container of the viewport. It contains navigation buttons and viewport. | +
p-carousel-items-content | +Viewport. | +
p-carousel-indicators | +Container of the indicators. | +
p-carousel-indicator | +Indicator element. | +
None.
+Carousel is a content slider featuring various customization options.
+
+import CascadeSelect from 'primevue/cascadeselect';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/cascadeselect/cascadeselect.min.js"></script>
+
+
+
+ + CascadeSelect requires a value to bind and a collection of arbitrary objects with a nested hierarchy. optionGroupLabel is used for the text of a category and optionGroupChildren is to define the children of the category. + Note that order of the optionGroupChildren matters and it should correspond to the data hierarchy. +
+ +
+<CascadeSelect v-model="selectedCity" :options="countries" optionLabel="cname" optionGroupLabel="name"
+ :optionGroupChildren="['states', 'cities']" style="minWidth: 14rem" >
+
+
+
+
+data() {
+ return {
+ selectedCity: null,
+ countries: [
+ {
+ name: 'Australia',
+ code: 'AU',
+ states: [
+ {
+ name: 'New South Wales',
+ cities: [
+ {cname: 'Sydney', code: 'A-SY'},
+ {cname: 'Newcastle', code: 'A-NE'},
+ {cname: 'Wollongong', code: 'A-WO'}
+ ]
+ },
+ {
+ name: 'Queensland',
+ cities: [
+ {cname: 'Brisbane', code: 'A-BR'},
+ {cname: 'Townsville', code: 'A-TO'}
+ ]
+ },
+
+ ]
+ },
+ {
+ name: 'Canada',
+ code: 'CA',
+ states: [
+ {
+ name: 'Quebec',
+ cities: [
+ {cname: 'Montreal', code: 'C-MO'},
+ {cname: 'Quebec City', code: 'C-QU'}
+ ]
+ },
+ {
+ name: 'Ontario',
+ cities: [
+ {cname: 'Ottawa', code: 'C-OT'},
+ {cname: 'Toronto', code: 'C-TO'}
+ ]
+ },
+
+ ]
+ },
+ {
+ name: 'United States',
+ code: 'US',
+ states: [
+ {
+ name: 'California',
+ cities: [
+ {cname: 'Los Angeles', code: 'US-LA'},
+ {cname: 'San Diego', code: 'US-SD'},
+ {cname: 'San Francisco', code: 'US-SF'}
+ ]
+ },
+ {
+ name: 'Florida',
+ cities: [
+ {cname: 'Jacksonville', code: 'US-JA'},
+ {cname: 'Miami', code: 'US-MI'},
+ {cname: 'Tampa', code: 'US-TA'},
+ {cname: 'Orlando', code: 'US-OR'}
+ ]
+ },
+ {
+ name: 'Texas',
+ cities: [
+ {cname: 'Austin', code: 'US-AU'},
+ {cname: 'Dallas', code: 'US-DA'},
+ {cname: 'Houston', code: 'US-HO'}
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
+
+
+
+ Content of an item can be customized with the option template.
+ +
+<CascadeSelect v-model="selectedCity" :options="countries" optionLabel="cname" optionGroupLabel="name"
+ :optionGroupChildren="['states', 'cities']" style="minWidth: 14rem">
+ <template #option="slotProps">
+ <div class="country-item">
+ <img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + slotProps.option.code.toLowerCase()" v-if="slotProps.option.states" />
+ <i class="pi pi-compass mr-2" v-if="slotProps.option.cities"></i>
+ <i class="pi pi-map-marker mr-2" v-if="slotProps.option.cname"></i>
+ <span>{{slotProps.option.cname || slotProps.option.name}}</span>
+ </div>
+ </template>
+</CascadeSelect>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
options | +array | +null | +An array of selectitems to display as the available options. | +
optionLabel | +string | function | +null | +Property name or getter function to use as the label of an option. | +
optionValue | +string | function | +null | +Property name or getter function to use as the value of an option, defaults to the option itself when not defined. | +
optionDisabled | +string | function | +null | +Property name or getter function to use as the disabled flag of an option, defaults to false when not defined. | +
optionGroupLabel | +string | function | +null | +Property name or getter function to use as the label of an option group. | +
optionGroupChildren | +array | function | +null | +Property name or getter function to retrieve the items of a group. | +
placeholder | +string | +null | +Default text to display when no option is selected. | +
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +
dataKey | +string | +null | +A property to uniquely identify an option. | +
inputId | +string | +null | +Identifier of the underlying input element. | +
inputStyle | +any | +null | +Inline style of the input field. | +
inputClass | +string | +null | +Style class of the input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement/HTMLSpanElement to the focusable input element inside the component. | +
panelStyle | +any | +null | +Inline style of the overlay panel. | +
panelClass | +string | +null | +Style class of the overlay panel. | +
panelProps | +object | +null | +Uses to pass all properties of the HTMLDivElement to the overlay panel. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. Special keywords are "body" for document body and "self" for the element itself. | +
loading | +boolean | +false | +Whether the dropdown is in loading state. | +
loadingIcon | +string | +pi pi-spinner pi-spin | +Icon to display in loading state. | +
autoOptionFocus | +boolean | +true | +Whether to focus on the first visible or selected element when the overlay panel is shown. | +
selectOnFocus | +boolean | +false | +When enabled, the focused option is selected/opened. | +
searchLocale | +string | +undefined | +Locale to use in searching. The default locale is the host environment's current locale. | +
searchMessage | +string | +{0} results are available | +Text to be displayed in hidden accessible field when filtering returns any results. Defaults to value from PrimeVue locale configuration. | +
selectionMessage | +string | +{0} items selected | +Text to be displayed in hidden accessible field when options are selected. Defaults to value from PrimeVue locale configuration. | +
emptySelectionMessage | +string | +No selected item | +Text to be displayed in hidden accessible field when any option is not selected. Defaults to value from PrimeVue locale configuration. | +
emptySearchMessage | +string | +No results found | +Text to be displayed when filtering does not return any results. Defaults to value from PrimeVue locale configuration. | +
emptyMessage | +string | +No available options | +Text to be displayed when there are no options available. Defaults to value from PrimeVue locale configuration. | +
tabindex | +number | +0 | +Index of the element in tabbing order. | +
aria-label | +string | +null | +Defines a string value that labels an interactive element. | +
aria-labelledby | +string | +null | +Establishes relationships between the component and label(s) where its value should be one or more element IDs. | +
Name | +Parameters | +Description | +
---|---|---|
change | +
+ event.originalEvent: Original event + event.value: Selected option value + |
+ Callback to invoke on value change. | +
focus | +event | +Callback to invoke when the component receives focus. | +
blur | +event | +Callback to invoke when the component loses focus. | +
click | +event | +Callback to invoke on click. | +
group-change | +
+ event.originalEvent: Original event + event.value: Selected option group + |
+ Callback to invoke when a group changes. | +
before-show | +- | +Callback to invoke before the overlay is shown. | +
before-hide | +- | +Callback to invoke before the overlay is hidden. | +
show | +- | +Callback to invoke when the overlay is shown. | +
hide | +- | +Callback to invoke when the overlay is hidden. | +
Name | +Parameters | +
---|---|
value | +
+ value: Value of the component + placeholder: Placeholder text to show + |
+
option | +option: Option instance | +
indicator | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-cascadeselect | +Container element. | +
p-cascadeselect-label | +Element to display label of selected option. | +
p-cascadeselect-trigger | +Icon element. | +
p-cascadeselect-panel | +Icon element. | +
p-cascadeselect-items-wrapper | +Wrapper element of items list. | +
p-cascadeselect-items | +List element of items. | +
p-cascadeselect-item | +An item in the list. | +
p-overlay-open | +Container element when overlay is visible. | +
+ Value to describe the component can either be provided with aria-labelledby or aria-label props. The cascadeselect element has a combobox role in addition to aria-haspopup and aria-expanded attributes. + The relation between the combobox and the popup is created with aria-controls that refers to the id of the popup. +
++ The popup list has an id that refers to the aria-controls attribute of the combobox element and uses tree as the role. Each list item has a treeitem role along with aria-label, aria-selected and + aria-expanded attributes. The container element of a treenode has the group role. The aria-setsize, aria-posinset and aria-level attributes are calculated implicitly and added to each treeitem. +
+ +
+<span id="dd1">Options</span>
+<CascadeSelect aria-labelledby="dd1" />
+
+<CascadeSelect aria-label="Options" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the cascadeselect element. | +
space | +Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. | +
enter | +Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. | +
down arrow | +Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. | +
up arrow | +Opens the popup and moves visual focus to the selected option, if there is none then last option receives the focus. | +
any printable character | +Opens the popup and moves focus to the option whose label starts with the characters being typed, if there is none then first option receives the focus. | +
Key | +Function | +
---|---|
tab | +Hides the popup and moves focus to the next tabbable element. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. | +
shift + tab | +Hides the popup and moves focus to the previous tabbable element. | +
enter | +Selects the focused option and closes the popup. | +
space | +Selects the focused option and closes the popup. | +
escape | +Closes the popup, moves focus to the cascadeselect element. | +
down arrow | +Moves focus to the next option. | +
up arrow | +Moves focus to the previous option. | +
alt + up arrow | +Selects the focused option and closes the popup, then moves focus to the cascadeselect element. | +
right arrow | +If option is closed, opens the option otherwise moves focus to the first child option. | +
left arrow | +If option is open, closes the option otherwise moves focus to the parent option. | +
home | +Moves input cursor at the end, if not then moves focus to the first option. | +
end | +Moves input cursor at the beginning, if not then moves focus to the last option. | +
any printable character | +Moves focus to the option whose label starts with the characters being typed. | +
None.
+CascadeSelect is a form component to select a value from a nested structure of options.
+A bar chart or bar graph is a chart that presents grouped data with rectangular bars with lengths proportional to the values that they represent.
+Chart components are based on Charts.js, an open source HTML5 based charting library.
+ ++ Chart component is a wrapper around on Chart.js 3.3.2+ so chart.js needs to be included in your project. For a complete documentation and samples please refer to the + chart.js website. +
+
+npm install chart.js --save
+
+
+
+
+import Chart from 'primevue/chart';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/chart/chart.min.js"></script>
+
+
+
+ Chart type is defined using the type property. Currently there are 6 options available; pie, doughnut, line, bar, radar and polarArea.
+ ++ Data of a chart is provided using a binding to the data property, each type has its own format of data. Here is an example of a line chart. For more information refer to the + charts.js documentation. +
+
+<Chart type="bar" :data="basicData" />
+
+
+
+
+export default {
+ data() {
+ return {
+ basicData: {
+ labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
+ datasets: [
+ {
+ label: 'My First dataset',
+ backgroundColor: '#42A5F5',
+ data: [65, 59, 80, 81, 56, 55, 40]
+ },
+ {
+ label: 'My Second dataset',
+ backgroundColor: '#9CCC65',
+ data: [28, 48, 40, 19, 86, 27, 90]
+ }
+ ]
+ }
+ }
+ }
+}
+
+
+
+ + While a series can be customized per dataset, general chart options are defined with options property. Example below adds a title and customizes the legend position of the chart. For all available options refer to the + charts.js documentation. +
+
+<Chart type="line" :data="data" :options="options" />
+
+
+
+
+options: {
+ responsive: true,
+ hoverMode: 'index',
+ stacked: false,
+ scales: {
+ yAxes: [{
+ type: 'linear',
+ display: true,
+ position: 'left',
+ id: 'y-axis-1',
+ },
+ {
+ type: 'linear',
+ display: true,
+ position: 'right',
+ id: 'y-axis-2',
+ gridLines: {
+ drawOnChartArea: false
+ }
+ }]
+ }
+}
+
+
+
+ Any property as style and class are passed to the main container element. Following is the additional property to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
type | +string | +null | +Type of the chart. | +
data | +any | +null | +Data to display. | +
options | +any | +null | +Options to customize the chart. | +
plugins | +any | +null | +Used to custom plugins of the chart. | +
width | +number | +300 | +Width of the chart in non-responsive mode. | +
height | +number | +150 | +Height of the chart in non-responsive mode. | +
Name | +Parameters | +Description | +
---|---|---|
refresh | +- | +Redraws the graph. | +
reinit | +- | +Destroys the graph first and then creates it again. | +
generateLegend | +- | +Returns an HTML string of a legend for that chart. The legend is generated from the legendCallback in the options. | +
Name | +Parameters | +Description | +
---|---|---|
select | +
+ event: original event + event.dataset: Selected dataset + event.element: Selected element + event.element._datasetIndex = Index of the dataset in data + event.element._index = Index of the data in dataset + |
+ Callback to invoke when a tab gets expanded. | +
loaded | +chart instance | +Callback to invoke when chart is loaded. | +
Name | +Element | +
---|---|
p-chart | +Container element. | +
Different chart types can be combined in the same graph.
+A doughnut chart is a variant of the pie chart, with a blank center allowing for additional information about the data as a whole to be included.
+A line chart or line graph is a type of chart which displays information as a series of data points called 'markers' connected by straight line segments.
+A pie chart is a circular statistical graphic, which is divided into slices to illustrate numerical proportion.
+Polar area charts are similar to pie charts, but each segment has the same angle - the radius of the segment differs depending on the value.
+A radar chart is a graphical method of displaying multivariate data in the form of a two-dimensional chart of three or more quantitative variables represented on axes starting from the same point.
+
+import Checkbox from 'primevue/checkbox';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/checkbox/checkbox.min.js"></script>
+
+
+
+ Checkbox can either be used in multiple selection with other checkboxes or as a single checkbox to provide a boolean value.
+
+<Checkbox v-model="checked" :binary="true" />
+
+
+
+ Multiple mode is enabled by default, v-model property refers to an array to bind the selected values.
+
+<Checkbox name="city" value="Chicago" v-model="cities" />
+<Checkbox name="city" value="Los Angeles" v-model="cities" />
+<Checkbox name="city" value="New York" v-model="cities" />
+<Checkbox name="city" value="San Francisco" v-model="cities" />
+
+
+
+
+export default {
+ data() {
+ return {
+ cities: []
+ }
+ }
+}
+
+
+
+ As v-model is two-way binding enabled, prepopulating the model array with values is enough to display the related checkboxes as checked by default.
+ +Any valid attribute is passed to the root element implicitly, extended properties are as follows;
+Name | +Type | +Default | +Description | +
---|---|---|---|
value | +any | +null | +Value of the checkbox. | +
modelValue | +any | +null | +Value binding of the checkbox. | +
name | +string | +null | +Name of the input element. | +
binary | +boolean | +false | +Allows to select a boolean value instead of multiple values. | +
trueValue | +any | +null | +Value in checked state. | +
falseValue | +any | +null | +Value in unchecked state. | +
disabled | +boolean | +false | +When present, it specifies that the element should be disabled. | +
readonly | +boolean | +false | +When present, it specifies that an input field is read-only. | +
required | +boolean | +false | +When present, it specifies that the element is required. | +
tabindex | +number | +null | +Index of the element in tabbing order. | +
inputId | +string | +null | +Identifier of the underlying input element. | +
inputClass | +any | +null | +Style class of the input field. | +
inputStyle | +any | +null | +Inline style of the input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component. | +
In addition to the following events, any other valid events such as focus and blur are passed implicitly.
+Name | +Parameters | +Description | +
---|---|---|
click | +event: Browser event | +Callback to invoke on value click. | +
change | +event: Browser event | +Callback to invoke on value change. | +
input | +value: New value | +Callback to invoke on value change. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-checkbox | +Container element | +
p-checkbox-box | +Container of icon. | +
p-checkbox-icon | +Icon element. | +
+ Checkbox component uses a hidden native checkbox element internally that is only visible to screen readers. Value to describe the component can either be provided via label tag combined with id prop or using + aria-labelledby, aria-label props. +
+ +
+<label for="chkbox1">Remember Me</label>
+<Checkbox inputId="chkbox1" />
+
+<span id="chkbox2">Remember Me</span>
+<Checkbox aria-labelledby="chkbox2" />
+
+<Checkbox aria-label="Remember Me" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the checkbox. | +
space | +Toggles the checked state. | +
None.
+Checkbox is an extension to standard checkbox element with theming.
+
+import Chip from 'primevue/chip';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/chip/chip.min.js"></script>
+
+
+
+ Chip can display labels, icons and images.
+
+<Chip label="Text Only" />
+<Chip label="Text with icon" icon="pi pi-check" />
+<Chip label="Text with image" image="user.png" />
+
+
+
+ Setting removable property displays an icon to close the chip, the optional remove event is available to get notified when a chip is hidden.
+
+<Chip label="Text" removable />
+
+
+
+ Content can easily be customized with the default slot instead of using the built-in modes.
+
+<Chip>
+ Content
+</Chip>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
label | +string | +null | +Defines the text to display. | +
icon | +string | +null | +Defines the icon to display. | +
image | +string | +null | +Defines the image to display. | +
removable | +boolean | +false | +Whether to display a remove icon. | +
removeIconClass | +string | +pi pi-times-circle | +Icon of the remove element. | +
Name | +Parameters | +Description | +
---|---|---|
remove | +event: Browser event | +Callback to invoke when a chip is removed. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-chip | +Container element. | +
p-chip-image | +Container element in image mode. | +
p-chip-text | +Text of the chip. | +
p-chip-remove-icon | +Remove icon. | +
None.
+Chip represents entities using icons, labels and images.
+
+import Chips from 'primevue/chips';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/chips/chips.min.js"></script>
+
+
+
+ An array as the value can be bound using the standard v-model directive.
+
+<Chips v-model="value" />
+
+
+
+ A chip is customized using the chip template where the chip value is passed to the slotProps with the value property.
+
+<Chips v-model="value">
+ <template #chip="slotProps">
+ <div>
+ <span>{{slotProps.value}} - (active) </span>
+ <i class="pi pi-user-plus" style="font-size: 14px"></i>
+ </div>
+ </template>
+</Chips>
+
+
+
+ Any property such as name and placeholder are passed to the underlying input element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +array | +null | +Value of the component. | +
max | +number | +null | +Maximum number of entries allowed. | +
separator | +string | +null | +Separator char to add an item when pressed in addition to the enter key. Currently only possible value is "," | +
addOnBlur | +boolean | +false | +Whether to add an item when the input loses focus. | +
allowDuplicate | +boolean | +true | +Whether to allow duplicate values or not. | +
disabled | +boolean | +false | +When present, it specifies that the element should be disabled. | +
placeholder | +string | +null | +Placeholder text for the input. | +
inputId | +string | +null | +Style class of the component input field. | +
inputClass | +string | +null | +Style class of the input field. | +
inputStyle | +any | +null | +Inline style of the input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component. | +
Any valid event such as focus, blur and input are passed to the underlying input element. Following are the additional events to configure the component.
+Name | +Parameters | +Description | +
---|---|---|
add | +
+ originalEvent: Browser event + value: Added item value + |
+ Callback to invoke when a chip is added. | +
remove | +
+ originalEvent: Browser event + value: Removed item value + |
+ Callback to invoke when a chip is removed. | +
Name | +Parameters | +
---|---|
chip | +value: Value of the component | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-chips | +Container element | +
p-chips-token | +Chip element container. | +
p-chips-token-icon | +Icon of a chip. | +
p-chips-token-label | +label of a chip. | +
p-chips-input-token | +Container of input element. | +
+ Value to describe the component can either be provided via label tag combined with inputId prop or using aria-labelledby, aria-label props. Chip list uses listbox role with aria-orientation set to + horizontal whereas each chip has the option role with aria-label set to the label of the chip. +
+ +
+<label for="chips1">Tags</label>
+<Chips inputId="chips1" />
+
+<span id="chips2">Tags</span>
+<Chips aria-labelledby="chips2" />
+
+<Chips aria-label="Tags" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the input element | +
enter | +Adds a new chips using the input field value. | +
backspace | +Deletes the previous chip if the input field is empty. | +
left arrow | +Moves focus to the previous chip if available and input field is empty. | +
Key | +Function | +
---|---|
left arrow | +Moves focus to the previous chip if available. | +
right arrow | +Moves focus to the next chip, if there is none then input field receives the focus. | +
backspace | +Deletes the chips and adds focus to the input field. | +
None.
+Chips is used to enter multiple values on an input field.
+
+import ColorPicker from 'primevue/colorpicker';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/colorpicker/colorpicker.min.js"></script>
+
+
+
+ A model can be bound using the standard v-model directive. Default color format to use in value binding is "hex" and other possible values are "rgb" and "hsb".
+
+<ColorPicker v-model="color" />
+
+
+
+
+export default {
+ data() {
+ return {
+ color2: '1976D2'
+ }
+ }
+}
+
+
+
+ ColorPicker is displayed as an overlay with a preview option by default where second alternative is the inline mode.
+
+<ColorPicker v-model="color" :inline="true" />
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
defaultColor | +string | +ff0000 | +Initial color to display when value is not defined. | +
inline | +boolean | +false | +Whether to display as an overlay or not. | +
format | +string | +hex | +Format to use in value binding, supported formats are "hex", "rgb" and "hsb". | +
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +
tabindex | +string | +null | +Index of the element in tabbing order. | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
autoZIndex | +boolean | +true | +Whether to automatically manage layering. | +
panelClass | +string | +null | +Style class of the overlay panel. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. Special keywords are "body" for document body and "self" for the element itself. | +
Name | +Parameters | +Description | +
---|---|---|
change | +
+ event.originalEvent: Browser event + event.value: Selected color + |
+ Callback to invoke when a color is selected. | +
show | +- | +Callback to invoke when popup is shown. | +
hide | +- | +Callback to invoke when popup is hidden. | +
Following is the list style classed of the component.
+Name | +Element | +
---|---|
p-colorpicker | +Container element. | +
p-colorpicker-overlay | +Container element in overlay mode. | +
p-colorpicker-preview | +Preview input in overlay mode. | +
p-colorpicker-panel | +Panel element of the colorpicker. | +
p-colorpicker-content | +Wrapper that contains color and hue sections. | +
p-colorpicker-color-selector | +Color selector container. | +
p-colorpicker-color | +Color element. | +
p-colorpicker-color-handle | +Handle of the color element. | +
p-colorpicker-hue | +Hue slider. | +
p-colorpicker-hue-handle | +Handle of the hue slider. | +
+ Specification does not cover a color picker yet and using a semantic native color picker is not consistent across browsers so currently component is not compatible with screen readers. + In the upcoming versions, text fields will be introduced below the slider section to be able to pick a color using accessible text boxes in hsl, rgba and hex formats. +
+ +Key | +Function | +
---|---|
tab | +Moves focus to the color picker button. | +
space | +Opens the popup and moves focus to the color slider. | +
Key | +Function | +
---|---|
enter | +Selects the color and closes the popup. | +
space | +Selects the color and closes the popup. | +
escape | +Closes the popup, moves focus to the input. | +
Key | +Function | +
---|---|
arrow keys | +Changes color. | +
Key | +Function | +
---|---|
+ + up arrow + down arrow + + | +Changes hue. | +
None.
+ColorPicker is an input component to select a color.
+Each PrimeVue theme exports its own color palette.
+ +Colors are exported as CSS variables and used with the standard var syntax such as var(--text-color).
+ +
+<span :style="{color:var(--text-color)}"></span>
+
+
+
+ These are common variables used throughout the theme.
+ +Variable | +Description | +
---|---|
--text-color | +Font text color. | +
--text-color-secondary | +Muted font text color with a secondary level. | +
--primary-color | +Primary color of the theme. | +
--primary-color-text | +Text color when background is primary color. | +
--font-family | +Font family of the theme. | +
--inline-spacing | +Spacing between to adjacent items. | +
--border-radius | +Common border radius of elements. | +
--focus-ring | +Box shadow of a focused element. | +
--mask-bg | +Background of an overlay mask. | +
A palette consists of 9 colors where each color provides tints/shades from 50 to 900.
+ +
+<div :style="{backgroundColor:var(--blue-500)}"></div>
+
+
+
+ In addition, a theme brings a special palette called surfaces that can be used as the base when designing the surface layers and separators.
+A theme also exports named surfaces for common use cases.
+Variable | +Description | +
---|---|
--surface-ground | +Base ground color. | +
--surface-section | +Color of a section on a ground surface. | +
--surface-card | +Color of a surface used as a card. | +
--surface-overlay | +Color of overlay surfaces. | +
--surface-border | +Color of a divider. | +
--surface-hover | +Color of an element in hover state. | +
ConfirmDialog is controlled via the ConfirmationService that needs to be installed globally before the application instance is created.
+
+import {createApp} from 'vue';
+import ConfirmationService from 'primevue/confirmationservice';
+
+const app = createApp(App);
+app.use(ConfirmationService);
+
+
+
+
+import ConfirmDialog from 'primevue/confirmdialog';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/confirmdialog/confirmdialog.min.js"></script>
+
+
+
+ + ConfirmDialog is displayed by calling the require method of the $confirm instance by passing the options to customize the Dialog. Suggested location of the Dialog is the main application component where it can be shared by + any component within the application. +
+
+<ConfirmDialog></ConfirmDialog>
+
+<Button @click="delete()" icon="pi pi-check" label="Confirm"></Button>
+
+
+
+
+export default {
+ methods: {
+ delete() {
+ this.$confirm.require({
+ message: 'Are you sure you want to proceed?',
+ header: 'Confirmation',
+ icon: 'pi pi-exclamation-triangle',
+ accept: () => {
+ //callback to execute when user confirms the action
+ },
+ reject: () => {
+ //callback to execute when user rejects the action
+ }
+ });
+ },
+ }
+}
+
+
+
+ The service can be injected with the useConfirm function.
+
+import { defineComponent } from "vue";
+import { useConfirm } from "primevue/useconfirm";
+
+export default defineComponent({
+ setup() {
+ const confirm = useConfirm();
+ confirm.require({
+ message: 'Are you sure you want to proceed?',
+ header: 'Confirmation',
+ icon: 'pi pi-exclamation-triangle',
+ accept: () => {
+ //callback to execute when user confirms the action
+ },
+ reject: () => {
+ //callback to execute when user rejects the action
+ }
+ });
+ }
+})
+
+
+
+ The dialog can also be hidden programmatically using the close method.
+
+export default {
+ methods: {
+ discard() {
+ this.$confirm.close();
+ }
+ }
+}
+
+
+
+ Templating allows customizing the content where the message instance is available as the implicit variable.
+
+<ConfirmPopup group="demo">
+ <template #message="slotProps">
+ <div class="flex p-4">
+ <i :class="slotProps.message.icon" style="font-size: 1.5rem"></i>
+ <p class="pl-2">{{slotProps.message.message}}</p>
+ </div>
+ </template>
+</ConfirmPopup>
+
+
+
+
+ + ConfirmDialog width can be adjusted per screen size with the breakpoints option. In example below, default width is set to 50vw and below 961px, width would be 75vw and finally below 641px width becomes 100%. The value of + breakpoints should be an object literal whose keys are the maximum screen sizes and values are the widths per screen. +
+
+<ConfirmDialog :breakpoints="{'960px': '75vw', '640px': '100vw'}" :style="{width: '50vw'}"></ConfirmDialog>
+
+
+
+ ConfirmDialog can be customized with various options listed here.
+Name | +Type | +Default | +Description | +
---|---|---|---|
message | +string | +null | +Message of the confirmation. | +
group | +string | +null | +Optional key to match the key of the confirmation, useful to target a specific confirm dialog instance. | +
icon | +string | +null | +Icon to display next to the message. | +
header | +string | +null | +Header text of the dialog. | +
position | +string | +center | +Position of the dialog, options are "center", "top", "bottom", "left", "right", "topleft", "topright", "bottomleft" or "bottomright". | +
accept | +Function | +null | +Callback to execute when action is confirmed. | +
reject | +Function | +null | +Callback to execute when action is rejected. | +
acceptLabel | +string | +null | +Label of the accept button. Defaults to PrimeVue |
+
rejectLabel | +string | +null | +Label of the reject button. Defaults to PrimeVue |
+
acceptIcon | +string | +null | +Icon of the accept button. | +
rejectIcon | +string | +null | +Icon of the reject button. | +
acceptClass | +string | +null | +Style class of the accept button. | +
rejectClass | +string | +null | +Style class of the reject button. | +
blockScroll | +boolean | +true | +Whether background scroll should be blocked when dialog is visible. | +
defaultFocus | +string | +accept | +Element to receive the focus when the dialog gets visible, valid values are "accept" and "reject". | +
Name | +Parameters | +Description | +
---|---|---|
require | +confirm: Confirmation Object | +Displays the dialog using the confirmation object options. | +
close | +- | +Hides the dialog without invoking accept or reject callbacks. | +
Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
group | +string | +null | +Optional key to match the key of the confirmation, useful to target a specific confirm dialog instance. | +
breakpoints | +object | +null | +Object literal to define widths per screen size. | +
Name | +Parameters | +
---|---|
message | +- | +
ConfirmDialog inherits all the classes from the Dialog component, visit
Name | +Element | +
---|---|
p-confirm-dialog | +Container element. | +
None.
+ConfirmDialog uses a Dialog UI that is integrated with the Confirmation API.
+{{ slotProps.message.message }}
+ConfirmPopup is controlled via the ConfirmationService that needs to be installed globally before the application instance is created.
+
+import {createApp} from 'vue';
+import ConfirmationService from 'primevue/confirmationservice';
+
+const app = createApp(App);
+app.use(ConfirmationService);
+
+
+
+
+import ConfirmPopup from 'primevue/confirmpopup';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/confirmpopup/confirmpopup.min.js"></script>
+
+
+
+ ConfirmPopup is displayed by calling the require method of the $confirm instance by passing the options to customize the Popup. target attribute is mandatory to align the popup to its caller.
+
+<ConfirmPopup></ConfirmPopup>
+
+<Button @click="delete($event)" icon="pi pi-check" label="Confirm"></Button>
+
+
+
+
+export default {
+ methods: {
+ delete(event) {
+ this.$confirm.require({
+ target: event.currentTarget,
+ message: 'Are you sure you want to proceed?',
+ icon: 'pi pi-exclamation-triangle',
+ accept: () => {
+ //callback to execute when user confirms the action
+ },
+ reject: () => {
+ //callback to execute when user rejects the action
+ }
+ });
+ },
+ }
+}
+
+
+
+ The service can be injected with the useConfirm function.
+
+import { defineComponent } from "vue";
+import { useConfirm } from "primevue/useconfirm";
+
+export default defineComponent({
+ setup() {
+ const confirm = useConfirm();
+
+ function delete(event) {
+ confirm.require({
+ message: 'Are you sure you want to proceed?',
+ icon: 'pi pi-exclamation-triangle',
+ accept: () => {
+ //callback to execute when user confirms the action
+ },
+ reject: () => {
+ //callback to execute when user rejects the action
+ }
+ });
+ }
+
+ return {delete};
+ }
+})
+
+
+
+ The popup can also be hidden programmatically using the close method.
+
+export default {
+ methods: {
+ discard() {
+ this.$confirm.close();
+ }
+ }
+}
+
+
+
+ Templating allows customizing the content where the message instance is available as the implicit variable.
+
+<ConfirmPopup group="demo">
+ <template #message="slotProps">
+ <div class="flex p-4">
+ <i :class="slotProps.message.icon" style="font-size: 1.5rem"></i>
+ <p class="pl-2">{{slotProps.message.message}}</p>
+ </div>
+ </template>
+</ConfirmPopup>
+
+
+
+
+ ConfirmDialog can be customized with various options listed here.
+Name | +Type | +Default | +Description | +
---|---|---|---|
target | +DomElement | +null | +Element to align the overlay. | +
message | +string | +null | +Message of the confirmation. | +
group | +string | +null | +Optional key to match the key of the confirmation, useful to target a specific confirm dialog instance. | +
icon | +string | +null | +Icon to display next to the message. | +
accept | +Function | +null | +Callback to execute when action is confirmed. | +
reject | +Function | +null | +Callback to execute when action is rejected. | +
acceptLabel | +string | +null | +Label of the accept button. Defaults to PrimeVue |
+
rejectLabel | +string | +null | +Label of the reject button. Defaults to PrimeVue |
+
acceptIcon | +string | +null | +Icon of the accept button. | +
rejectIcon | +string | +null | +Icon of the reject button. | +
acceptClass | +string | +null | +Style class of the accept button. | +
rejectClass | +string | +null | +Style class of the reject button. | +
Name | +Parameters | +Description | +
---|---|---|
require | +confirm: Confirmation Object | +Displays the dialog using the confirmation object options. | +
close | +- | +Hides the dialog without invoking accept or reject callbacks. | +
Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
group | +string | +null | +Optional key to match the key of the confirmation, useful to target a specific confirm dialog instance. | +
Name | +Parameters | +
---|---|
message | +- | +
ConfirmDialog inherits all the classes from the Dialog component, visit
Name | +Element | +
---|---|
p-confirm-popup | +Container element. | +
p-confirm-popup-content | +Content element. | +
p-confirm-popup-icon | +Message icon. | +
p-confirm-popup-message | +Message text. | +
p-confirm-popup-footer | +Footer element for buttons. | +
None.
+ConfirmPopup displays a confirmation overlay displayed relatively to its target.
+{{ slotProps.message.message }}
+
+import ContextMenu from 'primevue/contextmenu';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/contextmenu/contextmenu.min.js"></script>
+
+
+
+ ContextMenu uses the common MenuModel API to define the items, visit
ContextMenu requires a collection of menuitems as its model.
+ +
+export default {
+ data() {
+ return {
+ items: [
+ {
+ label:'File',
+ icon:'pi pi-fw pi-file',
+ items:[
+ {
+ label:'New',
+ icon:'pi pi-fw pi-plus',
+ items:[
+ {
+ label:'Bookmark',
+ icon:'pi pi-fw pi-bookmark'
+ },
+ {
+ label:'Video',
+ icon:'pi pi-fw pi-video'
+ }
+ ]
+ },
+ {
+ label:'Delete',
+ icon:'pi pi-fw pi-trash'
+ },
+ {
+ separator:true
+ },
+ {
+ label:'Export',
+ icon:'pi pi-fw pi-external-link'
+ }
+ ]
+ },
+ {
+ label:'Edit',
+ icon:'pi pi-fw pi-pencil',
+ items:[
+ {
+ label:'Left',
+ icon:'pi pi-fw pi-align-left'
+ },
+ {
+ label:'Right',
+ icon:'pi pi-fw pi-align-right'
+ },
+ {
+ label:'Center',
+ icon:'pi pi-fw pi-align-center'
+ },
+ {
+ label:'Justify',
+ icon:'pi pi-fw pi-align-justify'
+ },
+
+ ]
+ },
+ {
+ label:'Users',
+ icon:'pi pi-fw pi-user',
+ items:[
+ {
+ label:'New',
+ icon:'pi pi-fw pi-user-plus',
+
+ },
+ {
+ label:'Delete',
+ icon:'pi pi-fw pi-user-minus',
+
+ },
+ {
+ label:'Search',
+ icon:'pi pi-fw pi-users',
+ items:[
+ {
+ label:'Filter',
+ icon:'pi pi-fw pi-filter',
+ items:[
+ {
+ label:'Print',
+ icon:'pi pi-fw pi-print'
+ }
+ ]
+ },
+ {
+ icon:'pi pi-fw pi-bars',
+ label:'List'
+ }
+ ]
+ }
+ ]
+ },
+ {
+ label:'Events',
+ icon:'pi pi-fw pi-calendar',
+ items:[
+ {
+ label:'Edit',
+ icon:'pi pi-fw pi-pencil',
+ items:[
+ {
+ label:'Save',
+ icon:'pi pi-fw pi-calendar-plus'
+ },
+ {
+ label:'Delete',
+ icon:'pi pi-fw pi-calendar-minus'
+ },
+
+ ]
+ },
+ {
+ label:'Archieve',
+ icon:'pi pi-fw pi-calendar-times',
+ items:[
+ {
+ label:'Remove',
+ icon:'pi pi-fw pi-calendar-minus'
+ }
+ ]
+ }
+ ]
+ },
+ {
+ separator:true
+ },
+ {
+ label:'Quit',
+ icon:'pi pi-fw pi-power-off'
+ }
+ ]
+ }
+ }
+}
+
+
+
+ Setting global property attaches the context menu to the document.
+
+<ContextMenu :global="true" :model="items" />
+
+
+
+ ContextMenu is attached to a custom element manually using the reference and calling the show(event) method.
+ +
+<img alt="logo" src="demo/images/nature/nature3.jpg" @contextmenu="onImageRightClick">
+<ContextMenu ref="menu" :model="items" />
+
+
+
+
+export default {
+ data() {
+ return {
+ items: //items
+ }
+ },
+ methods: {
+ onImageRightClick(event) {
+ this.$refs.menu.show(event);
+ }
+ }
+}
+
+
+
+ ContextMenu offers content customization with the item template that receives the menuitem instance from the model as a parameter.
+
+<ContextMenu :model="items">
+ <template #item="{item}">
+ <a :href="item.url">{{item.label}}</a>
+ </template>
+</ContextMenu>
+
+
+
+ router-link with route configuration can also be used within templating for further customization.
+
+<ContextMenu :model="items">
+ <template #item="{item}">
+ <router-link :to="item.to" custom v-slot="{href, route, navigate, isActive, isExactActive}">
+ <a :href="href" @click="navigate" :class="{'active-link': isActive, 'active-link-exact": isExactActive}>{{route.fullPath}}</a>
+ </router-link>
+ </template>
+</ContextMenu>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
model | +array | +null | +An array of menuitems. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
autoZIndex | +boolean | +true | +Whether to automatically manage layering. | +
global | +boolean | +false | +Attaches the menu to document instead of a particular item. | +
exact | +boolean | +true | +Whether to apply 'router-link-active-exact' class if route exactly matches the item path. | +
Name | +Parameters | +Description | +
---|---|---|
toggle | +event: Browser event | +Toggles the visibility of the menu. | +
show | +event: Browser event | +Shows the menu. | +
hide | +- | +Hides the menu. | +
Name | +Parameters | +
---|---|
item | +item: Menuitem instance | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-contextmenu | +Container element. | +
p-submenu-list | +Submenu list element. | +
p-menuitem | +Menuitem element. | +
p-menuitem-active | +Active menuitem element. | +
p-menuitem-text | +Label of a menuitem. | +
p-menuitem-icon | +Icon of a menuitem. | +
p-submenu-icon | +Arrow icon of a submenu. | +
None.
++ ContextMenu displays an overlay menu on right click of its target. Note that components like DataTable has special integration with ContextMenu. Refer to documentation of the individual documentation of the with context menu + support. +
+DataTable requires a collection to display along with column components for the representation of the data.
+Columns can be grouped at header and footer using headerColumnGroup and footerColumnGroup components.
++ Columns can be resized using drag drop by setting the resizableColumns to true. There are two resize modes; "fit" and "expand". Fit is the default one and the overall table width does not change when a column is resized. In + "expand" mode, table width also changes along with the column width. +
+MultiSelect component can be used to implement column toggle functionality.
+DataTable has exclusive integration with ContextMenu.
+This sample demonstrates a CRUD implementation using various PrimeVue components.
+DataTable displays data in tabular format.
+
+import DataTable from 'primevue/datatable';
+import Column from 'primevue/column';
+import ColumnGroup from 'primevue/columngroup'; //optional for column grouping
+import Row from 'primevue/row'; //optional for row
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/datatable/datatable.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/column/column.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/columngroup/columngroup.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/row/row.min.js"></script>
+
+
+
+ + DataTable requires a value as an array of objects and columns defined with Column component. Throughout the samples, a car interface having vin, brand, year and color properties is used to define an object to be displayed by the + datatable. Cars are loaded by a CarService that connects to a server to fetch the cars with a fetch API. Note that this is only for demo purposes, DataTable does not have any restrictions on how the data is provided. +
+ +
+export default class CarService {
+
+ getCarsSmall() {
+ return fetch.get('demo/data/cars-small.json').then(res => res.json()).then(d => d.data);
+ }
+
+ getCarsMedium() {
+ return fetch.get('demo/data/cars-medium.json').then(res => res.json()).then(d => d.data);
+ }
+
+ getCarsLarge() {
+ return fetch.get('demo/data/cars-large.json').then(res => res.json()).then(d => d.data);
+ }
+}
+
+
+
+ Example response;
+
+{
+ "data": [
+ {"brand": "Volkswagen", "year": 2012, "color": "Orange", "vin": "dsad231ff"},
+ {"brand": "Audi", "year": 2011, "color": "Black", "vin": "gwregre345"},
+ {"brand": "Renault", "year": 2005, "color": "Gray", "vin": "h354htr"},
+ {"brand": "BMW", "year": 2003, "color": "Blue", "vin": "j6w54qgh"},
+ {"brand": "Mercedes", "year": 1995, "color": "Orange", "vin": "hrtwy34"},
+ {"brand": "Volvo", "year": 2005, "color": "Black", "vin": "jejtyj"},
+ {"brand": "Honda", "year": 2012, "color": "Yellow", "vin": "g43gr"},
+ {"brand": "Jaguar", "year": 2013, "color": "Orange", "vin": "greg34"},
+ {"brand": "Ford", "year": 2000, "color": "Black", "vin": "h54hw5"},
+ {"brand": "Fiat", "year": 2013, "color": "Red", "vin": "245t2s"}
+ ]
+}
+
+
+
+ Following sample datatable has 4 columns and retrieves the data from a service on mount.
+
+<DataTable :value="cars">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ cars: null
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsSmall().then(data => this.cars = data);
+ }
+}
+
+
+
+ Column components can be dynamically generated using a v-for as well.
+
+<DataTable :value="cars">
+ <Column v-for="col of columns" :field="col.field" :header="col.header" :key="col.field"></Column>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ columns: null,
+ cars: null
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+
+ this.columns = [
+ {field: 'vin', header: 'Vin'},
+ {field: 'year', header: 'Year'},
+ {field: 'brand', header: 'Brand'},
+ {field: 'color', header: 'Color'}
+ ];
+ },
+ mounted() {
+ this.carService.getCarsSmall().then(data => this.cars = data);
+ }
+}
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
columnKey | +any | +null | +Identifier of a column if field property is not defined. | +
field | +string | +null | +Property represented by the column. | +
sortField | +string | +null | +Property name to use in sorting, defaults to field. | +
filterField | +string | +null | +Property name to use in filtering, defaults to field. | +
sortable | +any | +false | +Defines if a column is sortable. | +
header | +any | +null | +Header content of the column. | +
footer | +any | +null | +Footer content of the column. | +
style | +object | +null | +Inline style of header, body and footer cells. | +
class | +string | +null | +Style class of header, body and footer cells. | +
headerStyle | +object | +null | +Inline style of the column header. | +
headerClass | +string | +null | +Style class of the column header. | +
bodyStyle | +object | +null | +Inline style of the column body. | +
bodyClass | +string | +null | +Style class of the column body. | +
footerStyle | +object | +null | +Inline style of the column footer. | +
footerClass | +string | +null | +Style class of the column footer. | +
showFilterMenu | +boolean | +true | +Whether to display the filter overlay. | +
showFilterOperator | +boolean | +true | +When enabled, match all and match any operator selector is displayed. | +
showClearButton | +boolean | +true | +Displays a button to clear the column filtering. | +
showApplyButton | +boolean | +true | +Displays a button to apply the column filtering. | +
showFilterMatchModes | +boolean | +true | +Whether to show the match modes selector. | +
showAddButton | +boolean | +true | +When enabled, a button is displayed to add more rules. | +
filterMatchModeOptions | +array | +null | +An array of label-value pairs to override the global match mode options. | +
maxConstraints | +number | +2 | +Maximum number of constraints for a column filter. | +
excludeGlobalFilter | +boolean | +false | +Whether to exclude from global filtering or not. | +
filterHeaderStyle | +object | +null | +Inline style of the column filter header in row filter display. | +
filterHeaderClass | +string | +null | +Style class of the column filter header in row filter display. | +
filterMenuStyle | +object | +null | +Inline style of the column filter overlay. | +
filterMenuClass | +string | +null | +Style class of the column filter overlay. | +
selectionMode | +string | +null | +Defines column based selection mode, options are "single" and "multiple". | +
expander | +boolean | +false | +Displays an icon to toggle row expansion. | +
colspan | +number | +null | +Number of columns to span for grouping. | +
rowspan | +number | +null | +Number of rows to span for grouping. | +
rowReorder | +boolean | +false | +Whether this column displays an icon to reorder the rows. | +
rowReorderIcon | +string | +pi pi-bars | +Icon of the drag handle to reorder rows. | +
reorderableColumn | +boolean | +true | +Defines if the column itself can be reordered with dragging. | +
rowEditor | +boolean | +false | +When enabled, column displays row editor controls. | +
frozen | +boolean | +false | +Whether the column is fixed in horizontal scrolling. | +
alignFrozen | +string | +left | +Position of a frozen column, valid values are left and right. | +
exportable | +boolean | +true | +Whether the column is included in data export. | +
exportHeader | +string | +null | +Custom export header of the column to be exported as CSV. | +
exportFooter | +string | +null | +Custom export footer of the column to be exported as CSV. | +
filterMatchMode | +string | +null | +Defines the filtering algorithm to use when searching the options. | +
hidden | +boolean | +false | +Whether the column is rendered. | +
Name | +Parameters | +
---|---|
header | +column: Column node | +
body | +
+ data: Row data + column: Column node + field: Column field + index: Row index + frozenRow: Is row frozen + editorInitCallback: Callback function + |
+
footer | +column: Column node | +
editor | +
+ data: Row data + column: Column node + field: Column field + index: Row index + frozenRow: Is row frozen + editorSaveCallback: Callback function + editorCancelCallback: Callback function + |
+
filter | +
+ field: Column field + filterModel: {value,matchMode} Filter metadata + filterCallback: Callback function + |
+
filterheader | +
+ field: Column field + filterModel: {value,matchMode} Filter metadata + filterCallback: Callback function + |
+
filterfooter | +
+ field: Column field + filterModel: {value,matchMode} Filter metadata + filterCallback: Callback function + |
+
filterclear | +
+ field: Column field + filterModel: {value,matchMode} Filter metadata + filterCallback: Callback function + |
+
filterapply | +
+ field: Column field + filterModel: {value,matchMode} Filter metadata + filterCallback: Callback function + |
+
loading | +
+ data: Row data + column: Column node + field: Column field + index: Row index + frozenRow: Is row frozen + loadingOptions: Loading options. + |
+
+ Default table-layout is fixed meaning the cell widths do not depend on their content. If you require cells to scale based on their contents set autoLayout property to true. Note that Scrollable and/or Resizable tables do not + support auto layout due to technical limitations. +
+ ++ Field data of a corresponding row is displayed as the cell content by default, this can be customized using a body template where current row data and column properties are passed via the slot props. On the other hand, + header and footer sections of a column can either be defined with the properties or the templates. Similarly DataTable itself also provides header and footer properties along with the templates for the main header and + footer of the table. +
+ +
+<DataTable :value="cars">
+ <template #header>
+ <div>
+ <Button icon="pi pi-refresh" style="float: left"/>
+ List of Cars
+ </div>
+ </template>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand">
+ <template #body="slotProps">
+ <img :src="'demo/images/car/' + slotProps.data.brand + '.png'" :alt="slotProps.data.brand" width="48px"/>
+ </template>
+ </Column>
+ <Column field="color" header="Color"></Column>
+ <Column headerStyle="width: 8em" bodyStyle="text-align: center">
+ <template #header>
+ <Button type="button" icon="pi pi-cog"></Button>
+ </template>
+ <template #body="slotProps">
+ <Button type="button" icon="pi pi-search" class="p-button-success" style="margin-right: .5em"></Button>
+ <Button type="button" icon="pi pi-pencil" class="p-button-warning"></Button>
+ </template>
+ </Column>
+ <template #footer>
+ In total there are {{cars ? cars.length : 0 }} cars.
+ </template>
+</DataTable>
+
+
+
+ In addition to the regular table, a smal and a large version are available with different paddings. For a table with smaller paddings use p-datatable-sm class and for a larger one use p-datatable-lg.
+ +
+<DataTable :value="cars" class="p-datatable-sm">
+ <template #header>
+ Small Table
+ </template>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+<DataTable :value="cars">
+ <template #header>
+ Normal Table
+ </template>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+<DataTable :value="cars" class="p-datatable-lg">
+ <template #header>
+ Large Table
+ </template>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+ Columns can be grouped at header and footer sections by defining a ColumnGroup with nested rows and columns.
+
+<DataTable :value="sales">
+ <ColumnGroup type="header">
+ <Row>
+ <Column header="Brand" :rowspan="3" />
+ <Column header="Sale Rate" :colspan="4" />
+ </Row>
+ <Row>
+ <Column header="Sales" :colspan="2" />
+ <Column header="Profits" :colspan="2" />
+ </Row>
+ <Row>
+ <Column header="Last Year" />
+ <Column header="This Year" />
+ <Column header="Last Year" />
+ <Column header="This Year" />
+ </Row>
+ </ColumnGroup>
+ <Column field="brand" />
+ <Column field="lastYearSale" />
+ <Column field="thisYearSale" />
+ <Column field="lastYearProfit" />
+ <Column field="thisYearProfit" />
+ <ColumnGroup type="footer">
+ <Row>
+ <Column footer="Totals:" :colspan="3" />
+ <Column footer="$506,202" />
+ <Column footer="$531,020" />
+ </Row>
+ </ColumnGroup>
+</DataTable>
+
+
+
+
+ Pagination is enabled by setting paginator property to true and defining the rows property defines the number of rows per page. See the
+<DataTable :value="cars" :paginator="true" :rows="10">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+ paginatorstart and paginatorend templates are available to specify custom content at the left and right side.
+
+<DataTable :value="cars" :paginator="true" :rows="10">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+ <template #paginatorstart>
+ <Button type="button" icon="pi pi-refresh" />
+ </template>
+ <template #paginatorend>
+ <Button type="button" icon="pi pi-cloud" />
+ </template>
+</DataTable>
+
+
+
+ + Paginator can also be programmed programmatically using a binding to the first property that defines the index of the first element to display. For example setting first to zero will reset the paginator to the very first page. + This property also supports v-model in case you'd like your binding to be updated whenever the user changes the page. +
+
+<DataTable :value="cars" :paginator="true" :rows="10" :first="firstRecordIndex">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+ Enabling sortable property at column component would be enough to make a column sortable. The property to use when sorting is the field by default and can be customized using the sortField.
+ +
+<DataTable :value="cars">
+ <Column field="vin" header="Vin" :sortable="true"></Column>
+ <Column field="year" header="Year" :sortable="true"></Column>
+ <Column field="brand" header="Brand" :sortable="true"></Column>
+ <Column field="color" header="Color" :sortable="true"></Column>
+</DataTable>
+
+
+
+ By default sorting is executed on the clicked column only. To enable multiple field sorting, set sortMode property to "multiple" and use metakey when clicking on another column.
+
+<DataTable :value="cars" sortMode="multiple">
+ <Column field="vin" header="Vin" :sortable="true"></Column>
+ <Column field="year" header="Year" :sortable="true"></Column>
+ <Column field="brand" header="Brand" :sortable="true"></Column>
+ <Column field="color" header="Color" :sortable="true"></Column>
+</DataTable>
+
+
+
+ + In case you'd like to display the table as sorted per a single column by default on mount or programmatically apply sort, use sortField and sortOrder properties. These two properties also support the v-model directive to + get updated when the user applies sort a column. +
+
+<DataTable :value="cars" sortField="year" :sortOrder="1">
+ <Column field="vin" header="Vin" :sortable="true"></Column>
+ <Column field="year" header="Year" :sortable="true"></Column>
+ <Column field="brand" header="Brand" :sortable="true"></Column>
+ <Column field="color" header="Color" :sortable="true"></Column>
+</DataTable>
+
+<DataTable :value="cars" sortField="dynamicSortField" :sortOrder="dynamicSortOrder">
+ <Column field="vin" header="Vin" :sortable="true"></Column>
+ <Column field="year" header="Year" :sortable="true"></Column>
+ <Column field="brand" header="Brand" :sortable="true"></Column>
+ <Column field="color" header="Color" :sortable="true"></Column>
+</DataTable>
+
+
+
+ In multiple mode, use the multiSortMeta property and bind an array of SortMeta objects instead.
+
+<DataTable :value="cars" sortMode="multiple" :multiSortMeta="multiSortMeta">
+ <Column field="vin" header="Vin" :sortable="true"></Column>
+ <Column field="year" header="Year" :sortable="true"></Column>
+ <Column field="brand" header="Brand" :sortable="true"></Column>
+ <Column field="color" header="Color" :sortable="true"></Column>
+</DataTable>
+
+
+
+
+data() {
+ return {
+ multiSortMeta: [
+ {field: 'year', order: 1},
+ {field: 'brand', order: -1}
+ ]
+ }
+}
+
+
+
+ + DataTable has advanced filtering capabilities that does the heavy lifting while providing flexible customization. Filtering has two layout alternatives defined with the filterDisplay. In row setting, filter elements are + displayed in a separate row at the header section whereas in menu mode filter elements are displayed inside an overlay. Filter metadata is specified using the filters as a v-model and UI elements for the filtering are + placed inside the filter template. The template filter gets a filterModel and filterCallback, use filterModel.value to populate the filter with your own form components and call the filterCallback with the event of your + choice like @input, @change, @click. +
+ +
+import CustomerService from '../../service/CustomerService';
+import {FilterMatchMode} from 'primevue/api';
+
+export default {
+ data() {
+ return {
+ customers: null,
+ filters: {
+ 'name': {value: null, matchMode: FilterMatchMode.STARTS_WITH}
+ }
+ }
+ },
+ created() {
+ this.customerService = new CustomerService();
+ },
+ mounted() {
+ this.customerService.getCustomersLarge().then(data => this.customers = data);
+ }
+}
+
+
+ Input field is displayed in a separate header row.
+ +
+<DataTable :value="customers1"
+ dataKey="id" v-model:filters="filters" filterDisplay="row" :loading="loading">
+ <Column field="name" header="Name">
+ <template #filter="{filterModel,filterCallback}">
+ <InputText type="text" v-model="filterModel.value" @keydown.enter="filterCallback()" class="p-column-filter" :placeholder="`Search by name - ${filterModel.matchMode}`"/>
+ </template>
+ </Column>
+</DataTable>
+
+
+
+ Input field is displayed in an overlay.
+ +
+<DataTable :value="customers1"
+ dataKey="id" v-model:filters="filters" filterDisplay="menu" :loading="loading">
+ <Column field="name" header="Name">
+ <template #filter="{filterModel,filterCallback}">
+ <InputText type="text" v-model="filterModel.value" @keydown.enter="filterCallback()" class="p-column-filter" :placeholder="`Search by name - ${filterModel.matchMode}`"/>
+ </template>
+ </Column>
+</DataTable>
+
+
+
+ In "menu" display, it is possible to add more constraints to a same filter. In this case, metadata could be an array of constraints. The operator defines whether all or any of the constraints should match.
+ +
+data() {
+ return {
+ customers: null,
+ filters: {
+ 'name': {operator: FilterOperator.AND, constraints: [{value: null, matchMode: FilterMatchMode.STARTS_WITH}]},
+ }
+ }
+}
+
+
+ Providing a filters with predefined values would be enough to display the table as filtered by default. This approach can also be used to clear filters progammatically.
+
+data() {
+ return {
+ customers: null,
+ filters: {
+ 'name': {operator: FilterOperator.AND, constraints: [
+ {value: 'Prime', matchMode: FilterMatchMode.STARTS_WITH},
+ {value: 'Vue', matchMode: FilterMatchMode.CONTAINS}
+ ]}
+ }
+ }
+}
+
+
+ Depending on the dataType of the column, suitable match modes are displayed. Default configuration is available at PrimeVue.filterMatchModeOptions which can be used to customize the modes globally for all tables.
+ +
+import {createApp} from 'vue';
+import PrimeVue from 'primevue/config';
+import FilterMatchMode from 'primevue/api',
+const app = createApp(App);
+
+app.use(PrimeVue, {
+ filterMatchModeOptions: {
+ text: [
+ FilterMatchMode.STARTS_WITH,
+ FilterMatchMode.CONTAINS,
+ FilterMatchMode.NOT_CONTAINS,
+ FilterMatchMode.ENDS_WITH,
+ FilterMatchMode.EQUALS,
+ FilterMatchMode.NOT_EQUALS
+ ],
+ numeric: [
+ FilterMatchMode.EQUALS,
+ FilterMatchMode.NOT_EQUALS,
+ FilterMatchMode.LESS_THAN,
+ FilterMatchMode.LESS_THAN_OR_EQUAL_TO,
+ FilterMatchMode.GREATER_THAN,
+ FilterMatchMode.GREATER_THAN_OR_EQUAL_TO
+ ],
+ date: [
+ FilterMatchMode.DATE_IS,
+ FilterMatchMode.DATE_IS_NOT,
+ FilterMatchMode.DATE_BEFORE,
+ FilterMatchMode.DATE_AFTER
+ ]
+ }
+});
+
+
+ If you need to override the match modes for a particular column use the filterMatchModeOptions property and provide an array with label-value pairs.
+
+<Column field="name" header="Name" :filterMatchModeOptions="matchModes">
+ <template #filter="{filterModel,filterCallback}">
+ <InputText type="text" v-model="filterModel.value" @keydown.enter="filterCallback()" class="p-column-filter" :placeholder="`Search by name - ${filterModel.matchMode}`"/>
+ </template>
+</Column>
+
+
+
+
+matchModes: [
+ {label: 'Starts With', value: FilterMatchMode.STARTS_WITH},
+ {label: 'Contains', value: FilterMatchMode.CONTAINS},
+]
+
+
+ Custom filtering is implemented using the FilterService, first register your filter and add it to your filterMatchModeOptions.
+
+import {FilterService} from 'primevue/api';
+
+FilterService.register('myfilter', (a,b) => a === b);
+
+
+
+matchModes: [
+ {label: 'My Filter', "myfilter"},
+ {label: 'Starts With', value: FilterMatchMode.STARTS_WITH},
+ {label: 'Contains', value: FilterMatchMode.CONTAINS},
+]
+
+
+ Filter menu overlay can be customized even further with various templates including filterheader, filterfooter, filterclear, filterapply. Example here changes the buttons and adds a footer.
+ +
+<Column header="Country" filterField="country.name">
+ <template #filter="{filterModel}">
+ <InputText type="text" v-model="filterModel.value" class="p-column-filter" placeholder="Search by country"/>
+ </template>
+ <template #filterclear="{filterCallback}">
+ <Button type="button" icon="pi pi-times" @click="filterCallback()" class="p-button-secondary"></Button>
+ </template>
+ <template #filterapply="{filterCallback}">
+ <Button type="button" icon="pi pi-check" @click="filterCallback()" class="p-button-success"></Button>
+ </template>
+ <template #filterfooter>
+ <div class="px-3 pt-0 pb-3 text-center font-bold">Customized Buttons</div>
+ </template>
+</Column>
+
+
+
+ + DataTable provides single and multiple selection modes on click of a row. Selected rows are bound to the selection property and updated using the v-model directive. Alternatively column based selection can be done using radio + buttons or checkboxes using selectionMode of a particular column. In addition row-select and row-unselect events are provided as optional callbacks. +
+ +The dataKey property identifies a unique value of a row in the dataset, it is not mandatory however being able to define it increases the performance of the table signifantly.
+ +In single mode, selection binding is an object reference.
+ +
+<DataTable :value="cars" v-model:selection="selectedCar" selectionMode="single" dataKey="vin">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+ + In multiple mode, selection binding should be an array and multiple items can either be selected using metaKey or toggled individually depending on the value of metaKeySelection property value which is true by default. On touch + enabled devices metaKeySelection is turned off automatically. Additionally ShiftKey is supported for range selection. +
+
+<DataTable :value="cars" v-model:selection="selectedCars" selectionMode="multiple" dataKey="vin">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+ + If you prefer a radioButton or a checkbox instead of a row click, use the selectionMode of a column instead. Following datatable displays a checkbox at the first column of each row and automatically adds a header checkbox to + toggle selection of all rows. +
+
+<DataTable :value="cars" v-model:selection="selectedCars" dataKey="vin">
+ <Column selectionMode="multiple"></Column>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+ DataTable supports both horizontal and vertical scrolling as well as frozen columns and rows. Scrollable DataTable is enabled using scrollable property and scrollHeight to define the viewport height.
+
+<DataTable :value="cars" :scrollable="true" scrollHeight="400px">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+ Scrollable table uses flex layout so there are a couple of rules to consider when adjusting the widths of columns.
+
+<Column field="vin" header="Vin" style="flex: 0 0 4rem"></Column>
+
+
+
+ + In cases where viewport should adjust itself according to the table parent's height instead of a fixed viewport height, set scrollHeight option as flex. In example below, table is inside a Dialog where viewport size dynamically + responds to the dialog size changes such as maximizing. +
+
+<Button label="Show" icon="pi pi-external-link" @click="openDialog" />
+<Dialog header="Flex Scroll" v-model:visible="dialogVisible" :style="{width: '50vw'}" :maximizable="true" :modal="true" :contentStyle="{height: '300px'}">
+ <DataTable :value="cars" :scrollable="true" scrollHeight="flex">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+ </DataTable>
+ <template #footer>
+ <Button label="Yes" icon="pi pi-check" @click="closeDialog" />
+ <Button label="No" icon="pi pi-times" @click="closeDialog" class="p-button-secondary"/>
+ </template>
+</Dialog>
+
+
+
+ FlexScroll can also be used for cases where scrollable viewport should be responsive with respect to the window size. See the
+<div style="height: calc(100vh - 143px)">
+ <DataTable :value="cars" :scrollable="true" scrollHeight="flex">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+ </DataTable>
+</div>
+
+
+
+ For horizontal scrolling, it is required to set scrollDirection to "horizontal" and give fixed widths to columns.
+
+<DataTable :value="customers" :scrollable="true" scrollDirection="horizontal">
+ <Column field="id" header="Id" footer="Id" :style="{width:'200px'}"></Column>
+ <Column field="name" header="Name" footer="Name" :style="{width:'200px'}"></Column>
+ <Column field="country.name" header="Country" footer="Country" :style="{width:'200px'}"></Column>
+ <Column field="date" header="Date" footer="Date" :style="{width:'200px'}"></Column>
+ <Column field="balance" header="Balance" footer="Balance" :style="{width:'200px'}"></Column>
+ <Column field="company" header="Company" footer="Company" :style="{width:'200px'}"></Column>
+ <Column field="status" header="Status" footer="Status" :style="{width:'200px'}"></Column>
+ <Column field="activity" header="Activity" footer="Activity" :style="{width:'200px'}"></Column>
+ <Column field="representative.name" header="Representative" footer="Representative" :style="{width:'200px'}"></Column>
+</DataTable>
+
+
+
+ Set scrollDirection to "both" and give fixed widths to columns to scroll both ways.
+
+<DataTable :value="customers" :scrollable="true" scrollHeight="400px" scrollDirection="both">
+ <Column field="id" header="Id" footer="Id" :style="{width:'200px'}"></Column>
+ <Column field="name" header="Name" footer="Name" :style="{width:'200px'}"></Column>
+ <Column field="country.name" header="Country" footer="Country" :style="{width:'200px'}"></Column>
+ <Column field="date" header="Date" footer="Date" :style="{width:'200px'}"></Column>
+ <Column field="balance" header="Balance" footer="Balance" :style="{width:'200px'}"></Column>
+ <Column field="company" header="Company" footer="Company" :style="{width:'200px'}"></Column>
+ <Column field="status" header="Status" footer="Status" :style="{width:'200px'}"></Column>
+ <Column field="activity" header="Activity" footer="Activity" :style="{width:'200px'}"></Column>
+ <Column field="representative.name" header="Representative" footer="Representative" :style="{width:'200px'}"></Column>
+</DataTable>
+
+
+
+ Frozen rows are used to fix certain rows while scrolling, this data is defined with the frozenValue property.
+ +
+<DataTable :value="customers" :frozenValue="lockedCustomers" :scrollable="true" scrollHeight="400px">
+ <Column field="name" header="Name"></Column>
+ <Column field="country.name" header="Country"></Column>
+ <Column field="representative.name" header="Representative"></Column>
+ <Column field="status" header="Status"></Column>
+</DataTable>
+
+
+
+ Certain columns can be frozen by using the frozen property of the column component. In addition alignFrozen is available to define whether the column should be fixed on the left or right.
+ +
+<DataTable :value="customers" :scrollable="true" scrollHeight="400px" scrollDirection="both">
+ <Column field="name" header="Name" :style="{width:'200px'}" frozen></Column>
+ <Column field="id" header="Id" :style="{width:'100px'}" :frozen="idFrozen"></Column>
+ <Column field="name" header="Name" :style="{width:'200px'}"></Column>
+ <Column field="country.name" header="Country" :style="{width:'200px'}"></Column>
+ <Column field="date" header="Date" :style="{width:'200px'}"></Column>
+ <Column field="company" header="Company" :style="{width:'200px'}"></Column>
+ <Column field="status" header="Status" :style="{width:'200px'}"></Column>
+ <Column field="activity" header="Activity" :style="{width:'200px'}"></Column>
+ <Column field="representative.name" header="Representative" :style="{width:'200px'}"></Column>
+ <Column field="balance" header="Balance" :style="{width:'200px'}" frozen alignFrozen="right"></Column>
+</DataTable>
+
+
+
+
+ Row groups with subheaders have exclusive support for filtering, when the table scrolls the subheaders stay fixed as long as their data are still displayed. No additional configuration is required to enable this feature. View the
+
+ Lazy mode is handy to deal with large datasets, instead of loading the entire data, small chunks of data is loaded by invoking corresponding callbacks such as paging and sorting. It is also important to assign the logical number of + rows to totalRecords by doing a projection query for paginator configuration so that paginator displays the UI accordingly. +
+ ++ Lazy loading is implemented by handling page, sort, filter events by making a remote query using the information passed to these events such as first offset, number of rows, sort field for ordering and filters. + Note that, in lazy filtering totalRecords should also be updated to align the data with the paginator. +
+ +Visit the
+ Rows can be expanded to display additional content using the expandedRows property with the v-model directive accompanied by a template named "expansion". row-expand and row-collapse are optional callbacks that + are invoked when a row is expanded or toggled. +
+ +The dataKey property identifies a unique value of a row in the dataset, it is not mandatory in row expansion functionality however being able to define it increases the performance of the table significantly.
+
+<DataTable :value="cars" v-model:expandedRows="expandedRows" dataKey="vin"
+ @row-expand="onRowExpand" @row-collapse="onRowCollapse">
+ <template #header>
+ <div class="table-header-container">
+ <Button icon="pi pi-plus" label="Expand All" @click="expandAll" />
+ <Button icon="pi pi-minus" label="Collapse All" @click="collapseAll" />
+ </div>
+ </template>
+ <Column :expander="true" headerStyle="width: 3em" />
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+ <template #expansion="slotProps">
+ <div class="car-details">
+ <div>
+ <img :src="'demo/images/car/' + slotProps.data.brand + '.png'" :alt="slotProps.data.brand"/>
+ <div class="grid">
+ <div class="col-12">Vin: <b>{{slotProps.data.vin}}</b></div>
+ <div class="col-12">Year: <b>{{slotProps.data.year}}</b></div>
+ <div class="col-12">Brand: <b>{{slotProps.data.brand}}</b></div>
+ <div class="col-12">Color: <b>{{slotProps.data.color}}</b></div>
+ </div>
+ </div>
+ <Button icon="pi pi-search"></Button>
+ </div>
+ </template>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ cars: null,
+ expandedRows: []
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsSmall().then(data => this.cars = data);
+ },
+ methods: {
+ onRowExpand(event) {
+ this.$toast.add({severity: 'info', summary: 'Row Expanded', detail: 'Vin: ' + event.data.vin, life: 3000});
+ },
+ onRowCollapse(event) {
+ this.$toast.add({severity: 'success', summary: 'Row Collapsed', detail: 'Vin: ' + event.data.vin, life: 3000});
+ },
+ expandAll() {
+ this.expandedRows = this.cars.filter(car => car.vin);
+ this.$toast.add({severity: 'success', summary: 'All Rows Expanded', life: 3000});
+ },
+ collapseAll() {
+ this.expandedRows = null;
+ this.$toast.add({severity: 'success', summary: 'All Rows Collapsed', life: 3000});
+ }
+ }
+}
+
+
+
+ In cell editing provides a rapid and user friendly way to manipulate the data. The datatable provides a flexible API so that the editing behavior is implemented by the page author whether it utilizes v-model or vuex.
+ ++ Individual cell editing is configured by setting the editMode to cell, defining editors with the editor template along with the @cell-edit-complete event. The content of the editor defines how the editing + is implemented. The editor template receives a clone of the row data and using @cell-edit-complete event the new value can be updated to the model or cancelled. This also provides flexibility to apply conditional logic such as + implementing validations. +
+ +
+<h5>Cell Editing</h5>
+<DataTable :value="cars" editMode="cell" @cell-edit-complete="onCellEditComplete">
+ <Column field="vin" header="Vin">
+ <template #editor="slotProps">
+ <InputText v-model="slotProps.data[slotProps.field]" />
+ </template>
+ </Column>
+ <Column field="year" header="Year">
+ <template #editor="slotProps">
+ <InputText v-model="slotProps.data[slotProps.field]" />
+ </template>
+ </Column>
+ <Column field="brand" header="Brand">
+ <template #editor="slotProps">
+ <Dropdown v-model="slotProps.data['brand']" :options="brands" optionLabel="brand" optionValue="value" placeholder="Select a Brand">
+ <template #option="optionProps">
+ <div class="p-dropdown-car-option">
+ <img :alt="optionProps.option.brand" :src="'demo/images/car/' + optionProps.option.brand + '.png'" />
+ <span>{{optionProps.option.brand}}</span>
+ </div>
+ </template>
+ </Dropdown>
+ </template>
+ </Column>
+ <Column field="color" header="Color">
+ <template #editor="slotProps">
+ <InputText v-model="slotProps.data[slotProps.field]" />
+ </template>
+ </Column>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+import Vue from 'vue';
+
+export default {
+ data() {
+ return {
+ cars: null,
+ brands: [
+ {brand: 'Audi', value: 'Audi'},
+ {brand: 'BMW', value: 'BMW'},
+ {brand: 'Fiat', value: 'Fiat'},
+ {brand: 'Honda', value: 'Honda'},
+ {brand: 'Jaguar', value: 'Jaguar'},
+ {brand: 'Mercedes', value: 'Mercedes'},
+ {brand: 'Renault', value: 'Renault'},
+ {brand: 'Volkswagen', value: 'Volkswagen'},
+ {brand: 'Volvo', value: 'Volvo'}
+ ]
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ methods: {
+ onCellEditComplete(event) {
+ let { data, newValue, field } = event;
+
+ switch (event.field) {
+ case 'year':
+ if (this.isPositiveInteger(newValue))
+ data[field] = newValue;
+ else
+ event.preventDefault();
+ break;
+
+ default:
+ if (newValue.trim().length > 0)
+ data[field] = newValue;
+ else
+ event.preventDefault();
+ break;
+ }
+ },
+ isPositiveInteger(val) {
+ let str = String(val);
+ str = str.trim();
+ if (!str) {
+ return false;
+ }
+ str = str.replace(/^0+/, "") || "0";
+ var n = Math.floor(Number(str));
+ return n !== Infinity && String(n) === str && n >= 0;
+ }
+ },
+ mounted() {
+ this.carService.getCarsSmall().then(data => this.cars = data);
+ }
+}
+
+
+
+ + Row Editing is specified by setting editMode as row, defining editingRows with the v-model directive to hold the reference of the editing rows, adding a row editor column to provide the editing controls and + implementing @row-edit-save to update the original row data. Note that since editingRows is two-way binding enabled, you may use it to initially display one or more rows in editing more or programmatically toggle row + editing. +
+
+<h3>Row Editing</h3>
+<DataTable :value="cars" editMode="row" dataKey="vin" v-model:editingRows="editingRows" @row-edit-save="onRowEditSave">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year">
+ <template #editor="slotProps">
+ <InputText v-model="slotProps.data[slotProps.field]" autofocus/>
+ </template>
+ </Column>
+ <Column field="brand" header="Brand">
+ <template #editor="slotProps">
+ <InputText v-model="slotProps.data[slotProps.field]" />
+ </template>
+ </Column>
+ <Column field="color" header="Color">
+ <template #editor="slotProps">
+ <InputText v-model="slotProps.data[slotProps.field]" />
+ </template>
+ </Column>
+ <Column :rowEditor="true" headerStyle="width:7rem" bodyStyle="text-align:center"></Column>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+import Vue from 'vue';
+
+export default {
+ data() {
+ return {
+ cars: null,
+ editingRows: []
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ methods: {
+ onRowEditSave(event) {
+ let { newData, index } = event;
+
+ this.cars[index] = newData;
+ },
+ },
+ mounted() {
+ this.carService.getCarsSmall().then(data => this.cars = data);
+ }
+}
+
+
+
+ + Columns can be resized using drag drop by setting the resizableColumns to true. There are two resize modes; "fit" and "expand". Fit is the default one and the overall table width does not change when a column is resized. In + "expand" mode, table width also changes along with the column width. column-resize-end is a callback that passes the resized column header and delta change as a parameter. +
+
+<DataTable :value="cars" :resizableColumns="true" columnResizeMode="fit | expand">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+ It is important to note that when you need to change column widths, since table width is 100%, giving fixed pixel widths does not work well as browsers scale them, instead give percentage widths.
+
+<DataTable :value="cars" :resizableColumns="true" columnResizeMode="fit | expand">
+ <Column field="vin" header="Vin" headerStyle="width: 20%"></Column>
+ <Column field="year" header="Year" headerStyle="width: 40%"></Column>
+ <Column field="brand" header="Brand" headerStyle="width: 20%"></Column>
+ <Column field="color" header="Color" headerStyle="width: 20%"></Column>
+</DataTable>
+
+
+
+ + Columns can be reordered using drag drop by setting the reorderableColumns to true. column-reorder is a callback that is invoked when a column is reordered. DataTable keeps the column order state internally using keys + that identifies a column using the field property. If the column has no field, use columnKey instead as it is mandatory for columns to have unique keys when reordering is enabled. +
+
+<DataTable :value="cars" :reorderableColumns="true">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+ + Data can be reordered using drag drop by adding a reorder column that will display an icon as a drag handle along with the row-reorder event which is mandatory to update the new order. Note that the reorder icon can be + customized using rowReorderIcon of the column component. +
+
+<DataTable :value="cars" @row-reorder="onRowReorder">
+ <Column :rowReorder="true" headerStyle="width: 3em" />
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ cars: null
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsSmall().then(data => this.cars = data);
+ },
+ methods: {
+ onRowReorder(event) {
+ //update new order
+ this.cars = event.value;
+ }
+ }
+}
+
+
+
+ + Row Grouping comes in two modes, in "subheader" mode rows are grouped by a header row along with an optional group footer. In addition, the groups can be made toggleable by enabling expandableRowGroups as true. On the other + hand, the "rowspan" mode uses rowspans instead of a header to group rows. groupRowsBy property defines the field to use in row grouping. Multiple row grouping is available in "rowspan" mode by specifying the + groupRowsBy as an array of fields. +
+ +Example below demonstrates the all grouping alternatives. Note that data needs to be sorted for grouping which can also be done by the table itself by speficying the sort properties.
+ +
+<h3>Subheader Grouping</h3>
+<DataTable :value="cars" rowGroupMode="subheader" groupRowsBy="brand"
+ sortMode="single" sortField="brand" :sortOrder="1">
+ <Column field="brand" header="Brand"></Column>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="color" header="Color"></Column>
+ <Column field="price" header="Price"></Column>
+ <template #groupheader="slotProps">
+ <span>{{slotProps.data.brand}}</span>
+ </template>
+ <template #groupfooter="slotProps">
+ <td colspan="3" style="text-align: right">Total Price</td>
+ <td>{{calculateGroupTotal(slotProps.data.brand)}}</td>
+ </template>
+</DataTable>
+
+<h3>Expandable Row Groups</h3>
+<DataTable :value="cars" rowGroupMode="subheader" groupRowsBy="brand"
+ sortMode="single" sortField="brand" :sortOrder="1"
+ :expandableRowGroups="true" v-model:expandedRowGroups="expandedRowGroups"
+ @rowgroup-expand="onRowExpand" @rowgroup-collapse="onRowCollapse">
+ <Column field="brand" header="Brand"></Column>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="color" header="Color"></Column>
+ <Column field="price" header="Price"></Column>
+ <template #groupheader="slotProps">
+ <span>{{slotProps.data.brand}}</span>
+ </template>
+ <template #groupfooter="slotProps">
+ <td colspan="3" style="text-align: right">Total Price</td>
+ <td>{{calculateGroupTotal(slotProps.data.brand)}}</td>
+ </template>
+</DataTable>
+
+<h3>RowSpan Grouping</h3>
+<DataTable :value="cars" rowGroupMode="rowspan" groupRowsBy="brand"
+ sortMode="single" sortField="brand" :sortOrder="1">
+ <Column header="#" headerStyle="width:3em">
+ <template #body="slotProps">
+ {{slotProps.index}}
+ </template>
+ </Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="color" header="Color"></Column>
+ <Column field="price" header="Price"></Column>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ cars: null,
+ expandedRowGroups: null
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsMedium().then(data => this.cars = data);
+ },
+ methods: {
+ onRowGroupExpand(event) {
+ this.$toast.add({severity: 'info', summary: 'Row Group Expanded', detail: 'Value: ' + event.data, life: 3000});
+ },
+ onRowGroupCollapse(event) {
+ this.$toast.add({severity: 'success', summary: 'Row Group Collapsed', detail: 'Value: ' + event.data, life: 3000});
+ },
+ calculateGroupTotal(brand) {
+ let total = 0;
+
+ if (this.cars) {
+ for (let car of this.cars) {
+ if (car.brand === brand) {
+ total += car.price;
+ }
+ }
+ }
+
+ return total;
+ }
+ }
+}
+
+
+
+ DataTable can export its data in CSV format using exportCSV() method.
+
+<DataTable :value="cars" ref="dt">
+ <template #header>
+ <div style="text-align: left">
+ <Button icon="pi pi-external-link" label="Export" @click="exportCSV($event)" />
+ </div>
+ </template>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ cars: null
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsSmall().then(data => this.cars = data);
+ },
+ methods: {
+ exportCSV() {
+ this.$refs.dt.exportCSV();
+ }
+ }
+}
+
+
+
+ + Stateful table allows keeping the state such as page, sort and filtering either at local storage or session storage so that when the page is visited again, table would render the data using its last settings. Enabling state is easy as + defining a unique stateKey, the storage to keep the state is defined with the stateStorage property that accepts session for sessionStorage and local for localStorage. Currently following features are supported by + TableState; paging, sorting, filtering, column resizing, column reordering, row expansion, row group expansion and row selection. +
+
+<DataTable :value="cars" :paginator="true" :rows="10" v-model:filters="filters"
+ stateStorage="session" stateKey="dt-state-demo-session"
+ v-model:selection="selectedCar" selectionMode="single" dataKey="vin">
+ <template #header>
+ <div style="text-align: right">
+ <i class="pi pi-search" style="margin: 4px 4px 0px 0px;"></i>
+ <InputText v-model="filters['global']" placeholder="Global Search" size="50" />
+ </div>
+ </template>
+ <Column field="vin" header="Vin" filterMatchMode="startsWith" :sortable="true">
+ <template #filter>
+ <InputText type="text" v-model="filters['vin']" class="p-column-filter" placeholder="Starts with" />
+ </template>
+ </Column>
+ <Column field="year" header="Year" filterMatchMode="contains" :sortable="true">
+ <template #filter>
+ <InputText type="text" v-model="filters['year']" class="p-column-filter" placeholder="Contains" />
+ </template>
+ </Column>
+ <Column field="brand" header="Brand" filterMatchMode="equals" :sortable="true">
+ <template #filter>
+ <Dropdown v-model="filters['brand']" :options="brands" optionLabel="brand" optionValue="value" placeholder="Select a Brand" class="p-column-filter" :showClear="true">
+ <template #option="slotProps">
+ <div class="p-dropdown-car-option">
+ <img :alt="slotProps.option.brand" :src="'demo/images/car/' + slotProps.option.brand + '.png'" />
+ <span>{{slotProps.option.brand}}</span>
+ </div>
+ </template>
+ </Dropdown>
+ </template>
+ </Column>
+ <Column field="color" header="Color" filterMatchMode="in" :sortable="true">
+ <template #filter>
+ <MultiSelect v-model="filters['color']" :options="colors" optionLabel="name" optionValue="value" placeholder="Select a Color" />
+ </template>
+ </Column>
+ <template #empty>
+ No records found.
+ </template>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ filters: {},
+ brands: [
+ {brand: 'Audi', value: 'Audi'},
+ {brand: 'BMW', value: 'BMW'},
+ {brand: 'Fiat', value: 'Fiat'},
+ {brand: 'Honda', value: 'Honda'},
+ {brand: 'Jaguar', value: 'Jaguar'},
+ {brand: 'Mercedes', value: 'Mercedes'},
+ {brand: 'Renault', value: 'Renault'},
+ {brand: 'Volkswagen', value: 'Volkswagen'},
+ {brand: 'Volvo', value: 'Volvo'}
+ ],
+ colors: [
+ {name: 'White', value: 'White'},
+ {name: 'Green', value: 'Green'},
+ {name: 'Silver', value: 'Silver'},
+ {name: 'Black', value: 'Black'},
+ {name: 'Red', value: 'Red'},
+ {name: 'Maroon', value: 'Maroon'},
+ {name: 'Brown', value: 'Brown'},
+ {name: 'Orange', value: 'Orange'},
+ {name: 'Blue', value: 'Blue'}
+ ],
+ selectedCar: null,
+ cars: null
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsMedium().then(data => this.cars = data);
+ }
+}
+
+
+
+ DataTable provides exclusive integration with the ContextMenu component using, contextMenu, contextMenuSelection property along with the row-contextmenu event.
+
+<DataTable :value="cars" contextMenu v-model:contextMenuSelection="selectedCar" @row-contextmenu="onRowContextMenu">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+<ContextMenu :model="menuModel" ref="cm" />
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ cars: null,
+ selectedCar: null,
+ menuModel: [
+ {label: 'View', icon: 'pi pi-fw pi-search', command: () => this.viewCar(this.selectedCar)},
+ {label: 'Delete', icon: 'pi pi-fw pi-times', command: () => this.deleteCar(this.selectedCar)}
+ ]
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsSmall().then(data => this.cars = data);
+ },
+ methods: {
+ onRowContextMenu(event) {
+ this.$refs.cm.show(event.originalEvent);
+ },
+ viewCar(car) {
+ this.$toast.add({severity: 'info', summary: 'Car Selected', detail: car.vin + ' - ' + car.brand});
+ },
+ deleteCar(car) {
+ this.cars = this.cars.filter((c) => c.vin !== car.vin);
+ this.$toast.add({severity: 'info', summary: 'Car Deleted', detail: car.vin + ' - ' + car.brand});
+ this.selectedCar = null;
+ }
+ }
+}
+
+
+
+ When there is no data, you may use the empty template to display a message.
+
+<DataTable :value="cars">
+ <template #empty>
+ No records found
+ </template>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+ + A loading status indicator can be displayed when the loading property is enabled. The icon is customized through loadingIcon property. Additionally an option loading template is available to render as the body until the + data is loaded. +
+
+<DataTable :value="cars" :loading="loading">
+ <template #loading>
+ Loading records, please wait...
+ </template>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ loading: false,
+ cars: null
+ }
+ },
+ datasource: null,
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.loading = true;
+
+ this.carService.getCarsLarge().then(data => {
+ this.cars = data
+ this.loading = false;
+ });
+ }
+}
+
+
+
+ + DataTable responsive layout can be achieved in two ways; first approach is displaying a horizontal scrollbar for smaller screens and second one is defining a breakpoint to display the cells of a row as stacked. Scrollable tables use + the scroll layout approach internally and do not require additional configuration. +
+ ++ Set responsiveLayout to scroll to enabled this layout. Note that, when scroll mode is enabled table-layout automatically switches to auto from fixed as a result table widths are likely to differ and resizable columns are not + supported. Read more about table-layout for more details. +
+ +
+<DataTable :value="products" responsiveLayout="scroll">
+
+</DataTable>
+
+
+
+ In stack layout, columns are displayed as stacked after a certain breakpoint. Default is '960px'.
+
+<DataTable :value="products" responsiveLayout="stack" breakpoint="640px">
+
+</DataTable>
+
+
+
+ + Certain rows or cells can easily be styled based on conditions. Cell styling is implemented with templating whereas row styling utilizes the rowClass property which takes the row data as a parameter and returns the style class + as a string. +
+
+<DataTable :value="cars" :rowClass="rowClass">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year" bodyStyle="padding: 0">
+ <template #body="slotProps">
+ <div :class="['year-cell', {'old-car': slotProps.data.year < 2010}]">
+ {{slotProps.data.year}}
+ </div>
+ </template>
+ </Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ columns: null,
+ cars: null
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsSmall().then(data => this.cars = data);
+ },
+ methods: {
+ rowClass(data) {
+ return data.color === 'Orange' ? 'orange-car': null;
+ }
+ }
+}
+
+
+
+
+.year-cell {
+ padding: 0.429em 0.857rem;
+
+ &.old-car {
+ background-color: #41b783;
+ font-weight: 700;
+ color: #ffffff;
+ }
+}
+
+.orange-car {
+ background-color: #344b5f !important;
+ color: #ffffff !important;
+}
+
+
+
+ Any valid attribute is passed to the root element implicitly, extended properties are as follows;
+Name | +Type | +Default | +Description | +
---|---|---|---|
value | +array | +null | +An array of objects to display. | +
dataKey | +string | +null | +Name of the field that uniquely identifies the a record in the data. | +
rows | +number | +null | +Number of rows to display per page. | +
first | +number | +0 | +Index of the first row to be displayed. | +
totalRecords | +number | +null | +Number of total records, defaults to length of value when not defined. | +
paginator | +boolean | +false | +When specified as true, enables the pagination. | +
paginatorPosition | +string | +bottom | +Position of the paginator, options are "top","bottom" or "both". | +
alwaysShowPaginator | +boolean | +true | +Whether to show it even there is only one page. | +
paginatorTemplate | +string | +
+ FirstPageLink PrevPageLink PageLinks + NextPageLink LastPageLink RowsPerPageDropdown + |
+ Template of the paginator. See the |
+
pageLinkSize | +number | +5 | +Number of page links to display. | +
rowsPerPageOptions | +array | +null | +Array of integer values to display inside rows per page dropdown. | +
currentPageReportTemplate | +string | +({currentPage} of {totalPages}) | +Template of the current page report element. | +
lazy | +boolean | +false | +Defines if data is loaded and interacted with in lazy manner. | +
loading | +boolean | +false | +Displays a loader to indicate data load is in progress. | +
loadingIcon | +string | +pi pi-spinner | +The icon to show while indicating data load is in progress. | +
sortField | +string | +null | +Property name or a getter function of a row data used for sorting by default | +
sortOrder | +number | +null | +Order to sort the data by default. | +
defaultSortOrder | +number | +1 | +Default sort order of an unsorted column. | +
multiSortMeta | +array | +null | +An array of SortMeta objects to sort the data by default in multiple sort mode. | +
sortMode | +string | +single | +Defines whether sorting works on single column or on multiple columns. | +
removableSort | +boolean | +false | +When enabled, columns can have an un-sorted state. | +
filters | +object | +null | +Filters object with key-value pairs to define the filters. | +
filterDisplay | +string | +null | +Layout of the filter elements, valid values are "row" and "menu". | +
filterLocale | +string | +undefined | +Locale to use in filtering. The default locale is the host environment's current locale. | +
selection | +any | +null | +Selected row in single mode or an array of values in multiple mode. | +
selectionMode | +string | +null | +Specifies the selection mode, valid values are "single" and "multiple". | +
compareSelectionBy | +string | +deepEquals | +
+ Algorithm to define if a row is selected, valid values are "equals" that compares by reference and + "deepEquals" that compares all fields. + |
+
metaKeySelection | +boolean | +true | +
+ Defines whether metaKey is requred or not for the selection. + When true metaKey needs to be pressed to select or unselect an item and + when set to false selection of each item can be toggled individually. On touch enabled devices, metaKeySelection is turned off automatically. + |
+
contextMenu | +boolean | +false | +Enables context menu integration. | +
contextMenuSelection | +object | +null | +Selected row instance with the ContextMenu. | +
rowHover | +boolean | +false | +When enabled, background of the rows change on hover. | +
csvSeparator | +string | +, | +Character to use as the csv separator. | +
exportFilename | +string | +download | +Name of the exported file. | +
exportFunction | +function | +download | +Custom function to export data. | +
autoLayout | +boolean | +false | +Whether the cell widths scale according to their content or not. Does not apply to scrollable tables. | +
resizableColumns | +boolean | +false | +When enabled, columns can be resized using drag and drop. | +
columnResizeMode | +string | +fit | +
+ Defines whether the overall table width should change on column resize, + valid values are "fit" and "expand". + |
+
reorderableColumns | +boolean | +false | +When enabled, columns can be reordered using drag and drop. | +
expandedRows | +array | +null | +A collection of row data display as expanded. | +
expandedRowIcon | +string | +pi-chevron-down | +Icon of the row toggler to display the row as expanded. | +
collapsedRowIcon | +string | +pi-chevron-right | +Icon of the row toggler to display the row as collapsed. | +
rowGroupMode | +string | +null | +Defines the row group mode, valid options are "subheader" and "rowspan". | +
groupRowsBy | +string|array | +null | +One or more field names to use in row grouping. | +
expandableRowGroups | +boolean | +false | +Whether the row groups can be expandable. | +
expandedRowGroups | +array | +null | +An array of group field values whose groups would be rendered as expanded. | +
stateStorage | +string | +session | +Defines where a stateful table keeps its state, valid values are "session" for sessionStorage and "local" for localStorage. | +
stateKey | +string | +null | +Unique identifier of a stateful table to use in state storage. | +
editMode | +string | +null | +Defines the incell editing mode, valid options are "cell" and "row". | +
editingRows | +array | +null | +A collection of rows to represent the current editing data in row edit mode. | +
rowClass | +function | +null | +A function that takes the row data as a parameter and returns a string to apply a particular class for the row. | +
rowStyle | +object | +null | +Inline style of the row element. | +
scrollable | +boolean | +false | +When specified, enables horizontal and/or vertical scrolling. | +
scrollDirection | +string | +vertical | +Orientation of the scrolling, options are "vertical", "horizontal" and "both". | +
scrollHeight | +string | +null | +Height of the scroll viewport in fixed pixels or the "flex" keyword for a dynamic size. | +
virtualScrollerOptions | +object | +null | +
+ Whether to use the virtualScroller feature. The properties of Note: Currently only vertical + orientation mode is supported. + |
+
frozenValue | +array | +null | +Items of the frozen part in scrollable DataTable. | +
responsiveLayout | +string | +stack | +Defines the responsive mode, valid options are "stack" and "scroll". | +
breakpoint | +string | +960px | +The breakpoint to define the maximum width boundary when using stack responsive layout. | +
showGridlines | +boolean | +false | +Whether to show grid lines between cells. | +
stripedRows | +boolean | +false | +Whether to displays rows with alternating colors. | +
tableStyle | +object | +null | +Inline style of the table element. | +
tableClass | +string | +null | +Style class of the table element. | +
Name | +Parameters | +Description | +
---|---|---|
page | +
+ event.originalEvent: Browser event + event.page: New page number + event.pageCount: Total page count + event.first: Index of first record + event.rows: Number of rows to display in new page + event.sortField: Field to sort against + event.sortOrder: Sort order as integer + event.multiSortMeta: MultiSort metadata + event.filters: Collection of active filters + event.filterMatchModes: Match modes per field + |
+ Callback to invoke on pagination. Sort and Filter information is also available for lazy loading implementation. | +
sort | +
+ event.originalEvent: Browser event + event.first: Index of first record + event.rows: Number of rows to display in new page + event.sortField: Field to sort against + event.sortOrder: Sort order as integer + event.multiSortMeta: MultiSort metadata + event.filters: Collection of active filters + event.filterMatchModes: Match modes per field + |
+ Callback to invoke on sort. Page and Filter information is also available for lazy loading implementation. | +
filter | +
+ event.originalEvent: Browser event + event.first: Index of first record + event.rows: Number of rows to display in new page + event.sortField: Field to sort against + event.sortOrder: Sort order as integer + event.multiSortMeta: MultiSort metadata + event.filters: Collection of active filters + event.filteredValue: Filtered collection (non-lazy only) + |
+ Event to emit after filtering, not triggered in lazy mode. | +
value-change | +value: Value displayed by the table | +Callback to invoke after filtering, sorting, pagination and cell editing to pass the rendered value. | +
row-click | +
+ event.originalEvent: Browser event. + event.data: Selected row data. + event.index: Row index. + |
+ Callback to invoke when a row is clicked. | +
row-dblclick | +
+ event.originalEvent: Browser event. + event.data: Selected row data. + event.index: Row index. + |
+ Callback to invoke when a row is double clicked. | +
row-contextmenu | +
+ event.originalEvent: Browser event. + event.data: Selected row data. + event.index: Row index. + |
+ Callback to invoke when a row is selected with a ContextMenu. | +
row-select | +
+ event.originalEvent: Browser event. + event.data: Selected row data. + event.index: Row index. + event.type: Type of the selection, valid values are "row", "radio" or "checkbox". + |
+ Callback to invoke when a row is selected. | +
row-unselect | +
+ event.originalEvent: Browser event. + event.data: Unselected row data. + event.index: Row index. + event.type: Type of the selection, valid values are "row", "radio" or "checkbox". + |
+ Callback to invoke when a row is unselected. | +
row-select-all | +
+ event.originalEvent: Browser event. + event.data: Selected dataset + |
+ Fired when header checkbox is checked. | +
row-unselect-all | +event.originalEvent: Browser event. | +Fired when header checkbox is unchecked. | +
column-resize-end | +
+ event.element: DOM element of the resized column. + event.delta: Change in column width + |
+ Callback to invoke when a column is resized. | +
column-reorder | +
+ event.originalEvent: Browser event + event.dragIndex: Index of the dragged column + event.dropIndex: Index of the dropped column + |
+ Callback to invoke when a column is reordered. | +
row-reorder | +
+ event.originalEvent: Browser event + event.dragIndex: Index of the dragged row + event.dropIndex: Index of the dropped row + value: Reordered value + |
+ Callback to invoke when a row is reordered. | +
row-expand | +
+ event.originalEvent: Browser event + event.data: Expanded row data. + |
+ Callback to invoke when a row is expanded. | +
row-collapse | +
+ event.originalEvent: Browser event + event.data: Collapsed row data. + |
+ Callback to invoke when a row is collapsed. | +
rowgroup-expand | +
+ event.originalEvent: Browser event + event.data: Expanded group value. + |
+ Callback to invoke when a row group is expanded. | +
rowgroup-collapse | +
+ event.originalEvent: Browser event + event.data: Collapsed group value. + |
+ Callback to invoke when a row group is collapsed. | +
cell-edit-init | +
+ event.originalEvent: Browser event + event.data: Row data to edit. + event.field: Field name of the row data. + event.index: Index of the row data to edit. + |
+ Callback to invoke when cell edit is initiated. | +
cell-edit-complete | +
+ event.originalEvent: Browser event + event.data: Row data to edit. + event.newData: New row data after editing. + event.value: Field value of row data to edit. + event.newValue: Field value of new row data after editing. + event.field: Field name of the row data. + event.index: Index of the row data to edit. + event.type: Type of completion such as "enter", "outside" or "tab". + |
+ Callback to invoke when cell edit is completed. | +
cell-edit-cancel | +
+ event.originalEvent: Browser event + event.data: Row data to edit. + event.field: Field name of the row data. + event.index: Index of the row data to edit. + |
+ Callback to invoke when cell edit is cancelled with escape key. | +
row-edit-init | +
+ event.originalEvent: Browser event + event.data: Row data to edit. + event.newData: New row data after editing. + event.field: Field name of the row data. + event.index: Index of the row data to edit. + |
+ Callback to invoke when row edit is initiated. | +
row-edit-save | +
+ event.originalEvent: Browser event + event.data: Row data to edit. + event.newData: New row data after editing. + event.field: Field name of the row data. + event.index: Index of the row data to edit. + |
+ Callback to invoke when row edit is saved. | +
row-edit-cancel | +
+ event.originalEvent: Browser event + event.data: Row data to edit. + event.newData: New row data after editing. + event.field: Field name of the row data. + event.index: Index of the row data to edit. + |
+ Callback to invoke when row edit is cancelled. | +
state-save | +
+ event.first: Index of first record + event.rows: Number of rows to display in new page + event.sortField: Field to sort against + event.sortOrder: Sort order as integer + event.multiSortMeta: MultiSort metadata + event.filters: Collection of active filters + event.columWidths: Comma separated list of column widths + event.columnOrder: Order of the columns + event.expandedRows: Instances of rows in expanded state + event.expandedRowKeys: Keys of rows in expanded state + event.expandedRowGroups: Instances of row groups in expanded state + event.selection: Selected rows + event.selectionKeys: Keys of selected rows + |
+ Invoked when a stateful table saves the state. | +
state-restore | +
+ event.first: Index of first record + event.rows: Number of rows to display in new page + event.sortField: Field to sort against + event.sortOrder: Sort order as integer + event.multiSortMeta: MultiSort metadata + event.filters: Collection of active filters + event.columWidths: Comma separated list of column widths + event.columnOrder: Order of the columns + event.expandedRows: Instances of rows in expanded state + event.expandedRowKeys: Keys of rows in expanded state + event.expandedRowGroups: Instances of row groups in expanded state + event.selection: Selected rows + event.selectionKeys: Keys of selected rows + |
+ Invoked when a stateful table restores the state. | +
Name | +Parameters | +Description | +
---|---|---|
exportCSV | +- | +Exports the data to CSV format. | +
Name | +Parameters | +
---|---|
header | +column: Column node | +
paginatorstart | +- | +
paginatorend | +- | +
footer | +column: Column node | +
groupheader | +
+ data: Row data + index: Row index + |
+
groupfooter | +
+ data: Row data + index: Row index + |
+
expansion | +
+ data: Row data + index: Row index + |
+
empty | +- | +
loading | +- | +
Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+ +Name | +Element | +
---|---|
p-datatable | +Container element. | +
p-datatable-scrollable | +Container element when table is scrollable. | +
p-datatable-header | +Header section. | +
p-datatable-footer | +Footer section. | +
p-datatable-wrapper | +Wrapper of table element. | +
p-datatable-table | +Table element. | +
p-datatable-thead | +Table thead element. | +
p-datatable-tbody | +Table tbody element. | +
p-datatable-tfoot | +Table tfoot element. | +
p-column-title | +Title of a column. | +
p-sortable-column | +Sortable column header. | +
p-frozen-column | +Frozen column header. | +
p-rowgroup-header | +Header of a rowgroup. | +
p-rowgroup-footer | +Footer of a rowgroup. | +
p-datatable-row-expansion | +Expanded row content. | +
p-row-toggler | +Toggle element for row expansion. | +
p-datatable-emptymessage | +Cell containing the empty message. | +
p-row-editor-init | +Pencil button of row editor. | +
p-row-editor-init | +Save button of row editor. | +
p-row-editor-init | +Cancel button of row editor. | +
None.
+Columns can be defined dynamically using the v-for directive.
+In cell editing provides a rapid and user friendly way to manipulate the data. The datatable provides a flexible API so that the editing behavior is implemented by the page author whether it utilizes v-model or vuex.
+Validations, dynamic columns and reverting values with the escape key.
+DataTable can export its data to CSV format.
+Filtering feature provides advanced and flexible options to query the data.
+Filters are displayed in an overlay.
+Filters are displayed inline within a separate row.
+Enabling showGridlines displays borders between cells. Note: Some themes may always display gridlines by design.
++ Lazy mode is handy to deal with large datasets, instead of loading the entire data, small chunks of data is loaded by invoking corresponding callbacks everytime paging, sorting and filtering happens. Sample belows imitates lazy + paging by using an in memory list. It is also important to assign the logical number of rows to totalRecords by doing a projection query for paginator configuration so that paginator displays the UI assuming there are actually + records of totalRecords size although in reality they aren't as in lazy mode, only the records that are displayed on the current page exist. In addition, the implementation of checkbox selection in lazy tables is left + entirely to the user since the DataTable does not have access to the whole dataset in order to define the checked state. +
+Pagination is enabled by setting paginator property to true and defining the rows attribute as the number of rows per page.
+Order of the columns and rows can be changed using drag and drop.
+DataTable responsive layout can be achieved in two ways; first approach is displaying a horizontal scrollbar for smaller screens and second one is defining a breakpoint to display the cells of a row as stacked.
+A row can be expanded to display additional content.
+Rows can either be grouped by a separate grouping row or using rowspan.
+Group customers by their representative.
+Group customers by their representative.
+Data scrolling is available horizontally, vertically or both with support for frozen rows and columns.
++ Flex scroll feature makes the scrollable viewport section dynamic instead of a fixed value so that it can grow or shrink relative to the parent size of the table. Click the button below to display a maximizable Dialog where data + viewport adjusts itself according to the size changes. +
+ + +DataTable provides single and multiple selection modes based on row click or using radio button and checkbox elements.
+In single mode, a row is selected on click event of a row. If the row is already selected then the row gets unselected.
++ In multiple mode, selection binding should be an array. For touch enabled devices, selection is managed by tapping and for other devices metakey or shiftkey are required. Setting metaKeySelection property as false enables multiple + selection without meta key. +
+row-select and row-unselects are available as selection events.
+Single selection can also be handled using radio buttons by enabling the selectionMode property of column as "single".
+In addition to a regular table, alternatives with alternative sizes are available.
+Enabling sortable property on a column is enough to make a column sortable. Multiple column sorting is enabled using sortMode property and used with metaKey.
+Use metakey to add a column to the sort selection.
+Stateful table allows keeping the state such as page, sort and filtering either at local storage or session storage so that when the page is visited again, table would render the data using its last settings.
+Adding stripedRows displays rows with alternating colors.
+Certain rows or cells can easily be styled based on conditions.
+Custom content at header, body and footer sections are supported via templating.
+VirtualScroller is a performant approach to handle huge data efficiently.
+
+import DataView from 'primevue/dataview';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/dataview/dataview.min.js"></script>
+
+
+
+ DataView utilizes PrimeFlex library so it needs to be installed before getting started. Refer to PrimeFlex documentation for details.
+ ++ DataView requires a collection of items as its value and one or more templates depending on the layout mode e.g. list and grid. Throughout the samples, a car interface having vin, brand, year and color properties are used to define an + object to be displayed by the dataview. Cars are loaded by a CarService that connects to a server to fetch the cars. +
+
+export default {
+ data() {
+ return {
+ cars: null,
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsLarge().then(data => this.cars = data);
+ }
+}
+
+
+
+ DataView has two layout modes; list and grid where a separate template is used to render an item in each mode. In list mode name of the template is "list" whereas in grid mode it is "grid".
+Note that there is no restriction to use both layouts at the same time, you may configure only one layout using the layout property with the corresponding template.
+
+<template #list="slotProps">
+ <div class="col-12">
+ <div class="car-details">
+ <div>
+ <img :src="'demo/images/car/' + slotProps.data.brand + '.png'" :alt="slotProps.data.brand"/>
+ <div class="grid">
+ <div class="col-12">Vin: <b>{{slotProps.data.vin}}</b></div>
+ <div class="col-12">Year: <b>{{slotProps.data.year}}</b></div>
+ <div class="col-12">Brand: <b>{{slotProps.data.brand}}</b></div>
+ <div class="col-12">Color: <b>{{slotProps.data.color}}</b></div>
+ </div>
+ </div>
+ <Button icon="pi pi-search"></Button>
+ </div>
+ </div>
+</template>
+<template #grid="slotProps">
+ <div style="padding: .5em" class="col-12 md:col-3">
+ <Panel :header="slotProps.data.vin" style="text-align: center">
+ <img :src="'demo/images/car/' + slotProps.data.brand + '.png'" :alt="slotProps.data.brand"/>
+ <div class="car-detail">{{slotProps.data.year}} - {{slotProps.data.color}}</div>
+ <Button icon="pi pi-search"></Button>
+ </Panel>
+ </div>
+</template>
+
+
+
+ Header and Footer are the two templates that are capable of displaying custom content.
+
+<template #header>Header Content</template>
+<template #footer>Footer Content</template>
+
+
+
+ Where there is no data to display, the optional empty template can be used to display information.
+
+<template #empty>No records found.</template>
+
+
+
+ + When both layout modes are enabled in DataView, a UI element would be necessary to let the user toggle between the view. DataViewLayoutOptions is a helper component to display a buttonset to choose the layout mode in DataView. Location of + the DataViewLayoutOptions should be inside the DataView component. If you prefer a different UI element you can create your own that updates the layout property of the DataView. +
+ +
+<DataView :value="cars" :layout="layout">
+ <template #header>
+ <DataViewLayoutOptions v-model="layout"></DataViewLayoutOptions>
+ </template>
+ <template #list="slotProps" >
+ <div>Vin: <b>{{slotProps.data.vin}}</b></div>
+ </template>
+ <template #grid="slotProps">
+ <div>Vin: <b>{{slotProps.data.vin}}</b></div>
+ </template>
+</DataView>
+
+
+
+ + Pagination is enabled by setting paginator property to true, rows attribute defines the number of rows per page and pageLinks specify the the number of page links to display. To customize the left and right side of the paginators, use + paginatorstart and paginatorend templates. +
+
+<DataView :value="cars" :layout="layout" paginatorPosition="both" :paginator="true" :rows="20">
+ <template #paginatorstart>
+ <Button type="button" icon="pi pi-refresh"/>
+ </template>
+ <template #paginatorend>
+ <Button type="button" icon="pi pi-search" />
+ </template>
+ <template #list="slotProps" >
+ <div>Vin: <b>{{slotProps.data.vin}}</b></div>
+ </template>
+ <template #grid="slotProps">
+ <div>Vin: <b>{{slotProps.data.vin}}</b></div>
+ </template>
+</DataView>
+
+
+
+ + sortField and sortOrder properties are available for the sorting functionality, for flexibility there is no built-in UI available so that a custom UI can be used for the sorting element. Here is an example that uses a + dropdown where simply updating the sortField-sortOrder bindings of the DataView initiates sorting. +
+
+<DataView :value="cars" :layout="layout" :sortOrder="sortOrder" :sortField="sortField">
+ <template #header>
+ <div class="grid grid-nogutter">
+ <div class="col-6" style="text-align: left">
+ <Dropdown v-model="sortKey" :options="sortOptions" optionLabel="label" placeholder="Sort By" @change="onSortChange($event)"/>
+ </div>
+ <div class="col-6" style="text-align: right">
+ <DataViewLayoutOptions v-model="layout" />
+ </div>
+ </div>
+ </template>
+ <template #list="slotProps" >
+ <div>Vin: <b>{{slotProps.data.vin}}</b></div>
+ </template>
+ <template #grid="slotProps">
+ <div>Vin: <b>{{slotProps.data.vin}}</b></div>
+ </template>
+</DataView>
+
+
+
+
+export default {
+ data() {
+ return {
+ cars: null,
+ layout: 'list',
+ sortKey: null,
+ sortOrder: null,
+ sortField: null,
+ sortOptions: [
+ {label: 'Newest First', value: '!year'},
+ {label: 'Oldest First', value: 'year'},
+ {label: 'Brand', value: 'brand'}
+ ]
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsLarge().then(data => this.cars = data);
+ },
+ methods: {
+ onSortChange(event){
+ const value = event.value.value;
+ const sortValue = event.value;
+
+ if (value.indexOf('!') === 0) {
+ this.sortOrder = -1;
+ this.sortField = value.substring(1, value.length);
+ this.sortKey = sortValue;
+ }
+ else {
+ this.sortOrder = 1;
+ this.sortField = value;
+ this.sortKey = sortValue;
+ }
+ }
+ }
+}
+
+
+
+ + Lazy loading is useful to deal with huge datasets, in order to implement lazy loading use the pagination and utilize the page callback to load your data from the backend. Pagination in this case needs to display the logical number + of records bound to the totalRecords property so that paginator can display itself according to the total records although you'd only need to load the data of the current page. +
+
+<DataView :value="cars" :layout="layout" :paginator="true" :rows="20" :lazy="true" @page="onPage($event)">
+ <template #list="slotProps" >
+ <div>Vin: <b>{{slotProps.data.vin}}</b></div>
+ </template>
+ <template #grid="slotProps">
+ <div>Vin: <b>{{slotProps.data.vin}}</b></div>
+ </template>
+</DataView>
+
+
+
+
+export default {
+ data() {
+ return {
+ cars: null,
+ layout: 'list'
+ }
+ },
+ carService: null,
+ mounted() {
+ this.cars = //initialize the first chunk of data between 0 and 20
+ },
+ methods: {
+ onPage(event){
+ this.cars = //load the data between (event.first) and (event.first + event.rows) from a remote datasource
+ }
+ }
+}
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
value | +array | +null | +An array of objects to display. | +
layout | +string | +list | +Layout of the items, valid values are "list" and "grid". | +
rows | +number | +0 | +Number of rows to display per page. | +
first | +number | +0 | +Index of the first record to render. | +
totalRecords | +number | +null | +Number of total records, defaults to length of value when not defined. | +
paginator | +boolean | +false | +When specified as true, enables the pagination. | +
paginatorPosition | +string | +bottom | +Position of the paginator, options are "top","bottom" or "both". | +
alwaysShowPaginator | +boolean | +true | +Whether to show it even there is only one page. | +
paginatorTemplate | +string | +FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown | +Template of the paginator. See the |
+
pageLinkSize | +number | +5 | +Number of page links to display. | +
rowsPerPageOptions | +array | +null | +Array of integer values to display inside rows per page dropdown. | +
currentPageReportTemplate | +string | +({currentPage} of {totalPages}) | +Template of the current page report element. | +
sortField | +string | +null | +Property name or a getter function of data to use in sorting by default. | +
sortOrder | +number | +null | +Order to sort the data by default. | +
lazy | +boolean | +false | +Defines if data is loaded and interacted with in lazy manner. | +
dataKey | +string | +null | +Name of the data that uniquely identifies the a record in the data. | +
Name | +Parameters | +Description | +
---|---|---|
page | +
+ event.page: New page number + event.first: Index of first record + event.rows: Number of rows to display in new page + event.pageCount: Total number of pages + |
+ Callback to invoke when page changes, the event object contains information about the new state. | +
Name | +Parameters | +
---|---|
header | +- | +
paginatorstart | +- | +
paginatorend | +- | +
list | +
+ data: Value of the component + index: Index of the list + |
+
grid | +
+ data: Value of the component + index: Index of the grid + |
+
empty | +- | +
footer | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-dataview | +Container element. | +
p-dataview-list | +Container element in list layout. | +
p-dataview-grid | +Container element in grid layout. | +
p-dataview-header | +Header section. | +
p-dataview-footer | +Footer section. | +
p-dataview-content | +Container of items. | +
p-dataview-emptymessage | +Empty message element. | +
PrimeFlex
+DataView displays data in grid or list layout with pagination and sorting features.
+
+import DeferredContent from 'primevue/deferredcontent';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/deferredcontent/deferredcontent.min.js"></script>
+
+
+
+ DeferredContent is used as a wrapper element of its content..
+
+<DeferredContent>
+ <DataTable :value="cars">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+ </DataTable>
+</DeferredContent>
+
+
+
+ onLoad callback is useful to initialize the content when it becomes visible on scroll such as loading data.
+
+<DeferredContent @load="onDataLoad">
+ <DataTable :value="cars">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+ </DataTable>
+</DeferredContent>
+
+
+
+ Component has no properties.
+ +Name | +Parameters | +Description | +
---|---|---|
load | +event: Event object | +Callback to invoke when deferred content is loaded.. | +
Component does not apply any styling.
+ ++ DeferredContent can be utilized in many use cases as a result no role is enforced, in fact a role may not be necessary if the card is used for presentational purposes only. Any valid attribute is passed to the container element so you + have full control over the roles like landmark and attributes like aria-live. +
+ +
+<DeferredContent role="region" aria-live="polite" aria-label="Content loaded after page scrolled down">
+ Content
+</DeferredContent>
+
+
+
+ Component does not include any interactive elements.
+None.
+DeferredContent postpones the loading the content that is initially not in the viewport until it becomes visible on scroll.
+
+import Dialog from 'primevue/dialog';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ Dialog is used as a container and visibility is managed with visible property that requires the v-model for two-way binding.
+
+<Dialog header="Header" v-model:visible="display" >
+ Content
+</Dialog>
+
+
+
+
+export default {
+ data() {
+ return {
+ display: false
+ }
+ }
+}
+
+
+
+ Header and Footer sections are defined using properties with the same name that accept simple strings or with the header and footer templates for custom content.
+
+<Dialog header="Header" footer="Footer" v-model:visible="display">
+ Content
+</Dialog>
+
+
+
+
+<Dialog v-model:visible="display">
+ <template #header>
+ <h3>Header</h3>
+ </template>
+
+ Content
+
+ <template #footer>
+ <Button label="No" icon="pi pi-times" class="p-button-text"/>
+ <Button label="Yes" icon="pi pi-check" autofocus />
+ </template>
+</Dialog>
+
+
+
+ Dialog location is controlled with the position property whose default value is center. Other valid values are top", "bottom", "left", "right", "topleft", "topright", "bottomleft" and "bottomright".
+
+<Dialog position="top" v-model:visible="display">
+ Content
+</Dialog>
+
+
+
+ + Dialog width can be adjusted per screen size with the breakpoints option. In example below, default width is set to 50vw and below 961px, width would be 75vw and finally below 641px width becomes 100%. The value of + breakpoints should be an object literal whose keys are the maximum screen sizes and values are the widths per screen. +
+ +
+<Dialog v-model:visible="display" :breakpoints="{'960px': '75vw', '640px': '100vw'}" :style="{width: '50vw'}">
+ Content
+</Dialog>
+
+
+
+ Adding autofocus to an element in the dialog makes it the initial focus target when dialog gets shown.
+
+<Dialog v-model:visible="display">
+ Content
+ <template #footer>
+ <Button label="No" />
+ <Button label="Yes" autofocus/>
+ </template>
+</Dialog>
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
header | +any | +null | +Title content of the dialog. | +
footer | +any | +null | +Footer content of the dialog. | +
visible | +boolean | +false | +Specifies the visibility of the dialog. | +
modal | +boolean | +null | +Defines if background should be blocked when dialog is displayed. | +
closeOnEscape | +boolean | +true | +Specifies if pressing escape key should hide the dialog. | +
dismissableMask | +boolean | +false | +Specifies if clicking the modal background should hide the dialog. | +
position | +string | +center | +Position of the dialog, options are "center", "top", "bottom", "left", "right", "topleft", "topright", "bottomleft" or "bottomright". | +
contentStyle | +object | +null | +Style of the content section. | +
contentClass | +string | +null | +Style class of the content section. | +
rtl | +boolean | +null | +When enabled dialog is displayed in RTL direction. | +
closable | +boolean | +true | +Adds a close icon to the header to hide the dialog. | +
showHeader | +boolean | +true | +Whether to show the header or not. | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
autoZIndex | +boolean | +true | +Whether to automatically manage layering. | +
ariaCloseLabel | +string | +close | +Aria label of the close icon. | +
maximizable | +boolean | +false | +Whether the dialog can be displayed full screen. | +
breakpoints | +object | +null | +Object literal to define widths per screen size. | +
draggable | +boolean | +true | +Enables dragging to change the position using header. | +
minX | +number | +0 | +Minimum value for the left coordinate of dialog in dragging. | +
minY | +number | +0 | +Minimum value for the top coordinate of dialog in dragging. | +
keepInViewport | +boolean | +true | +Keeps dialog in the viewport when dragging. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the dialog gets attached. Special keywords are "body" for document body and "self" for the element itself. | +
Name | +Parameters | +Description | +
---|---|---|
hide | +- | +Callback to invoke when dialog is hidden. | +
after-hide | +- | +Callback to invoke after dialog is hidden. | +
show | +- | +Callback to invoke when dialog is showed. | +
maximize | +event: Event object | +Fired when a dialog gets maximized. | +
unmaximize | +event: Event object | +Fired when a dialog gets unmaximized. | +
dragend | +event: Event object | +Fired when a dialog drag completes.. | +
Name | +Parameters | +
---|---|
header | +- | +
footer | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-dialog | +Container element. | +
p-dialog-titlebar | +Container of header. | +
p-dialog-title | +Header element. | +
p-dialog-titlebar-icon | +Icon container inside header. | +
p-dialog-titlebar-close | +Close icon element. | +
p-dialog-content | +Content element | +
None.
+Dialog is a container to display content in an overlay window.
+
+import Divider from 'primevue/divider';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/divider/divider.min.js"></script>
+
+
+
+ Divider has two orientations defined with the layout property, default is "horizontal" and the alternative is "vertical".
+
+<div>Content 1</div>
+<Divider />
+<div>Content 2</div>
+
+
+
+ Style of the border is configured with the type property and supports 3 values; default is "solid" and other possibilities are "dashed" and "dotted".
+
+<div>Content 1</div>
+<Divider type="dashed"/>
+<div>Content 2</div>
+
+
+
+ Vertical divider is enabled by setting the layout property as "vertical".
+
+<div class="flex">
+ <div>Content 1</div>
+ <Divider layout="vertical" />
+ <div>Content 2</div>
+ <Divider layout="vertical" />
+ <div>Content 3</div>
+</div>
+
+
+
+ + Any content placed inside is rendered within the boundaries of the divider. In addition, location of the content is configured with the align property. In horizontal layout, alignment options are "left", "center" and "right" + whereas vertical mode supports "top", "center" and "bottom". +
+
+<div>Content 1</div>
+
+<Divider align="left">
+ <div class="inline-flex align-items-center">
+ <i class="pi pi-user mr-2"></i>
+ <b>Icon</b>
+ </div>
+</Divider>
+
+<div>Content 2</div>
+
+<Divider align="center">
+ <span class="p-tag">Badge</span>
+</Divider>
+
+<div>Content 3</div>
+
+<Divider align="right">
+ <Button label="Button" icon="pi pi-search" class="p-button-outlined"></Button>
+</Divider>
+
+<div>Content 4</div>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
align | +string | +null | +Alignment of the content, options are "left", "center", "right" for horizontal layout and "top", "center", "bottom" for vertical. | +
layout | +string | +horizontal | +Specifies the orientation, valid values are "horizontal" and "vertical". | +
type | +string | +solid | +Border style type, default is "solid" and other options are "dashed" and "dotted". | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-divider | +Container element. | +
p-divider-horizontal | +Container element in horizontal layout. | +
p-divider-vertical | +Container element in vertical layout. | +
p-divider-solid | +Container element with solid border. | +
p-divider-dashed | +Container element with dashed border. | +
p-divider-dotted | +Container element with dotted border. | +
p-divider-left | +Container element with content aligned to left. | +
p-divider-right | +Container element with content aligned to right. | +
p-divider-center | +Container element with content aligned to center. | +
p-divider-bottom | +Container element with content aligned to bottom. | +
p-divider-top | +Container element with content aligned to top. | +
Divider uses a separator role with aria-orientation set to either "horizontal" or "vertical".
+ +Component does not include any interactive elements.
+None.
+Divider is used to separate contents.
++ 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. +
+ ++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim + ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
+ ++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui + officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
+ ++ Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis + voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. Donec vel volutpat ipsum. Integer nunc magna, posuere ut tincidunt eget, egestas vitae sapien. Morbi dapibus luctus odio. +
++ 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. +
+ ++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim + ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
+ ++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui + officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
+ ++ Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis + voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. Donec vel volutpat ipsum. Integer nunc magna, posuere ut tincidunt eget, egestas vitae sapien. Morbi dapibus luctus odio. +
++ 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. +
+ ++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim + ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
+ ++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui + officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
+ ++ Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis + voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. Donec vel volutpat ipsum. Integer nunc magna, posuere ut tincidunt eget, egestas vitae sapien. Morbi dapibus luctus odio. +
++ 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. +
+ ++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim + ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
+ ++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa + qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
+
+import Dock from 'primevue/dock';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/slider/slider.min.js"></script>
+
+
+
+ Dock is a navigation component consisting of menuitems. It has a collection of additional options defined by the model property.
+ +
+<Dock :model="items" />
+
+
+
+
+ export default {
+ data() {
+ return {
+ items: [
+ {
+ label: "Finder",
+ icon: "demo/images/dock/finder.svg"
+ },
+ {
+ label: "App Store",
+ icon: "demo/images/dock/appstore.svg"
+ },
+ {
+ label: "Photos",
+ icon: "demo/images/dock/photos.svg"
+ },
+ {
+ label: "Trash",
+ icon: "demo/images/dock/trash.png"
+ }
+ ]
+ }
+ }
+ }
+
+
+
+
+ Dock uses the common MenuModel API to define the items, visit
Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
model | +object | +null | +MenuModel instance to define the action items. | +
position | +string | +bottom | +Position of element. Valid values are 'bottom', 'top', 'left' and 'right'. | +
class | +string | +null | +Style class of the element. | +
style | +object | +null | +Inline style of the element. | +
exact | +boolean | +true | +Whether to apply 'router-link-active-exact' class if route exactly matches the item path. | +
tooltipOptions | +object | +null | +Whether to display the tooltip on items. The modifiers of |
+
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-dock | +Container element. | +
p-dock-list | +List of items. | +
p-dock-item | +Each items in list. | +
Name | +Parameters | +
---|---|
item | +item: Custom content for item | +
icon | +item: Custom content for icon | +
None.
+Dock is a navigation component consisting of menuitems.
+
+import Dropdown from 'primevue/dropdown';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ Dropdown requires a value to bind and a collection of arbitrary objects along with the optionLabel property to specify the label property of the option.
+
+<Dropdown v-model="selectedCity" :options="cities" optionLabel="name" placeholder="Select a City" />
+
+
+
+
+data() {
+ return {
+ selectedCity: null,
+ cities: [
+ {name: 'New York', code: 'NY'},
+ {name: 'Rome', code: 'RM'},
+ {name: 'London', code: 'LDN'},
+ {name: 'Istanbul', code: 'IST'},
+ {name: 'Paris', code: 'PRS'}
+ ]
+ }
+}
+
+
+
+ Common pattern is providing an empty option as the placeholder when using native selects, however Dropdown has built-in support using the placeholder option so it is suggested to use it instead of creating an empty option.
+ +Options groups are specified with the optionGroupLabel and optionGroupChildren properties.
+
+export default {
+ data() {
+ return {
+ selectedGroupedCity: null,
+ groupedCities: [{
+ label: 'Germany', code: 'DE',
+ items: [
+ {label: 'Berlin', value: 'Berlin'},
+ {label: 'Frankfurt', value: 'Frankfurt'},
+ {label: 'Hamburg', value: 'Hamburg'},
+ {label: 'Munich', value: 'Munich'}
+ ]
+ },
+ {
+ label: 'USA', code: 'US',
+ items: [
+ {label: 'Chicago', value: 'Chicago'},
+ {label: 'Los Angeles', value: 'Los Angeles'},
+ {label: 'New York', value: 'New York'},
+ {label: 'San Francisco', value: 'San Francisco'}
+ ]
+ },
+ {
+ label: 'Japan', code: 'JP',
+ items: [
+ {label: 'Kyoto', value: 'Kyoto'},
+ {label: 'Osaka', value: 'Osaka'},
+ {label: 'Tokyo', value: 'Tokyo'},
+ {label: 'Yokohama', value: 'Yokohama'}
+ ]
+ }]
+ }
+ }
+}
+
+
+
+<Dropdown v-model="selectedGroupedCity" :options="groupedCities"
+ optionLabel="label" optionGroupLabel="label" optionGroupChildren="items">
+</Dropdown>
+
+
+
+ + Filtering allows searching items in the list using an input field at the header. In order to use filtering, enable filter property. By default, optionLabel is used when searching and filterFields can be used to customize the + fields being utilized. Furthermore, filterMatchMode is available to define the search algorithm. Valid values are "contains" (default), "startsWith" and "endsWith". +
+ +
+<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" placeholder="Select a Car" :filter="true" filterPlaceholder="Find Car"/>
+
+
+
+ + Label of an option is used as the display text of an item by default, for custom content support define an option template that gets the option instance as a parameter. In addition value, optiongroup, header, + footer, emptyfilter and empty slots are provided for further customization. +
+
+<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" :filter="true" placeholder="Select a Car" :showClear="true">
+ <template #value="slotProps">
+ <div class="p-dropdown-car-value" v-if="slotProps.value">
+ <img :alt="slotProps.value.brand" :src="'demo/images/car/' + slotProps.value.brand + '.png'" />
+ <span>{{slotProps.value.brand}}</span>
+ </div>
+ <span v-else>
+ {{slotProps.placeholder}}
+ </span>
+ </template>
+ <template #option="slotProps">
+ <div class="p-dropdown-car-option">
+ <img :alt="slotProps.option.brand" :src="'demo/images/car/' + slotProps.option.brand + '.png'" />
+ <span>{{slotProps.option.brand}}</span>
+ </div>
+ </template>
+</Dropdown>
+
+
+
+ Any property of HTMLDivElement are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
options | +array | +null | +An array of selectitems to display as the available options. | +
optionLabel | +string | function | +null | +Property name or getter function to use as the label of an option. | +
optionValue | +string | function | +null | +Property name or getter function to use as the value of an option, defaults to the option itself when not defined. | +
optionDisabled | +string | function | +null | +Property name or getter function to use as the disabled flag of an option, defaults to false when not defined. | +
optionGroupLabel | +string | function | +null | +Property name or getter function to use as the label of an option group. | +
optionGroupChildren | +string | function | +null | +Property name or getter function that refers to the children options of option group. | +
scrollHeight | +string | +200px | +Height of the viewport, a scrollbar is defined if height of list exceeds this value. | +
filter | +boolean | +false | +When specified, displays a filter input at header. | +
filterPlaceholder | +string | +null | +Placeholder text to show when filter input is empty. | +
filterLocale | +string | +undefined | +Locale to use in filtering. The default locale is the host environment's current locale. | +
filterMatchMode | +string | +contains | +Defines the filtering algorithm to use when searching the options. Valid values are "contains" (default), "startsWith" and "endsWith" | +
filterFields | +array | +null | +Fields used when filtering the options, defaults to optionLabel. | +
editable | +boolean | +false | +When present, custom value instead of predefined options can be entered using the editable input field. | +
placeholder | +string | +null | +Default text to display when no option is selected. | +
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +
dataKey | +string | +null | +A property to uniquely identify an option. | +
showClear | +boolean | +false | +When enabled, a clear icon is displayed to clear the value. | +
inputId | +string | +null | +Identifier of the underlying input element. | +
inputStyle | +any | +null | +Inline style of the input field. | +
inputClass | +string | +null | +Style class of the input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement/HTMLSpanElement to the focusable input element inside the component. | +
panelStyle | +any | +null | +Inline style of the overlay panel. | +
panelClass | +string | +null | +Style class of the overlay panel. | +
panelProps | +object | +null | +Uses to pass all properties of the HTMLDivElement to the overlay panel. | +
filterInputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the filter input inside the overlay panel. | +
clearIconProps | +object | +null | +Uses to pass all properties of the HTMLElement to the clear icon inside the component. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. Special keywords are "body" for document body and "self" for the element itself. | +
loading | +boolean | +false | +Whether the dropdown is in loading state. | +
loadingIcon | +string | +pi pi-spinner pi-spin | +Icon to display in loading state. | +
resetFilterOnHide | +boolean | +false | +Clears the filter value when hiding the dropdown. | +
virtualScrollerOptions | +object | +null | +Whether to use the virtualScroller feature. The properties of |
+
autoOptionFocus | +boolean | +true | +Whether to focus on the first visible or selected element when the overlay panel is shown. | +
autoFilterFocus | +boolean | +false | +Whether to focus on the filter element when the overlay panel is shown. | +
selectOnFocus | +boolean | +false | +When enabled, the focused option is selected. | +
filterMessage | +string | +{0} results are available | +Text to be displayed in hidden accessible field when filtering returns any results. Defaults to value from PrimeVue locale configuration. | +
selectionMessage | +string | +{0} items selected | +Text to be displayed in hidden accessible field when options are selected. Defaults to value from PrimeVue locale configuration. | +
emptySelectionMessage | +string | +No selected item | +Text to be displayed in hidden accessible field when any option is not selected. Defaults to value from PrimeVue locale configuration. | +
emptyFilterMessage | +string | +No results found | +Text to be displayed when filtering does not return any results. Defaults to value from PrimeVue locale configuration. | +
emptyMessage | +string | +No results found | +Text to be displayed when there are no options available. Defaults to value from PrimeVue locale configuration. | +
tabindex | +number | +0 | +Index of the element in tabbing order. | +
aria-label | +string | +null | +Defines a string value that labels an interactive element. | +
aria-labelledby | +string | +null | +Establishes relationships between the component and label(s) where its value should be one or more element IDs. | +
Name | +Parameters | +Description | +
---|---|---|
change | +
+ event.originalEvent: Original event + event.value: Selected option value + |
+ Callback to invoke on value change. | +
focus | +event | +Callback to invoke when the component receives focus. | +
blur | +event | +Callback to invoke when the component loses focus. | +
before-show | +- | +Callback to invoke before the overlay is shown. | +
before-hide | +- | +Callback to invoke before the overlay is hidden. | +
show | +- | +Callback to invoke when the overlay is shown. | +
hide | +- | +Callback to invoke when the overlay is hidden. | +
filter | +
+ event.originalEvent: Original event + event.value: Filter value + |
+ Callback to invoke on filter input. | +
Name | +Parameters | +Description | +
---|---|---|
show | +isFocus: Decides whether to focus on the component. Default value is false. | +Shows the overlay. | +
hide | +isFocus: Decides whether to focus on the component. Default value is false. | +Hides the overlay. | +
Name | +Parameters | +
---|---|
value | +
+ value: Value of the component + placeholder: Placeholder prop value + |
+
indicator | +- | +
header | +
+ value: Value of the component + options: Displayed options + |
+
footer | +
+ value: Value of the component + options: Displayed options + |
+
option | +
+ option: Option instance + index: Index of the option + |
+
optiongroup | +
+ option: OptionGroup instance + index: Index of the option group + |
+
emptyfilter | +- | +
empty | +- | +
content | +
+ items: An array of objects to display for virtualscroller + styleClass: Style class of the component + contentRef: Referance of the content + getItemOptions: Options of the items + |
+
loader | +options: Options of the loader items for virtualscroller | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-dropdown | +Container element. | +
p-dropdown-label | +Element to display label of selected option. | +
p-dropdown-trigger | +Icon element. | +
p-dropdown-panel | +Icon element. | +
p-dropdown-items-wrapper | +Wrapper element of items list. | +
p-dropdown-items | +List element of items. | +
p-dropdown-item | +An item in the list. | +
p-dropdown-filter-container | +Container of filter input. | +
p-dropdown-filter | +Filter element. | +
p-overlay-open | +Container element when overlay is visible. | +
+ Value to describe the component can either be provided with aria-labelledby or aria-label props. The dropdown element has a combobox role in addition to aria-haspopup and aria-expanded attributes. If the + editable option is enabled aria-autocomplete is also added. The relation between the combobox and the popup is created with aria-controls and aria-activedescendant attribute is used to instruct screen reader which + option to read during keyboard navigation within the popup list. +
++ The popup list has an id that refers to the aria-controls attribute of the combobox element and uses listbox as the role. Each list item has an option role, an id to match the aria-activedescendant of + the input element along with aria-label, aria-selected and aria-disabled attributes. +
+ +If filtering is enabled, filterInputProps can be defined to give aria-* props to the filter input element.
+
+<span id="dd1">Options</span>
+<Dropdown aria-labelledby="dd1" />
+
+<Dropdown aria-label="Options" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the dropdown element. | +
space | +Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. | +
enter | +Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. | +
down arrow | +Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. | +
up arrow | +Opens the popup and moves visual focus to the selected option, if there is none then last option receives the focus. | +
any printable character | +Opens the popup and moves focus to the option whose label starts with the characters being typed, if there is none and dropdown is not editable then first option receives the focus. | +
Key | +Function | +
---|---|
tab | +Moves focus to the next focusable element in the popup. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. | +
shift + tab | +Moves focus to the previous focusable element in the popup. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. | +
enter | +Selects the focused option and closes the popup, then moves focus to the dropdown element. | +
space | +Selects the focused option and closes the popup, then moves focus to the dropdown element. | +
escape | +Closes the popup, then moves focus to the dropdown element. | +
down arrow | +Moves focus to the next option, if there is none then visual focus does not change. | +
up arrow | +Moves focus to the previous option, if there is none then visual focus does not change. | +
alt + up arrow | +Selects the focused option and closes the popup, then moves focus to the dropdown element. | +
left arrow | +If the dropdown is editable, removes the visual focus from the current option and moves input cursor to one character left. | +
right arrow | +If the dropdown is editable, removes the visual focus from the current option and moves input cursor to one character right. | +
home | +If the dropdown is editable, moves input cursor at the end, if not then moves focus to the first option. | +
end | +If the dropdown is editable, moves input cursor at the beginning, if not then moves focus to the last option. | +
pageUp | +Jumps visual focus to first option. | +
pageDown | +Jumps visual focus to last option. | +
any printable character | +Moves focus to the option whose label starts with the characters being typed if dropdown is not editable. | +
Key | +Function | +
---|---|
down arrow | +Moves focus to the next option, if there is none then visual focus does not change. | +
up arrow | +Moves focus to the previous option, if there is none then visual focus does not change. | +
left arrow | +Removes the visual focus from the current option and moves input cursor to one character left. | +
right arrow | +Removes the visual focus from the current option and moves input cursor to one character right. | +
home | +Moves input cursor at the end, if not then moves focus to the first option. | +
end | +Moves input cursor at the beginning, if not then moves focus to the last option. | +
enter | +Closes the popup and moves focus to the dropdown element. | +
escape | +Closes the popup and moves focus to the dropdown element. | +
tab | +Moves focus to the next focusable element in the popup. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. | +
None.
+Dropdown is used to select an item from a list of options.
+Dialogs can be created dynamically with any component as the content using a DialogService.
+Dynamic dialogs require the DialogService to be configured globally.
+ +
+import {createApp} from 'vue';
+import DialogService from 'primevue/dialogservice';
+
+const app = createApp(App);
+app.use(DialogService);
+
+
+
+
+import DynamicDialog from 'primevue/dynamicdialog';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/dynamicdialog/dynamicdialog.min.js"></script>
+
+
+
+ Ideal location of a DynamicDialog is the main application template so that it can be used by any component within the application.
+ +
+<template>
+ <DynamicDialog />
+<template>
+
+
+
+ $dialog is available as a property in the application instance.
+
+const dialogRef = this.$dialog;
+
+
+
+ The service can be injected with the useDialog function.
+
+import { useDialog } from 'primevue/usedialog';
+
+const dialog = useDialog();
+
+
+
+ The open function of the DialogService is used to open a Dialog. First parameter is the component to load and second one is the configuration object to customize the Dialog.
+ +
+import ProductListDemo from './ProductListDemo';
+
+export default {
+ methods:{
+ showProducts() {
+ this.$dialog.open(ProductListDemo, {});
+ }
+ }
+}
+
+
+
+
+import ProductListDemo from './ProductListDemo';
+import { useDialog } from 'primevue/usedialog';
+
+export default {
+ methods:{
+ showProducts() {
+ const dialog = useDialog();
+ dialog.open(ProductListDemo, {});
+ }
+ }
+}
+
+
+
+ The close function of the dialogRef is used to hide a Dialog. The dialogRef is injected to the component that is loaded by the dialog.
+ +
+export default {
+ inject: ['dialogRef'],
+ methods:{
+ closeDialog() {
+ this.dialogRef.close();
+ }
+ }
+}
+
+
+
+
+import { inject } from 'vue'
+
+export default {
+ methods:{
+ closeDialog() {
+ const dialogRef = inject('dialogRef');
+ dialogRef.value.close();
+ }
+ }
+}
+
+
+
+ Data can be passed to the component that is loaded by the Dialog and also from the component back to the caller component. Use the open function and pass your parameters with the data property in the options object.
+ +
+this.$dialog.open(ProductListDemo, {
+ data: {
+ user: 'primetime'
+ }
+};
+
+
+
+
+export default {
+ inject: ['dialogRef'],
+ mounted:{
+ const params = this.dialogRef.data; //{user: 'primetime'}
+ }
+}
+
+
+
+ Similarly when hiding a Dialog, any parameter passed to the close function is received from the onClose callback defined by the open function at the caller.
+
+this.$dialog.open(ProductListDemo, {
+ onClose(options) {
+ const callbackParams = options.data; //{id: 12}
+ }
+);
+
+
+
+
+export default {
+ inject: ['dialogRef'],
+ methods:{
+ closeDialog() {
+ this.dialogRef.close({id: 12});
+ }
+ }
+}
+
+
+
+ props option is used to customize the dynamically generated Dialog, refer to the
+import { h } from 'vue';
+import Button from 'primevue/button';
+import ProductListDemo from './ProductListDemo';
+
+export default {
+ methods:{
+ showProducts() {
+ const dialogRef = this.$dialog.open(ProductListDemo, {
+ props: {
+ header: 'Product List',
+ style: {
+ width: '50vw',
+ },
+ breakpoints:{
+ '960px': '75vw',
+ '640px': '90vw'
+ },
+ modal: true
+ },
+ templates: {
+ footer: () => {
+ return [
+ h(Button, { label: "No", icon: "pi pi-times", onClick: () => dialogRef.close(), class: "p-button-text" }),
+ h(Button, { label: "Yes", icon: "pi pi-check", onClick: () => dialogRef.close(), autofocus: true})
+ ]
+ }
+ },
+ onClose: (options) => {
+ const data = options.data;
+ if (data) {
+ this.$toast.add({ severity:'info', summary: 'Info Message', detail:'Order submitted', life: 3000 });
+ }
+ }
+ });
+ }
+ }
+}
+
+
+ DialogService is the main entry point to open a dialog and load any content within.
+ +Name | +Parameters | +Description | +
---|---|---|
open | +
+ content: The component to load + options: Configuration of the Dialog + |
+ Creates a dialog dynamically with the given options and loads the component. See the Dialog Open Configuration API section below for the avaiable properties. | +
Options to configure a dynamically loaded Dialog including Dialog props, data to pass and callback to execute on hide.
+Name | +Type | +Default | +Description | +
---|---|---|---|
props | +object | +null | +Properties of a dialog. | +
data | +object | +null | +Data to pass to the loaded component. | +
templates | +object | +null | +Templates of a dialog including, header and footer. | +
onClose | +function | +null | +Function callback to invoke when dialog is closed. | +
Reference to the dynamic dialog that can be used to access the passed data and close the dialog with the option of passing data back to the caller.
+Name | +Type | +Default | +Description | +
---|---|---|---|
content | +object | +null | +Loaded content of a dialog. | +
options | +object | +null | +Options used to open a dialog. | +
data | +object | +null | +Data passed to the dialog. | +
close | +function | +null | +Function to close a dialog. | +
+ There are {{ totalProducts }} products in total in this list. +
+
+import Fieldset from 'primevue/fieldset';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/fieldset/fieldset.min.js"></script>
+
+
+
+ Fieldset is a container component that accepts content as its children.
+
+<Fieldset legend="Godfather I">
+ The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
+ His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
+ Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
+ kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
+</Fieldset>
+
+
+
+ Header of the panel is either defined with the legend property or the legend template.
+
+<Fieldset>
+ <template #legend>
+ Header Content
+ </template>
+ Content
+</Fieldset>
+
+
+
+ Content of the fieldset can be expanded and collapsed using toggleable option..
+
+<Fieldset legend="Godfather I" :toggleable="true">
+ The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
+ His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
+ Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
+ kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
+</Fieldset>
+
+
+
+ To control the initial state of the toggleable panel, use the collapsed property.
+
+<Fieldset legend="Header Text" :toggleable="true" :collapsed="true">
+ Content
+</Fieldset>
+
+
+
+ Use the v-model directive to enable two-way binding.
+
+<button type="button" @click="isCollapsed = !isCollapsed">Toggle Programmatically</button>
+<Fieldset legend="Header Text" :toggleable="true" v-model:collapsed="isCollapsed">
+ Content
+</Fieldset>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
legend | +string | +null | +Header text of the fieldset. | +
toggleable | +boolean | +null | +When specified, content can toggled by clicking the legend. | +
collapsed | +boolean | +null | +Defines the default visibility state of the content. | +
toggleButtonProps | +string | +null | +Uses to pass the custom value to read for the anchor inside the component. | +
Name | +Parameters | +Description | +
---|---|---|
toggle | +
+ event.originalEvent: browser event + event.value: collapsed state as a boolean + |
+ Callback to invoke when a tab gets expanded or collapsed. | +
Name | +Parameters | +
---|---|
legend | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-fieldset | +Fieldset element. | +
p-fieldset-toggleable | +Toggleable fieldset element. | +
p-fieldset-legend | +Legend element. | +
p-fieldset-content | +Content element. | +
+ Fieldset component uses the semantic fieldset element. When toggleable option is enabled, a clickable element with button role is included inside the legend element, this button has aria-controls to define + the id of the content section along with aria-expanded for the visibility state. The value to read the button defaults to the value of the legend property and can be customized by defining an aria-label or + aria-labelledby via the toggleButtonProps property. +
+The content uses region, defines an id that matches the aria-controls of the content toggle button and aria-labelledby referring to the id of the header.
+ +Key | +Function | +
---|---|
tab | +Moves focus to the next the focusable element in the page tab sequence. | +
shift + tab | +Moves focus to the previous the focusable element in the page tab sequence. | +
enter | +Toggles the visibility of the content. | +
space | +Toggles the visibility of the content. | +
None.
+Fieldset is a grouping component with the optional content toggle feature.
+
+import FileUpload from 'primevue/fileupload';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/fileupload/fileupload.min.js"></script>
+
+
+
+ FileUpload requires a url property as the upload target and a name to identify the files at backend.
+
+<FileUpload name="demo[]" url="./upload" />
+
+
+
+ Only one file can be selected at a time by default, to allow selecting multiple files at once enable multiple option.
+
+<FileUpload name="demo[]" url="./upload" :multiple="true" />
+
+
+
+ FileUpload basic mode provides a simpler UI as an alternative to advanced mode.
+
+<FileUpload mode="basic" name="demo[]" url="./upload" />
+
+
+
+ File selection can also be done by dragging and dropping from the filesystem to the content section of the component.
+ +When auto property is enabled, upload begins as soon as file selection is completed or a file is dropped on the drop area.
+
+<FileUpload mode="basic" name="demo[]" url="./upload" :auto="true" />
+
+
+
+ Selectable file types can be restricted with accept property, example below only allows images to be uploaded. Read more about other possible values here.
+
+<FileUpload mode="basic" name="demo[]" url="./upload" accept="image/*" />
+
+
+
+ Maximium file size can be restricted using maxFileSize property defined in bytes. Similarly fileLimit is available to restrict the number of files to be uploaded.
+
+<FileUpload name="demo[]" url="./upload" :maxFileSize="1000000" :fileLimit="3" />
+
+
+
+ In order to customize the default messages use invalidFileSizeMessage and invalidFileLimitMessage options where {0} placeholder refers to the filename and {1} the file size.
+XHR request to upload the files can be customized using the before-upload callback that passes the xhr instance and FormData object as event parameters.
+ +Uploading implementation can be overridden by enabling customMode property and defining a custom upload handler event.
+
+<FileUpload name="demo[]" :customUpload="true" @uploader="myUploader" />
+
+
+
+
+myUploader(event) {
+ //event.files == files to upload
+}
+
+
+
+ When there is no file selected, you may use the empty slot to display content.
+
+<FileUpload name="demo[]" url="./upload">
+ <template #empty>
+ <p>Drag and drop files to here to upload.</p>
+ </template>
+</FileUpload>
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
name | +string | +null | +Name of the request parameter to identify the files at backend. | +
url | +string | +null | +Remote url to upload the files. | +
mode | +string | +advanced | +Defines the UI of the component, possible values are "advanced" and "basic". | +
multiple | +boolean | +false | +Used to select multiple files at once from file dialog. | +
accept | +string | +null | +Pattern to restrict the allowed file types such as "image/*". | +
disabled | +boolean | +false | +Disables the upload functionality. | +
auto | +boolean | +false | +When enabled, upload begins automatically after selection is completed. | +
maxFileSize | +number | +null | +Maximum file size allowed in bytes. | +
invalidFileSizeMessage | +string | +"{0}: Invalid file size, file size should be smaller than {1}." | +Message of the invalid fize size. | +
invalidFileLimitMessage | +string | +Maximum number of files exceeded, limit is {0} at most. | +Message to display when number of files to be uploaded exceeeds the limit. | +
fileLimit | +number | +null | +Maximum number of files that can be uploaded. | +
withCredentials | +boolean | +false | +Cross-site Access-Control requests should be made using credentials such as cookies, authorization headers or TLS client certificates. | +
previewWidth | +number | +50 | +Width of the image thumbnail in pixels. | +
chooseLabel | +string | +null | +Label of the choose button. Defaults to PrimeVue |
+
uploadLabel | +string | +Upload | +Label of the upload button. Defaults to PrimeVue |
+
cancelLabel | +string | +Cancel | +Label of the cancel button. Defaults to PrimeVue |
+
customUpload | +boolean | +false | +Whether to use the default upload or a manual implementation defined in uploadHandler callback. Defaults to PrimeVue |
+
showUploadButton | +boolean | +true | +Whether to show the upload button. | +
showCancelButton | +boolean | +true | +Whether to show the cancel button. | +
chooseIcon | +string | +pi pi-plus | +Icon of the choose button. | +
uploadIcon | +string | +pi pi-upload | +Icon of the upload button. | +
cancelIcon | +string | +pi pi-times | +Icon of the cancel button. | +
style | +any | +null | +Inline style of the component. | +
class | +string | +null | +Style class of the component. | +
Name | +Parameters | +Description | +
---|---|---|
before-upload | +
+ event.xhr: XmlHttpRequest instance. + event.formData: FormData object. + |
+ Callback to invoke before file upload begins to customize the request such as post parameters before the files. | +
before-send | +
+ event.xhr: XmlHttpRequest instance. + event.formData: FormData object. + |
+ Callback to invoke before file send begins to customize the request such as adding headers. | +
upload | +
+ event.xhr: XmlHttpRequest instance. + event.files: Uploaded files. + |
+ Callback to invoke when file upload is complete. | +
error | +
+ event.xhr: XmlHttpRequest instance. + event.files: Files that are not uploaded. + |
+ Callback to invoke if file upload fails. | +
clear | +-. | +Callback to invoke when files in queue are removed without uploading. | +
select | +
+ event.originalEvent: Original browser event. + event.files: List of selected files. + |
+ Callback to invoke when files are selected. | +
progress | +
+ event.originalEvent: Original browser event. + event.progress: Calculated progress value. + |
+ Callback to invoke when files are being uploaded. | +
uploader | +event.files: List of selected files. | +Callback to invoke to implement a custom upload. | +
remove | +
+ event.file: Removed file. + event.files: Remaining files to be uploaded. + |
+ Callback to invoke when a singe file is removed from the list. | +
Name | +Parameters | +
---|---|
empty | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-fileupload | +Container element. | +
p-fileupload-buttonbar | +Header containing the buttons. | +
p-fileupload-content | +Content section. | +
None.
+FileUpload is an advanced uploader with dragdrop support, multi file uploads, auto uploading, progress tracking and validations.
+Drag and drop files to here to upload.
+ +
+import {FilterService} from 'primevue/api';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ Filters are accessed with FilterService.filters.
+
+const value = 'PrimeVue';
+
+FilterService.filters.equals(value, 'Vue'); //false
+FilterService.filters.equals(value, 8); //false
+FilterService.filters.equals(value, new Date()); //false
+FilterService.filters.contains(value, 'Vue'); //true
+FilterService.filters.startsWith(value, 'Vue'); //false
+FilterService.filters.endsWith(value, 'Vue'); //true
+FilterService.filters.lt(10, 20); //true
+FilterService.filters.gt(50, 20); //true
+FilterService.filters.in(value, ['PrimeFaces', 'PrimeVue']); //true
+
+
+
+ FilterService can be extended by adding new constraints using the register function.
+
+FilterService.register('isPrimeNumber', (value, filter): boolean => {
+ if (filter === undefined || filter === null || filter.trim() === '') {
+ return true;
+ }
+
+ if (value === undefined || value === null) {
+ return false;
+ }
+
+ return value.toString() === filter.toString();
+});
+
+FilterService.filters['isPrimeNumber'](3); //true
+FilterService.filters['isPrimeNumber'](5); //true
+FilterService.filters['isPrimeNumber'](568985673); //false
+
+
+
+ Name | +Parameters | +Description | +
---|---|---|
startsWith | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the value starts with the filter value | +
contains | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the value contains the filter value | +
endsWith | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the value ends with the filter value | +
equals | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the value equals the filter value | +
notEquals | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the value does not equal the filter value | +
in | +
+ value: Value to filter + filter[]: An array of filter values + filterLocale: Locale to use in filtering + |
+ Whether the value contains the filter value | +
lt | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the value is less than the filter value | +
lte | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the value is less than or equals to the filter value | +
gt | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the value is greater than the filter value | +
gte | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the value is greater than or equals to the filter value | +
is | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the value equals the filter value, alias to equals | +
isNot | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the value does not equal the filter value, alias to notEquals. | +
before | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the date value is before the filter date. | +
after | +
+ value: Value to filter + filter: Filter value + filterLocale: Locale to use in filtering + |
+ Whether the date value is after the filter date. | +
Name | +Parameters | +Description | +
---|---|---|
filter | +
+ value[]: An array of values to filter + fields[]: An array of properties in the value object + filterValue: Filter value + filterMatchMode: Constraint + filterLocale: Locale to use in filtering + |
+ Whether the property values of the given value collection matches the filter. | +
filters | +- | +Property to access constraints collection. | +
register | +
+ name: string + fn: Filter callback + |
+ Registers a new constraint in filters. | +
None.
+FilterService is a helper utility to filter collections against constraints.
+A custom equals filter that checks for exact case sensitive value is registered and defined as a match mode of a column filter.
+ +All input text components support floating labels.
+Galleria can be extended further to implement complex requirements.
+
+<Galleria ref="galleria" :value="images" v-model:activeIndex="activeIndex" :numVisible="5" containerStyle="max-width: 640px" :containerClass="galleriaClass"
+ :showThumbnails="showThumbnails" :showItemNavigators="true" :showItemNavigatorsOnHover="true"
+ :circular="true" :autoPlay="true" :transitionInterval="3000">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" :style="[{'width': !fullScreen ? '100%' : '', 'display': !fullScreen ? 'block' : ''}]" />
+ </template>
+ <template #thumbnail="slotProps">
+ <div class="grid grid-nogutter justify-content-center">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" style="display: block;" />
+ </div>
+ </template>
+ <template #footer>
+ <div class="custom-galleria-footer">
+ <Button icon="pi pi-list" @click="onThumbnailButtonClick" />
+ <span v-if="images" class="title-container">
+ <span>{{activeIndex + 1}}/{{images.length}}</span>
+ <span class="title">{{images[activeIndex].title}}</span>
+ <span>{{images[activeIndex].alt}}</span>
+ </span>
+ <Button :icon="fullScreenIcon" @click="toggleFullScreen" class="fullscreen-button" />
+ </div>
+ </template>
+</Galleria>
+
+
+
+
+import PhotoService from '../../service/PhotoService';
+
+export default {
+ data() {
+ return {
+ images: null,
+ activeIndex: 0,
+ showThumbnails: false,
+ fullScreen: false
+ }
+ },
+ galleriaService: null,
+ created() {
+ this.galleriaService = new PhotoService();
+ },
+ mounted() {
+ this.galleriaService.getImages().then(data => this.images = data);
+ this.bindDocumentListeners();
+ },
+ methods: {
+ onThumbnailButtonClick() {
+ this.showThumbnails = !this.showThumbnails;
+ },
+ toggleFullScreen() {
+ if (this.fullScreen) {
+ this.closeFullScreen();
+ }
+ else {
+ this.openFullScreen();
+ }
+ },
+ onFullScreenChange() {
+ this.fullScreen = !this.fullScreen;
+ },
+ openFullScreen() {
+ let elem = this.$refs.galleria.$el;
+ if (elem.requestFullscreen) {
+ elem.requestFullscreen();
+ }
+ else if (elem.mozRequestFullScreen) { /* Firefox */
+ elem.mozRequestFullScreen();
+ }
+ else if (elem.webkitRequestFullscreen) { /* Chrome, Safari & Opera */
+ elem.webkitRequestFullscreen();
+ }
+ else if (elem.msRequestFullscreen) { /* IE/Edge */
+ elem.msRequestFullscreen();
+ }
+ },
+ closeFullScreen() {
+ if (document.exitFullscreen) {
+ document.exitFullscreen();
+ }
+ else if (document.mozCancelFullScreen) {
+ document.mozCancelFullScreen();
+ }
+ else if (document.webkitExitFullscreen) {
+ document.webkitExitFullscreen();
+ }
+ else if (document.msExitFullscreen) {
+ document.msExitFullscreen();
+ }
+ },
+ bindDocumentListeners() {
+ document.addEventListener("fullscreenchange", this.onFullScreenChange);
+ document.addEventListener("mozfullscreenchange", this.onFullScreenChange);
+ document.addEventListener("webkitfullscreenchange", this.onFullScreenChange);
+ document.addEventListener("msfullscreenchange", this.onFullScreenChange);
+ },
+ unbindDocumentListeners() {
+ document.removeEventListener("fullscreenchange", this.onFullScreenChange);
+ document.removeEventListener("mozfullscreenchange", this.onFullScreenChange);
+ document.removeEventListener("webkitfullscreenchange", this.onFullScreenChange);
+ document.removeEventListener("msfullscreenchange", this.onFullScreenChange);
+ }
+ },
+ computed: {
+ galleriaClass() {
+ return ['custom-galleria', {'fullscreen': this.fullScreen}];
+ },
+ fullScreenIcon() {
+ return `pi ${this.fullScreen ? 'pi-window-minimize' : 'pi-window-maximize'}`;
+ }
+ }
+}
+
+
+
+
+::v-deep(.custom-galleria) {
+ &.fullscreen {
+ display: flex;
+ flex-direction: column;
+
+ .p-galleria-content {
+ flex-grow: 1;
+ justify-content: center;
+ }
+ }
+
+ .p-galleria-content {
+ position: relative;
+ }
+
+ .p-galleria-thumbnail-wrapper {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ }
+
+ .p-galleria-thumbnail-items-container {
+ width: 100%;
+ }
+
+ .custom-galleria-footer {
+ display: flex;
+ align-items: center;
+ background-color: rgba(0, 0, 0, .9);
+ color: #ffffff;
+
+ > button {
+ background-color: transparent;
+ color: #ffffff;
+ border: 0 none;
+ border-radius: 0;
+ margin: .2rem 0;
+
+ &.fullscreen-button {
+ margin-left: auto;
+ }
+
+ &:hover {
+ background-color: rgba(255, 255, 255, 0.1);
+ }
+ }
+ }
+
+ .title-container {
+ > span {
+ font-size: .9rem;
+ padding-left: .829rem;
+
+ &.title {
+ font-weight: bold;
+ }
+ }
+ }
+}
+
+
+ AutoPlay mode is used to implement slideshows.
+
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px"
+ :circular="true" :autoPlay="true" :transitionInterval="2000">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" style="display: block;" />
+ </template>
+</Galleria>
+
+
+
+
+import PhotoService from '../../service/PhotoService';
+
+export default {
+ data() {
+ return {
+ images: null,
+ responsiveOptions: [
+ {
+ breakpoint: '1024px',
+ numVisible: 5
+ },
+ {
+ breakpoint: '768px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+ ]
+ }
+ },
+ galleriaService: null,
+ created() {
+ this.galleriaService = new PhotoService();
+ },
+ mounted() {
+ this.galleriaService.getImages().then(data => this.images = data);
+ }
+}
+
+
+ Caption displays a description for an item.
+{{ item.alt }}
+ +
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px">
+ <template #item="{item}">
+ <img :src="item.itemImageSrc" :alt="item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="{item}">
+ <div class="grid grid-nogutter justify-content-center">
+ <img :src="item.thumbnailImageSrc" :alt="item.alt" style="display: block;" />
+ </div>
+ </template>
+ <template #caption="{item}">
+ <h4 style="margin-bottom: .5rem;">{{item.title}}</h4>
+ <p>{{item.alt}}</p>
+ </template>
+</Galleria>
+
+
+
+
+import PhotoService from '../../service/PhotoService';
+
+export default {
+ data() {
+ return {
+ images: null,
+ responsiveOptions: [
+ {
+ breakpoint: '1024px',
+ numVisible: 5
+ },
+ {
+ breakpoint: '768px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+ ]
+ }
+ },
+ galleriaService: null,
+ created() {
+ this.galleriaService = new PhotoService();
+ },
+ mounted() {
+ this.galleriaService.getImages().then(data => this.images = data);
+ }
+}
+
+
+ Galleria is an advanced content gallery component.
+
+import Galleria from 'primevue/galleria';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/galleria/galleria.min.js"></script>
+
+
+
+ Galleria requires item template and a value as an array of objects.
+
+<Galleria :value="images">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" />
+ </template>
+</Galleria>
+
+
+
+ For the rest of the documentation, sample data below would be return from an example service e.g. PhotoService.
+
+{
+ "data":[
+ {
+ "itemImageSrc": "demo/images/galleria/galleria1.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria1s.jpg",
+ "alt": "Description for Image 1",
+ "title": "Title 1"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria2.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria2s.jpg",
+ "alt": "Description for Image 2",
+ "title": "Title 2"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria3.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria3s.jpg",
+ "alt": "Description for Image 3",
+ "title": "Title 3"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria4.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria4s.jpg",
+ "alt": "Description for Image 4",
+ "title": "Title 4"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria5.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria5s.jpg",
+ "alt": "Description for Image 5",
+ "title": "Title 5"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria6.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria6s.jpg",
+ "alt": "Description for Image 6",
+ "title": "Title 6"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria7.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria7s.jpg",
+ "alt": "Description for Image 7",
+ "title": "Title 7"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria8.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria8s.jpg",
+ "alt": "Description for Image 8",
+ "title": "Title 8"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria9.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria9s.jpg",
+ "alt": "Description for Image 9",
+ "title": "Title 9"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria10.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria10s.jpg",
+ "alt": "Description for Image 10",
+ "title": "Title 10"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria11.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria11s.jpg",
+ "alt": "Description for Image 11",
+ "title": "Title 11"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria12.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria12s.jpg",
+ "alt": "Description for Image 12",
+ "title": "Title 12"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria13.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria13s.jpg",
+ "alt": "Description for Image 13",
+ "title": "Title 13"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria14.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria14s.jpg",
+ "alt": "Description for Image 14",
+ "title": "Title 14"
+ },
+ {
+ "itemImageSrc": "demo/images/galleria/galleria15.jpg",
+ "thumbnailImageSrc": "demo/images/galleria/galleria15s.jpg",
+ "alt": "Description for Image 15",
+ "title": "Title 15"
+ }
+ ]
+}
+
+
+
+export default class PhotoService {
+
+ getImages() {
+ return fetch('demo/data/photos.json').then(res => res.json())
+ .then(d => d.data);
+ }
+}
+
+
+
+
+export default {
+ data() {
+ return {
+ images: null
+ }
+ },
+ galleriaService: null,
+ created() {
+ this.galleriaService = new PhotoService();
+ },
+ mounted() {
+ this.galleriaService.getImages().then(data => this.images = data);
+ }
+}
+
+
+
+ Number of items per page is defined using the numVisible property.
+ +
+<Galleria :value="images" :numVisible="5">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" />
+ </template>
+</Galleria>
+
+
+
+ For responsive design, numVisible can be defined using the responsiveOptions property which references an array of objects whose breakpoint defines the max-width to apply the settings.
+ +
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" />
+ </template>
+</Galleria>
+
+
+
+
+responsiveOptions: [
+ {
+ breakpoint: '1024px',
+ numVisible: 5
+ },
+ {
+ breakpoint: '768px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+]
+
+
+
+ Custom content projection is available using the header and footer properties.
+
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px">
+ <template #header>
+ <h1>Header</h1>
+ </template>
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%" />
+ </template>
+ <template #footer>
+ <h1>Footer</h1>
+ </template>
+</Galleria>
+
+
+
+ + Indicators allow quick navigation between the items. Set showIndicators to display indicators which can be customized further with the changeItemOnIndicatorHover, showIndicatorsOnItem and + indicatorsPosition properties. +
+
+<Galleria :value="images" :showIndicators="true">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" />
+ </template>
+</Galleria>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
id | +string | +null | +Unique identifier of the element. | +
value | +array | +null | +An array of objects to display. | +
activeIndex | +number | +0 | +Index of the first item. | +
fullScreen | +boolean | +false | +Whether to display the component on fullscreen. | +
visible | +boolean | +false | +Specifies the visibility of the mask on fullscreen mode. | +
numVisible | +number | +3 | +Number of items per page. | +
responsiveOptions | +any | +null | +An array of options for responsive design. | +
showItemNavigators | +boolean | +false | +Whether to display navigation buttons in item section. | +
showThumbnailNavigators | +boolean | +true | +Whether to display navigation buttons in thumbnail container. | +
showItemNavigatorsOnHover | +boolean | +false | +Whether to display navigation buttons on item hover. | +
changeItemOnIndicatorHover | +boolean | +false | +When enabled, item is changed on indicator hover. | +
circular | +boolean | +false | +Defines if scrolling would be infinite. | +
autoPlay | +boolean | +false | +Items are displayed with a slideshow in autoPlay mode. | +
transitionInterval | +number | +4000 | +Time in milliseconds to scroll items. | +
showThumbnails | +boolean | +true | +Whether to display thumbnail container. | +
thumbnailsPosition | +string | +bottom | +Position of thumbnails. Valid values are "bottom", "top", "left" and "right". | +
verticalThumbnailViewPortHeight | +string | +300px | +Height of the viewport in vertical thumbnail. | +
showIndicators | +boolean | +false | +Whether to display indicator container. | +
showIndicatorsOnItem | +boolean | +false | +When enabled, indicator container is displayed on item container. | +
indicatorsPosition | +string | +bottom | +Position of indicators. Valid values are "bottom", "top", "left" and "right". | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
maskClass | +string | +null | +Style class of the mask on fullscreen mode. | +
containerStyle | +any | +null | +Inline style of the component on fullscreen mode. Otherwise, the 'style' property can be used. | +
containerClass | +any | +null | +Style class of the component on fullscreen mode. Otherwise, the 'class' property can be used. | +
Name | +Parameters | +
---|---|
header | +- | +
footer | +- | +
item | +item: Item instance | +
caption | +item: Item instance | +
thumbnail | +item: Item instance | +
indicator | +index: Index of the indicator item | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-galleria | +Container element. | +
p-galleria-header | +Header section. | +
p-galleria-footer | +Footer section. | +
p-galleria-item-wrapper | +Item wrapper element. It contains item container and indicators. | +
p-galleria-item-container | +Container of the item wrapper. It contains navigation buttons, items and caption content. | +
p-galleria-indicators | +Container of the indicators. It contains indicator items. | +
p-galleria-thumbnail-content | +Thumbnail content element. | +
p-galleria-thumbnail-container | +Container of the thumbnail content. It contains navigation buttons and thumbnail items. | +
p-galleria-caption | +Content of the item caption. | +
None.
+
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" />
+ </template>
+</Galleria>
+
+
+
+
+import PhotoService from '../../service/PhotoService';
+
+export default {
+ data() {
+ return {
+ images: null,
+ responsiveOptions: [
+ {
+ breakpoint: '1024px',
+ numVisible: 5
+ },
+ {
+ breakpoint: '768px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+ ]
+ }
+ },
+ galleriaService: null,
+ created() {
+ this.galleriaService = new PhotoService();
+ },
+ mounted() {
+ this.galleriaService.getImages().then(data => this.images = data);
+ }
+}
+
+
+ In fullscreen mode content covers the whole page over a mask..
+
+<h3>With Thumbnails</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions2" :numVisible="9" containerStyle="max-width: 50%"
+ :circular="true" :fullScreen="true" :showItemNavigators="true" v-model:visible="displayBasic">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" style="display: block;" />
+ </template>
+</Galleria>
+
+<Button label="Show" icon="pi pi-external-link" @click="displayBasic = true" />
+
+<h3>Without Thumbnails</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="7" containerStyle="max-width: 850px"
+ :circular="true" :fullScreen="true" :showItemNavigators="true" :showThumbnails="false" v-model:visible="displayBasic2">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" style="display: block;" />
+ </template>
+</Galleria>
+
+<Button label="Show" icon="pi pi-external-link" @click="displayBasic2 = true" />
+
+<h3>Custom Content</h3>
+<Galleria :value="images" v-model:activeIndex="activeIndex" :responsiveOptions="responsiveOptions" :numVisible="7" containerStyle="max-width: 850px"
+ :circular="true" :fullScreen="true" :showItemNavigators="true" :showThumbnails="false" v-model:visible="displayCustom">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" style="display: block;" />
+ </template>
+</Galleria>
+
+<div v-if="images" class="grid" style="max-width: 400px;">
+ <div v-for="(image, index) of images" class="col-3" :key="index">
+ <img :src="image.thumbnailImageSrc" :alt="image.alt" style="cursor: pointer" @click="imageClick(index)"/>
+ </div>
+</div>
+
+
+
+
+import PhotoService from '../../service/PhotoService';
+
+export default {
+ data() {
+ return {
+ images: null,
+ activeIndex: 0,
+ responsiveOptions: [
+ {
+ breakpoint: '1024px',
+ numVisible: 5
+ },
+ {
+ breakpoint: '768px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+ ],
+ responsiveOptions2: [
+ {
+ breakpoint: '1500px',
+ numVisible: 5
+ },
+ {
+ breakpoint: '1024px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '768px',
+ numVisible: 2
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+ ],
+ displayBasic: false,
+ displayBasic2: false,
+ displayCustom: false
+ }
+ },
+ galleriaService: null,
+ created() {
+ this.galleriaService = new PhotoService();
+ },
+ mounted() {
+ this.galleriaService.getImages().then(data => this.images = data);
+ },
+ methods: {
+ imageClick(index) {
+ this.activeIndex = index;
+ this.displayCustom = true;
+ }
+ }
+}
+
+
+ Indicators allow quick navigation between the items.
+
+<h3>Indicators with Click Event</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px"
+ :showThumbnails="false" :showIndicators="true">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+</Galleria>
+
+<h3>Indicators with Hover Event</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px"
+ :showThumbnails="false" :showIndicators="true" :changeItemOnIndicatorHover="true">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+</Galleria>
+
+<h3>Inside Content</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px"
+ :showThumbnails="false" :showIndicators="true" :changeItemOnIndicatorHover="true" :showIndicatorsOnItem="true">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+</Galleria>
+
+<h3>Positioned at Top</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px"
+ :showThumbnails="false" :showIndicators="true" :changeItemOnIndicatorHover="true" :showIndicatorsOnItem="true" indicatorsPosition="top">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+</Galleria>
+
+<h3>Positioned at Left</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px"
+ :showThumbnails="false" :showIndicators="true" :changeItemOnIndicatorHover="true" :showIndicatorsOnItem="true" indicatorsPosition="left">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+</Galleria>
+
+<h3>Positioned at Right</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px"
+ :showThumbnails="false" :showIndicators="true" :changeItemOnIndicatorHover="true" :showIndicatorsOnItem="true" indicatorsPosition="right">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+</Galleria>
+
+<h3>Indicator Template</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px" class="custom-indicator-galleria"
+ :showThumbnails="false" :showIndicators="true" :changeItemOnIndicatorHover="true" :showIndicatorsOnItem="true" indicatorsPosition="left">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #indicator="{index}">
+ <span style="color: #e9ecef; cursor: pointer">
+ {{index + 1}}
+ </span>
+ </template>
+</Galleria>
+
+
+
+
+import PhotoService from '../../service/PhotoService';
+
+export default {
+ data() {
+ return {
+ images: null,
+ images2: null,
+ responsiveOptions: [
+ {
+ breakpoint: '1024px',
+ numVisible: 5
+ },
+ {
+ breakpoint: '768px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+ ]
+ }
+ },
+ galleriaService: null,
+ created() {
+ this.galleriaService = new PhotoService();
+ },
+ mounted() {
+ this.galleriaService.getImages().then(data => {
+ this.images = data;
+ this.images2 = data.slice(0, 5);
+ });
+ }
+}
+
+
+
+
+::v-deep(.custom-indicator-galleria) {
+ .indicator-text {
+ color: #e9ecef;
+ cursor: pointer;
+ }
+
+ .p-highlight {
+ .indicator-text {
+ color: var(--primary-color);
+ }
+ }
+}
+
+
+ Combining item navigators, thumbnails and indicators provide various UI alternatives.
+
+<h3>Item Navigators and Thumbnails</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" :circular="true" containerStyle="max-width: 640px"
+ :showItemNavigators="true">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" style="display: block;" />
+ </template>
+</Galleria>
+
+<h3>Item Navigators without Thumbnails</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" :circular="true" containerStyle="max-width: 640px"
+ :showItemNavigators="true" :showThumbnails="false">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" style="display: block;" />
+ </template>
+</Galleria>
+
+<h3>Item Navigators on Hover</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" :circular="true" containerStyle="max-width: 640px"
+ :showItemNavigators="true" :showItemNavigatorsOnHover="true">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" style="display: block;" />
+ </template>
+</Galleria>
+
+<h3>Item Navigators and Indicators</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" :circular="true" containerStyle="max-width: 640px"
+ :showItemNavigators="true" :showThumbnails="false" :showItemNavigatorsOnHover="true" :showIndicators="true">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" style="display: block;" />
+ </template>
+</Galleria>
+
+
+
+
+import PhotoService from '../../service/PhotoService';
+
+export default {
+ data() {
+ return {
+ images: null,
+ responsiveOptions: [
+ {
+ breakpoint: '1024px',
+ numVisible: 5
+ },
+ {
+ breakpoint: '768px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+ ]
+ }
+ },
+ galleriaService: null,
+ created() {
+ this.galleriaService = new PhotoService();
+ },
+ mounted() {
+ this.galleriaService.getImages().then(data => this.images = data);
+ }
+}
+
+
+ Galleria can be controlled programmatically using the activeIndex property.
+
+<div style="padding: .5rem 0">
+ <Button icon="pi pi-minus" @click="prev" class="p-button-secondary" />
+ <Button icon="pi pi-plus" @click="next" class="p-button-secondary" style="margin-left: .5rem" />
+</div>
+
+<Galleria :value="images" v-model:activeIndex="activeIndex" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" />
+ </template>
+</Galleria>
+
+
+
+
+import PhotoService from '../../service/PhotoService';
+
+export default {
+ data() {
+ return {
+ images: null,
+ activeIndex: 2,
+ responsiveOptions: [
+ {
+ breakpoint: '1024px',
+ numVisible: 5
+ },
+ {
+ breakpoint: '768px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+ ]
+ }
+ },
+ galleriaService: null,
+ created() {
+ this.galleriaService = new PhotoService();
+ },
+ mounted() {
+ this.galleriaService.getImages().then(data => this.images = data);
+ },
+ methods: {
+ next() {
+ this.activeIndex = (this.activeIndex === this.images.length - 1) ? 0 : this.activeIndex + 1;
+ },
+ prev() {
+ this.activeIndex = (this.activeIndex === 0) ? 0 : this.images.length - 1;
+ }
+ }
+}
+
+
+ Galleria responsiveness is defined with the responsiveOptions property.
+
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="7" :circular="true" style="max-width: 800px">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" style="display: block;" />
+ </template>
+</Galleria>
+
+
+
+
+import PhotoService from '../../service/PhotoService';
+
+export default {
+ data() {
+ return {
+ images: null,
+ responsiveOptions: [
+ {
+ breakpoint: '1024px',
+ numVisible: 5
+ },
+ {
+ breakpoint: '960px',
+ numVisible: 4
+ },
+ {
+ breakpoint: '768px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+ ]
+ }
+ },
+ galleriaService: null,
+ created() {
+ this.galleriaService = new PhotoService();
+ },
+ mounted() {
+ this.galleriaService.getImages().then(data => this.images = data);
+ }
+}
+
+
+ Thumbnails represent a smaller version of the actual content.
+
+<h3>Positioned at Bottom</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" containerStyle="max-width: 640px">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" tyle="width: 100%; display: block;" />
+ </template>
+</Galleria>
+
+<h3>Positioned at Left</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions2" :numVisible="4" thumbnailsPosition="left" containerStyle="max-width: 640px">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <div class="grid grid-nogutter justify-content-center">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" tyle="width: 100%; display: block;" />
+ </div>
+ </template>
+</Galleria>
+
+<h3>Positioned at Right</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions2" :numVisible="4" thumbnailsPosition="right" containerStyle="max-width: 640px">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <div class="grid grid-nogutter justify-content-center">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" tyle="width: 100%; display: block;" />
+ </div>
+ </template>
+</Galleria>
+
+<h3>Positioned at Top</h3>
+<Galleria :value="images" :responsiveOptions="responsiveOptions" :numVisible="5" thumbnailsPosition="top" containerStyle="max-width: 640px">
+ <template #item="slotProps">
+ <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="width: 100%; display: block;" />
+ </template>
+ <template #thumbnail="slotProps">
+ <img :src="slotProps.item.thumbnailImageSrc" :alt="slotProps.item.alt" tyle="width: 100%; display: block;" />
+ </template>
+</Galleria>
+
+
+
+
+import PhotoService from '../../service/PhotoService';
+
+export default {
+ data() {
+ return {
+ images: null,
+ responsiveOptions: [
+ {
+ breakpoint: '1024px',
+ numVisible: 5
+ },
+ {
+ breakpoint: '768px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+ ],
+ responsiveOptions2: [
+ {
+ breakpoint: '768px',
+ numVisible: 3
+ },
+ {
+ breakpoint: '560px',
+ numVisible: 1
+ }
+ ]
+ }
+ },
+ galleriaService: null,
+ created() {
+ this.galleriaService = new PhotoService();
+ },
+ mounted() {
+ this.galleriaService.getImages().then(data => this.images = data);
+ }
+}
+
+
+ PrimeVue components internally use PrimeIcons library, the official icons suite from PrimeTek.
+ +PrimeIcons is available at npm, run the following command to download it to your project.
+ +
+npm install primeicons --save
+
+
+
+ Then import the library.
+ +
+import 'primeicons/primeicons.css';
+
+
+
+ PrimeIcons use the pi pi-{icon} syntax such as pi pi-check. A standalone icon can be displayed using an element like i or span
+ +
+<i class="pi pi-check"></i>
+<i class="pi pi-times"></i>
+
+
+
+
+
+
+ Size of the icons can easily be changed using font-size property.
+ +
+<i class="pi pi-check"></i>
+
+
+
+
+
+
+<i class="pi pi-check" style="font-size: 2rem"></i>
+
+
+
+
+
+ Special pi-spin class applies continuous rotation to an icon.
+
+<i class="pi pi-spin pi-spinner" style="font-size: 2rem"></i>
+
+
+
+
+
+ PrimeIcons constants API is provided to easily choose an icon with typescript e.g. when defining a menu model.
+
+<Menu :model="items" />
+
+
+
+
+import {PrimeIcons} from 'primevue/api';
+
+export default {
+ data() {
+ return {
+ items: [
+ {
+ label: 'Update',
+ icon: PrimeIcons.REFRESH,
+ to: '/update'
+ },
+ {
+ label: 'Delete',
+ icon: PrimeIcons.TIMES,
+ to: '/delete'
+ }
+ ]
+ }
+ }
+}
+
+
+
+ Here is the current list of PrimeIcons, more icons are added periodically. You may also request new icons at the issue tracker.
+ +
+import Image from 'primevue/image';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/image/image.min.js"></script>
+
+
+
+ Image is used as the native img element and supports all properties that the native element has.
+
+<Image src="image1.png" alt="Image Text" />
+
+
+
+ Preview mode displays a modal layer when the image is clicked that provides transformation options such as rotating and zooming.
+ +An eye icon is displayed by default when the image is hovered in preview mode. Use the indicator template for custom content.
+
+<Image src="image1.png" alt="Image Text">
+ <template #indicator>
+ Preview Content
+ </template>
+</Image>
+
+
+
+ Image passes any valid attribute to the underlying img element, additional attribute is the following.
+Name | +Type | +Default | +Description | +
---|---|---|---|
preview | +boolean | +false | +Controls the preview functionality. | +
imageStyle | +any | +null | +Inline style of the image element. | +
imageClass | +string | +null | +Style class of the image element. | +
Any valid event like click and mouseover are passed to the underlying input element. Events below are the additional ones related to the preview functionality.
+Name | +Parameters | +Description | +
---|---|---|
show | +- | +Triggered when the preview overlay is shown. | +
hide | +- | +Triggered when the preview overlay is hidden. | +
error | +- | +Triggered when an error occurs while loading an image file. | +
Name | +Parameters | +
---|---|
indicator | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-image | +Container element. | +
p-image-preview-container | +Container element with preview enabled. | +
p-image-preview-indicator | +Mask layer over the image when hovered. | +
p-image-preview-icon | +Icon of the preview indicator. | +
p-image-mask | +Preview overlay container. | +
p-image-toolbar | +Transformation options container. | +
p-image-action | +An element inside the toolbar. | +
p-image-preview | +Image element inside the preview overlay. | +
None.
+Displays an image with preview and tranformation options. For multiple image, see
+import Inplace from 'primevue/inplace';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/inplace/inplace.min.js"></script>
+
+
+
+ Inplace requires display and content templates to define the content of each state.
+ +
+<Inplace>
+ <template #display>
+ <span class="pi pi-search" style="vertical-align: middle"></span>
+ <span style="margin-left:.5rem; vertical-align: middle">View Picture</span>
+ </template>
+ <template #content>
+ <img src="demo/images/nature/nature1.jpg" />
+ </template>
+</Inplace>
+
+
+
+ closable property is handy within forms as it enables to switch back to output mode after editing is completed using a button displayed next to the form field.
+
+<Inplace :closable="true">
+ <template #display>
+ {{text || 'Click to Edit'}}
+ </template>
+ <template #content>
+ <InputText v-model="text" autoFocus />
+ </template>
+</Inplace>
+
+
+
+ Inplace allows lazy loading content so that the content gets initialized after getting opened instead of on load. Here is an example that loads, data of a table if the user decides to open the inplace.
+
+<Inplace @open="loadData">
+ <template #display>
+ View Data
+ </template>
+ <template #content>
+ <DataTable :value="cars">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+ </DataTable>
+ </template>
+</Inplace>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ cars: null
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ methods: {
+ loadData() {
+ this.carService.getCarsSmall().then(data => this.cars = data);
+ }
+ }
+}
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
active | +boolean | +false | +Whether the content is displayed or not. | +
closable | +boolean | +false | +Displays a button to switch back to display mode. | +
disabled | +boolean | +false | +When present, it specifies that the element should be disabled. | +
Name | +Parameters | +Description | +
---|---|---|
open | +event: browser event | +Callback to invoke when inplace is opened. | +
close | +event: browser event | +Callback to invoke when inplace is closed. | +
Name | +Parameters | +
---|---|
display | +- | +
content | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-inplace | +Container element | +
p-inplace-display | +Display container | +
p-inplace-content | +Content container | +
None.
+Inplace provides an easy to do editing and display at the same time where clicking the output displays the actual content.
+Text, icon, buttons and other content can be grouped next to an input.
+
+import InputMask from 'primevue/inputmask';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/inputmask/inputmask.min.js"></script>
+
+
+
+ A model can be bound using the standard v-model directive.
+
+<InputMask v-model="value" mask="99-999999" />
+
+
+
+ Mask format can be a combination of the the following built-in definitions.
+ +
+<InputMask v-model="value" mask="a*-999-a999" />
+
+
+
+ Underscore is the default placeholder for a mask and this can be customized using slotChart option.
+
+<InputMask v-model="value" mask="99/99/9999" slotChar="mm/dd/yyyy" />
+
+
+ + If the input does not complete the mask definition, it is cleared by default. Use autoClear property to control this behavior. In addition, certain part of a mask can be made optional by using ? symbol where anything after the + question mark becomes optional. +
+
+<InputMask v-model="value" mask="(999) 999-9999? x99999" />
+
+
+
+ InputText passes any valid attribute to the underlying input element. In addition;
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
mask | +string | +null | +Mask pattern. | +
slotChar | +string | +_ | +Placeholder character in mask, default is underscore. | +
autoClear | +boolean | +true | +Clears the incomplete value on blur. | +
unmask | +boolean | +false | +Defines if model sets the raw unmasked value to bound value or the formatted mask value. | +
Any valid event such as focus, blur and input are passed to the underlying input element.
+ +Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-inputmask p-inputtext | +Input element | +
+ InputMask component renders a native input element that implicitly includes any passed prop. Value to describe the component can either be provided via label tag combined with id prop or using aria-labelledby, + aria-label props. +
+ +
+<label for="date">Date</label>
+<InputMask id="date" />
+
+<span id="phone">Phone</span>
+<InputMask aria-labelledby="phone" />
+
+<InputMask aria-label="Age" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the input. | +
None.
+InputMask component is used to enter input in a certain format such as numeric, date, currency, email and phone.
+
+import InputNumber from 'primevue/inputnumber';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ InputNumber is used with the standard v-model directive. Component always provides a number type although formatting on the input is a string.
+ +
+<InputNumber v-model="value" />
+
+
+
+ Format is defined using the mode property, "decimal" is the default value allowing only integers when there is no other configuration.
+
+<InputNumber v-model="value" mode="decimal" />
+
+
+
+ Fractions are configured with the minFractionDigits property. Optionally maxFractionDigits can be used to defined a boundary for the maximum digits.
+
+<InputNumber v-model="value1" mode="decimal" :minFractionDigits="2" />
+<InputNumber v-model="value2" mode="decimal" :minFractionDigits="2" :maxFractionDigits="2" />
+
+
+
+ + locale option is available to set the localization information such as grouping and decimal symbols where default value is the browser locale. Locales are defined per + BCP Language Tag. +
+
+User Locale
+<InputNumber v-model="value1" mode="decimal" :minFractionDigits="2" />
+
+United State Locale
+<InputNumber v-model="value2" mode="decimal" locale="en-US" :minFractionDigits="2" />
+
+German Locale
+<InputNumber v-model="value3" mode="decimal" locale="de-DE" :minFractionDigits="2" />
+
+Indian Locale
+<InputNumber v-model="value4" mode="decimal" locale="en-IN" :minFractionDigits="2" />
+
+
+
+ Currency formatting is specified by setting the mode option to currency and currency property. In addition currencyDisplay option allows how the currency is displayed, valid values are "symbol" (default) or "code".
+
+United States
+<InputNumber v-model="value1" mode="currency" currency="USD" locale="en-US" />
+
+Germany
+<InputNumber v-model="value2" mode="currency" currency="EUR" locale="de-DE" />
+
+India
+<InputNumber v-model="value3" mode="currency" currency="INR" currencyDisplay="code" locale="en-IN" />
+
+Japan
+<InputNumber v-model="value4" mode="currency" currency="JPY" locale="jp-JP" />
+
+
+
+ Custom texts e.g. units can be placed before or after the input section with the prefix and suffix properties.
+
+Mile
+<InputNumber v-model="value1" suffix=" mi" />
+
+Percent
+<InputNumber v-model="value2" prefix="%" />
+
+Expiry
+<InputNumber v-model="value3" prefix="Expires in " suffix=" days" />
+
+Temperature
+<InputNumber v-model="value4" prefix="↑ " suffix="℃" :min="0" :max="40" />
+
+
+
+ + Spinner buttons is enabled using the showButtons options and layout is defined with the buttonLayout. Default value is "stacked" whereas "horizontal" and "stacked" are alternatives. Note that even there are no buttons, up + and down arrow keys can be used to spin the values with keyboard. +
+
+Stacked
+<InputNumber v-model="value1" showButtons mode="currency" currency="USD" />
+
+Horizontal
+<InputNumber v-model="value2" showButtons buttonLayout="horizontal"
+ decrementButtonClass="p-button-danger" incrementButtonClass="p-button-success" incrementButtonIcon="pi pi-plus" decrementButtonIcon="pi pi-minus" mode="currency" currency="EUR" />
+
+Vertical
+<InputNumber v-model="value3" mode="decimal" showButtons buttonLayout="vertical"
+ decrementButtonClass="p-button-secondary" incrementButtonClass="p-button-secondary" incrementButtonIcon="pi pi-plus" decrementButtonIcon="pi pi-minus" />
+
+
+
+ Step factor is 1 by default and can be customized with step option.
+
+<InputNumber v-model="value" :step="0.25" />
+
+
+
+ Value to be entered can be restricted by configuring the min and max options.
+
+<InputNumber v-model="value" :min="0" :max="100" />
+
+
+
+ InputNumber passes any valid attribute to the underlying input element.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +number | +null | +Value of the component. | +
format | +boolean | +true | +Whether to format the value. | +
showButtons | +boolean | +false | +Displays spinner buttons. | +
buttonLayout | +string | +stacked | +Layout of the buttons, valid values are "stacked" (default), "horizontal" and "vertical". | +
incrementButtonClass | +string | +null | +Style class of the increment button. | +
decrementButtonClass | +string | +null | +Style class of the decrement button. | +
incrementButtonIcon | +string | +pi pi-angle-up | +Style class of the increment button. | +
decrementButtonIcon | +string | +pi pi-angle-down | +Style class of the decrement button. | +
locale | +string | +null | +Locale to be used in formatting. | +
localeMatcher | +string | +best fit | ++ The locale matching algorithm to use. Possible values are "lookup" and "best fit"; the default is "best fit". See + Locale Negotation for details. + | +
mode | +string | +decimal | +Defines the behavior of the component, valid values are "decimal" and "currency". | +
prefix | +string | +null | +Text to display before the value. | +
suffix | +string | +decimal | +Text to display after the value. | +
currency | +string | +null | ++ The currency to use in currency formatting. Possible values are the ISO 4217 currency codes, such as "USD" for the US dollar, "EUR" for the euro, or + "CNY" for the Chinese RMB. There is no default value; if the style is "currency", the currency property must be provided. + | +
currencyDisplay | +string | +symbol | ++ How to display the currency in currency formatting. Possible values are "symbol" to use a localized currency symbol such as €, "code" to use the ISO currency code, "name" to use a localized currency name such as "dollar"; + the default is "symbol". + | +
useGrouping | +boolean | +true | +Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators. | +
minFractionDigits | +number | +null | ++ The minimum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number and percent formatting is 0; the default for currency formatting is the number of minor unit digits provided by + the ISO 4217 currency code list (2 if the list doesn't provide that information). + | +
maxFractionDigits | +number | +null | ++ The maximum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number formatting is the larger of minimumFractionDigits and 3; the default for currency formatting is the larger of + minimumFractionDigits and the number of minor unit digits provided by the ISO 4217 currency code list (2 if the list doesn't provide that + information). + | +
min | +number | +null | +Mininum boundary value. | +
max | +number | +null | +Maximum boundary value. | +
step | +number | +1 | +Step factor to increment/decrement the value. | +
allowEmpty | +boolean | +true | +Determines whether the input field is empty. | +
disabled | +boolean | +false | +When present, it specifies that the element should be disabled. | +
readonly | +boolean | +false | +When present, it specifies that an input field is read-only. | +
placeholder | +string | +null | +Placeholder text for the input. | +
inputId | +string | +null | +Style class of the component input field. | +
inputStyle | +any | +null | +Inline style of the input field. | +
inputClass | +string | +null | +Style class of the input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component. | +
incrementButtonProps | +object | +null | +Uses to pass all properties of the HTMLButtonElement to increment button inside the component. | +
decrementButtonProps | +object | +null | +Uses to pass all properties of the HTMLButtonElement to decrement button inside the component. | +
Name | +Parameters | +Description | +
---|---|---|
getFormatter | +- | +Returns Intl.NumberFormat object. | +
Any valid event such as focus and blur are passed to the underlying input element. Following are the additional events to configure the component.
+Name | +Parameters | +Description | +
---|---|---|
input | +
+ event.originalEvent: Browser event + event.value: New value + |
+ Callback to invoke when the value is entered. | +
focus | +event: Focus event | +Callback to invoke on focus of input field. | +
blur | +
+ event.originalEvent: Blur event + event.value: Input value + |
+ Callback to invoke on blur of input field. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-inputnumber | +Container element | +
p-inputnumber-stacked | +Container element with stacked buttons. | +
p-inputnumber-horizontal | +Container element with horizontal buttons. | +
p-inputnumber-vertical | +Container element with vertical buttons. | +
p-inputnumber-input | +Input element | +
p-inputnumber-button | +Input element | +
p-inputnumber-button-up | +Increment button | +
p-inputnumber-button-down | +Decrement button | +
p-inputnumber-button-icon | +Button icon | +
+ Value to describe the component can either be provided via label tag combined with inputId prop or using aria-labelledby, aria-label props. The input element uses spinbutton role in addition to the + aria-valuemin, aria-valuemax and aria-valuenow attributes. +
+ +
+<label for="price">Price</label>
+<InputNumber inputId="price" />
+
+<span id="label_number">Number</span>
+<InputNumber aria-labelledby="label_number" />
+
+<InputNumber aria-label="Number" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the input. | +
up arrow | +Increments the value. | +
down arrow | +Decrements the value. | +
home | +Set the minimum value if provided. | +
end | +Set the maximum value if provided. | +
None.
+InputNumber is an input component to provide numerical input.
+
+import InputSwitch from 'primevue/inputswitch';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/inputswitch/inputswitch.min.js"></script>
+
+
+
+ Two-way binding to a boolean property is defined using the standard v-model directive.
+
+<InputSwitch v-model="checked" />
+
+
+
+
+export default {
+ data() {
+ return {
+ checked: false
+ }
+ }
+}
+
+
+
+ As model is two-way binding enabled, setting the bound value as true displays the state as checked by default.
+ +
+export default {
+ data() {
+ return {
+ checked: true
+ }
+ }
+}
+
+
+
+ Any valid attribute is passed to the root element implicitly, extended properties are as follows;
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +boolean | +null | +Specifies whether a inputswitch should be checked or not. | +
trueValue | +any | +null | +Value in checked state. | +
falseValue | +any | +null | +Value in unchecked state. | +
inputId | +string | +null | +Style class of the component input field. | +
inputClass | +string | +null | +Style class of the input field. | +
inputStyle | +any | +null | +Inline style of the input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component. | +
In addition to the following events, any other valid events such as focus and blur are passed implicitly.
+Name | +Parameters | +Description | +
---|---|---|
click | +event: Browser event | +Callback to invoke on click. | +
change | +event: Browser event | +Callback to invoke on value change. | +
input | +value: New value | +Callback to invoke on value change. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-inputswitch | +Container element. | +
p-inputswitch-checked | +Container element in active state. | +
p-inputswitch-slider | +Slider element behind the handle. | +
+ InputSwitch component uses a hidden native checkbox element with switch role internally that is only visible to screen readers. Value to describe the component can either be provided via label tag combined with + id prop or using aria-labelledby, aria-label props. +
+ +
+<label for="switch1">Remember Me</label>
+<InputSwitch inputId="switch1" />
+
+<span id="switch2">Remember Me</span>
+<InputSwitch aria-labelledby="switch2" />
+
+<InputSwitch aria-label="Remember Me" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the switch. | +
space | +Toggles the checked state. | +
None.
+InputSwitch is used to select a boolean value.
+
+import InputText from 'primevue/inputtext';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ A model can be bound using the standard v-model directive.
+
+<InputText type="text" v-model="value" />
+
+
+
+ A floating label is implemented by wrapping the input and the label inside a container having .p-float-label style class.
+
+<span class="p-float-label">
+ <InputText id="username" type="text" v-model="value" />
+ <label for="username">Username</label>
+</span>
+
+
+
+ An icon can be integrated within an input field by wrapping the input and the icon with an element having p-input-icon-right and p-input-icon-left classes depending on the icon location.
+
+<span class="p-input-icon-left">
+ <i class="pi pi-search" />
+ <InputText type="text" v-model="value1" placeholder="Search" />
+</span>
+
+<span class="p-input-icon-right">
+ <InputText type="text" v-model="value2" />
+ <i class="pi pi-spin pi-spinner" />
+</span>
+
+<span class="p-input-icon-left p-input-icon-right">
+ <i class="pi pi-search" />
+ <InputText type="text" v-model="value3" />
+ <i class="pi pi-spin pi-spinner" />
+</span>
+
+
+
+
+ 2 more sizes are available in addition to a regular input, for a smaller input add p-inputtext-sm and for a larger one, use p-inputtext-lg. Note that these classes are mainly be used to change the size of a particular field,
+ for global scaling see the
+<InputText type="text" class="p-inputtext-sm" placeholder="Small" />
+<InputText type="text" placeholder="Normal" />
+<InputText type="text" class="p-inputtext-lg" placeholder="Large" />
+
+
+
+ Instead of repeating the scale classes for each input, sizing can also be applied to a group by adding the class to a container element so that descendant inputs share the same style easier.
+
+<div class="p-inputtext-sm">
+ <InputText />
+ <InputNumber />
+ <InputMask />
+</div>
+
+
+
+ + Input fields come in two styles, default is outlined with borders around the field whereas filled alternative adds a background color to the field. Applying p-input-filled to an ancestor of an input enables the filled + style. If you prefer to use filled inputs in the entire application, use a global container such as document body or the application element to apply the style class. +
+ +
+<div class="p-input-filled">
+ <InputText type="text" />
+ <InputText type="text" />
+ <InputText type="text" />
+</div>
+
+
+
+ InputText passes any valid attribute to the underlying input element, additional attribute is the following.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
Any valid event such as focus, blur and input are passed to the underlying input element.
+ +Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-inputtext | +Input element | +
p-inputtext-sm | +Smaller input element | +
p-inputtext-lg | +Larger input element | +
p-inputtext-filled | +Filled input style. | +
+ InputText component renders a native input element that implicitly includes any passed prop. Value to describe the component can either be provided via label tag combined with id prop or using aria-labelledby, + aria-label props. +
+ +
+<label for="firstname">Firstname</label>
+<InputText id="firstname" />
+
+<span id="lastname">Lastname</span>
+<InputText aria-labelledby="lastname" />
+
+<InputText aria-label="Age"/>
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the input. | +
None.
+InputText renders a text field to enter data.
+All form components have an invalid state style to display the validation errors.
+
+import Knob from 'primevue/knob';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/knob/knob.min.js"></script>
+
+
+
+ Knob is an input component and used with the standard v-model directive.
+
+<Knob v-model="value" />
+
+
+
+data() {
+ return {
+ value: 0
+ }
+}
+
+
+
+ Boundaries are configured with the min and max values whose defaults are 0 and 100 respectively.
+
+<Knob v-model="value" :min="-50" :max="10" />
+
+
+
+ Step factor is 1 by default and can be customized with step option.
+
+<Knob v-model="value" :step="10" />
+
+
+
+ + valueColor defines the value color, rangeColor defines the range background and similarly textColor configures the color of the value text. In addition, strokeWidth is used to determine the width of the stroke + of range and value sections. +
+
+<Knob v-model="value" valueColor="SlateGray" rangeColor="MediumTurquoise" />
+
+
+
+ Default size of the Knob is 100 pixels for width and height, use the size property to customize it per your requirements.
+
+<Knob v-model="value" :size="200" />
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +number | +null | +Value of the component. | +
size | +number | +100 | +Size of the component in pixels. | +
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +
readonly | +boolean | +false | +When present, it specifies that the component value cannot be edited. | +
tabindex | +number | +null | +Index of the element in tabbing order. | +
step | +number | +null | +Step factor to increment/decrement the value. | +
min | +number | +0 | +Mininum boundary value. | +
max | +number | +100 | +Maximum boundary value. | +
valueColor | +string | +null | +Background of the value. | +
rangeColor | +string | +null | +Background color of the range. | +
textColor | +number | +null | +Color of the value text. | +
strokeWidth | +number | +14 | +Width of the knob stroke. | +
showValue | +boolean | +true | +Whether the show the value inside the knob. | +
valueTemplate | +string | +{value} | +Template string of the value. | +
Name | +Parameters | +Description | +
---|---|---|
change | +value: New value | +Callback to invoke when the value changes. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-knob | +Container element. | +
p-knob-text | +Text element. | +
p-knob-value | +Value element. | +
p-knob-text | +Text element. | +
+ Knob element component uses slider role in addition to the aria-valuemin, aria-valuemax and aria-valuenow attributes. Value to describe the component can be defined using aria-labelledby and + aria-label props. +
+ +
+<span id="label_number">Number</span>
+<Knob aria-labelledby="label_number" />
+
+<Knob aria-label="Number" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the slider. | +
+ + left arrow + down arrow + + | +Decrements the value. | +
+ + right arrow + up arrow + + | +Increments the value. | +
home | +Set the minimum value. | +
end | +Set the maximum value. | +
page up | +Increments the value by 10 steps. | +
page down | +Decrements the value by 10 steps. | +
None.
+ +PrimeVue Knob has no dependency however implementation is derived and inspired from vue-knob-control component authored by kramer99.
+Knob is a form component to define number inputs with a dial.
+
+import Listbox from 'primevue/listbox';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/listbox/listbox.min.js"></script>
+
+
+
+ Listbox requires a value to bind and a collection of arbitrary objects along with the optionLabel property to specify the label property of the option.
+
+<Listbox v-model="selectedCity" :options="cities" optionLabel="name" />
+
+
+
+
+data() {
+ return {
+ selectedCity: null,
+ cities: [
+ {name: 'New York', code: 'NY'},
+ {name: 'Rome', code: 'RM'},
+ {name: 'London', code: 'LDN'},
+ {name: 'Istanbul', code: 'IST'},
+ {name: 'Paris', code: 'PRS'}
+ ]
+ }
+}
+
+
+
+ + Listbox allows selection of either single or multiple items. In single case, model should be a single object reference whereas in multiple case should be an array. Multiple items can either be selected using metaKey or toggled + individually depending on the value of metaKeySelection property value which is true by default. On touch enabled devices metaKeySelection is turned off automatically. +
+
+<Listbox v-model="selectedCity" :options="cities" optionLabel="name" :multiple="true"/>
+
+
+
+ Options groups are specified with the optionGroupLabel and optionGroupChildren properties.
+
+export default {
+ data() {
+ return {
+ selectedGroupedCity: null,
+ groupedCities: [{
+ label: 'Germany', code: 'DE',
+ items: [
+ {label: 'Berlin', value: 'Berlin'},
+ {label: 'Frankfurt', value: 'Frankfurt'},
+ {label: 'Hamburg', value: 'Hamburg'},
+ {label: 'Munich', value: 'Munich'}
+ ]
+ },
+ {
+ label: 'USA', code: 'US',
+ items: [
+ {label: 'Chicago', value: 'Chicago'},
+ {label: 'Los Angeles', value: 'Los Angeles'},
+ {label: 'New York', value: 'New York'},
+ {label: 'San Francisco', value: 'San Francisco'}
+ ]
+ },
+ {
+ label: 'Japan', code: 'JP',
+ items: [
+ {label: 'Kyoto', value: 'Kyoto'},
+ {label: 'Osaka', value: 'Osaka'},
+ {label: 'Tokyo', value: 'Tokyo'},
+ {label: 'Yokohama', value: 'Yokohama'}
+ ]
+ }]
+ }
+ }
+}
+
+
+
+<Listbox v-model="selectedGroupedCity" :options="groupedCities"
+ optionLabel="label" optionGroupLabel="label" optionGroupChildren="items">
+</Listbox>
+
+
+
+ + Filtering allows searching items in the list using an input field at the header. In order to use filtering, enable filter property. By default, optionLabel is used when searching and filterFields can be used to customize the + fields being utilized. Furthermore, filterMatchMode is available to define the search algorithm. Valid values are "contains" (default), "startsWith" and "endsWith". +
+
+<Listbox v-model="selectedCity" :options="cities" optionLabel="name" :filter="true"/>
+
+
+
+ + Label of an option is used as the display text of an item by default, for custom content support define an option template that gets the option instance as a parameter. In addition optiongroup, header, footer, + emptyfilter and empty slots are provided for further customization. +
+
+<Listbox v-model="selectedCars" :options="cars" :multiple="true" :filter="true" optionLabel="brand" listStyle="max-height:250px" style="width:15em">
+ <template #option="slotProps">
+ <div>
+ <img :alt="slotProps.option.brand" :src="'demo/images/car/' + slotProps.option.brand + '.png'" />
+ <span>{{slotProps.option.brand}}</span>
+ </div>
+ </template>
+</Listbox>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
options | +array | +null | +An array of selectitems to display as the available options. | +
optionLabel | +string | function | +null | +Property name or getter function to use as the label of an option. | +
optionValue | +string | function | +null | +Property name or getter function to use as the value of an option, defaults to the option itself when not defined. | +
optionDisabled | +string | function | +null | +Property name or getter function to use as the disabled flag of an option, defaults to false when not defined. | +
optionGroupLabel | +string | function | +null | +Property name or getter function to use as the label of an option group. | +
optionGroupChildren | +string | function | +null | +Property name or getter function that refers to the children options of option group. | +
listStyle | +string | +null | +Inline style of inner list element. | +
disabled | +boolean | +false | +When specified, disables the component. | +
dataKey | +string | +null | +A property to uniquely identify an option. | +
multiple | +boolean | +false | +When specified, allows selecting multiple values. | +
metaKeySelection | +boolean | +true | ++ Defines how multiple items can be selected, when true metaKey needs to be pressed to select or unselect an item and when set to false selection of each item can be toggled individually. On touch enabled devices, + metaKeySelection is turned off automatically. + | +
filter | +boolean | +false | +When specified, displays a filter input at header. | +
filterPlaceholder | +string | +null | +Placeholder text to show when filter input is empty. | +
filterLocale | +string | +undefined | +Locale to use in filtering. The default locale is the host environment's current locale. | +
filterMatchMode | +string | +contains | +Defines the filtering algorithm to use when searching the options. Valid values are "contains" (default), "startsWith" and "endsWith" | +
filterFields | +array | +null | +Fields used when filtering the options, defaults to optionLabel. | +
filterInputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the filter input inside the component. | +
virtualScrollerOptions | +object | +null | +Whether to use the virtualScroller feature. The properties of |
+
autoOptionFocus | +boolean | +true | +Whether to focus on the first visible or selected element. | +
selectOnFocus | +boolean | +false | +When enabled, the focused option is selected. | +
filterMessage | +string | +{0} results are available | +Text to be displayed in hidden accessible field when filtering returns any results. Defaults to value from PrimeVue locale configuration. | +
selectionMessage | +string | +{0} items selected | +Text to be displayed in hidden accessible field when options are selected. Defaults to value from PrimeVue locale configuration. | +
emptySelectionMessage | +string | +No selected item | +Text to be displayed in hidden accessible field when any option is not selected. Defaults to value from PrimeVue locale configuration. | +
emptyFilterMessage | +string | +No results found | +Text to display when filtering does not return any results. Defaults to value from PrimeVue locale configuration. | +
emptyMessage | +string | +No results found | +Text to display when there are no options available. Defaults to value from PrimeVue locale configuration. | +
tabindex | +number | +0 | +Index of the element in tabbing order. | +
aria-label | +string | +null | +Defines a string value that labels an interactive element. | +
aria-labelledby | +string | +null | +Establishes relationships between the component and label(s) where its value should be one or more element IDs. | +
Name | +Parameters | +Description | +
---|---|---|
change | +
+ event.originalEvent: Original event + event.value: Selected option value + |
+ Callback to invoke on value change. | +
focus | +event | +Callback to invoke when the component receives focus. | +
blur | +event | +Callback to invoke when the component loses focus. | +
filter | +
+ event.originalEvent: Original event + event.value: Filter value + |
+ Callback to invoke on filter input. | +
Name | +Parameters | +
---|---|
option | +
+ option: Option instance + index: Index of the option + |
+
optiongroup | +
+ option: OptionGroup instance + index: Index of the option group + |
+
header | +
+ value: Value of the component + options: Displayed options + |
+
footer | +
+ value: Value of the component + options: Displayed options + |
+
emptyfilter | +- | +
empty | +- | +
content | +
+ items: An array of objects to display for virtualscroller + styleClass: Style class of the component + contentRef: Referance of the content + getItemOptions: Options of the items + |
+
loader | +options: Options of the loader items for virtualscroller | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-listbox | +Main container element. | +
p-listbox-header | +Header element. | +
p-listbox-list-wrapper | +Container of list element. | +
p-listbox-list | +List element. | +
p-listbox-item | +An item in the list element. | +
+ Value to describe the component can be provided aria-labelledby or aria-label props. The list element has a listbox role with the aria-multiselectable attribute that sets to true when multiple selection is + enabled. Each list item has an option role with aria-selected and aria-disabled as their attributes. +
+If filtering is enabled, filterInputProps can be defined to give aria-* props to the input element. Alternatively filterPlaceholder is usually utilized by the screen readers as well.
+
+<span id="lb">Options</span>
+<ListBox aria-labelledby="lb" />
+
+<ListBox aria-label="City" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the first selected option, if there is none then first option receives the focus. | +
up arrow | +Moves focus to the previous option. | +
down arrow | +Moves focus to the next option. | +
enter | +Toggles the selected state of the focused option. | +
space | +Toggles the selected state of the focused option. | +
home | +Moves focus to the first option. | +
end | +Moves focus to the last option. | +
shift + down arrow | +Moves focus to the next option and toggles the selection state. | +
shift + up arrow | +Moves focus to the previous option and toggles the selection state. | +
shift + space | +Selects the items between the most recently selected option and the focused option. | +
control + shift + home | +Selects the focused options and all the options up to the first one. | +
control + shift + end | +Selects the focused options and all the options down to the last one. | +
control + a | +Selects all options. | +
pageUp | +Jumps visual focus to first option. | +
pageDown | +Jumps visual focus to last option. | +
any printable character | +Moves focus to the option whose label starts with the characters being typed. | +
Key | +Function | +
---|---|
down arrow | +Moves focus to the next option, if there is none then visual focus does not change. | +
up arrow | +Moves focus to the previous option, if there is none then visual focus does not change. | +
left arrow | +Removes the visual focus from the current option and moves input cursor to one character left. | +
right arrow | +Removes the visual focus from the current option and moves input cursor to one character right. | +
home | +Moves input cursor at the end, if not then moves focus to the first option. | +
end | +Moves input cursor at the beginning, if not then moves focus to the last option. | +
enter | +Closes the popup and moves focus to the multiselect element. | +
escape | +Closes the popup and moves focus to the multiselect element. | +
tab | +Moves focus to the next focusable element in the component. If there is none, moves focus to next element in page. | +
None.
+Listbox is used to select one or more values from a list of items.
+The Locale API allows setting i18n and l7n options globally for the components.
+ +Locale values are stored in the global configuration that becomes accessible after installing the PrimeVue.
+
+import {createApp} from 'vue';
+import PrimeVue from 'primevue/config';
+const app = createApp(App);
+
+app.use(PrimeVue);
+
+
+
+ Second parameter of the use function can be used to initiate the locale during PrimeVue installation.
+
+app.use(PrimeVue, {
+ locale: {
+ accept: 'Aceptar',
+ reject: 'Rechazar',
+ //...
+ }
+});
+
+
+
+ The locale configuration is reactive so that any changes are instantly reflected in the UI. Suppose you are doing a multi language application and need to change the language dynamically.
+ +
+export default {
+ methods: {
+ changeToSpanish() {
+ this.$primevue.config.locale.accept = 'Aceptar';
+ this.$primevue.config.locale.reject = 'Rechazar';
+ }
+ }
+}
+
+
+
+
+import { defineComponent, onMounted } from "vue";
+import { usePrimeVue } from "primevue/config";
+
+export default defineComponent({
+ setup() {
+ const changeToSpanish = () => {
+ const primevue = usePrimeVue();
+ primevue.config.locale.accept = 'Aceptar';
+ primevue.config.locale.reject = 'Rechazar';
+ }
+
+ onMounted(() => {
+ changeToSpanish();
+ })
+ }
+});
+
+
+
+
+locale: {
+ startsWith: 'Starts with',
+ contains: 'Contains',
+ notContains: 'Not contains',
+ endsWith: 'Ends with',
+ equals: 'Equals',
+ notEquals: 'Not equals',
+ noFilter: 'No Filter',
+ lt: 'Less than',
+ lte: 'Less than or equal to',
+ gt: 'Greater than',
+ gte: 'Greater than or equal to',
+ dateIs: 'Date is',
+ dateIsNot: 'Date is not',
+ dateBefore: 'Date is before',
+ dateAfter: 'Date is after',
+ clear: 'Clear',
+ apply: 'Apply',
+ matchAll: 'Match All',
+ matchAny: 'Match Any',
+ addRule: 'Add Rule',
+ removeRule: 'Remove Rule',
+ accept: 'Yes',
+ reject: 'No',
+ choose: 'Choose',
+ upload: 'Upload',
+ cancel: 'Cancel',
+ dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
+ dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
+ dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"],
+ monthNames: ["January","February","March","April","May","June","July","August","September","October","November","December"],
+ monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
+ chooseYear: 'Choose Year',
+ chooseMonth: 'Choose Month',
+ chooseDate: 'Choose Date',
+ prevDecade: 'Previous Decade',
+ nextDecade: 'Next Decade',
+ prevYear: 'Previous Year',
+ nextYear: 'Next Year',
+ prevMonth: 'Previous Month',
+ nextMonth: 'Next Month',
+ prevHour: 'Previous Hour',
+ nextHour: 'Next Hour',
+ prevMinute: 'Previous Minute',
+ nextMinute: 'Next Minute',
+ prevSecond: 'Previous Second',
+ nextSecond: 'Next Second',
+ am: 'am',
+ pm: 'pm',
+ today: 'Today',
+ weekHeader: 'Wk',
+ firstDayOfWeek: 0,
+ dateFormat: 'mm/dd/yy',
+ weak: 'Weak',
+ medium: 'Medium',
+ strong: 'Strong',
+ passwordPrompt: 'Enter a password',
+ emptyFilterMessage: 'No results found', // @deprecated Use 'emptySearchMessage' option instead.
+ searchMessage: '{0} results are available',
+ selectionMessage: '{0} items selected',
+ emptySelectionMessage: 'No selected item',
+ emptySearchMessage: 'No results found',
+ emptyMessage: 'No available options',
+ aria: {
+ trueLabel: 'True',
+ falseLabel: 'False',
+ nullLabel: 'Not Selected',
+ star: '1 star',
+ stars: '{star} stars',
+ selectAll: 'All items selected',
+ unselectAll: 'All items unselected',
+ close: 'Close',
+ previous: 'Previous',
+ next: 'Next'
+ }
+}
+
+
+ MegaMenu is navigation component that displays submenus together.
+
+import MegaMenu from 'primevue/megamenu';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/megamenu/megamenu.min.js"></script>
+
+
+
+ MegaMenu uses the common MenuModel API to define the items of the model, visit
+<MegaMenu :model="items" />
+
+
+
+
+export default {
+ data() {
+ return {
+ items: [
+ {
+ label: 'Videos', icon: 'pi pi-fw pi-video',
+ items: [
+ [
+ {
+ label: 'Video 1',
+ items: [{label: 'Video 1.1'}, {label: 'Video 1.2'}]
+ },
+ {
+ label: 'Video 2',
+ items: [{label: 'Video 2.1'}, {label: 'Video 2.2'}]
+ }
+ ],
+ [
+ {
+ label: 'Video 3',
+ items: [{label: 'Video 3.1'}, {label: 'Video 3.2'}]
+ },
+ {
+ label: 'Video 4',
+ items: [{label: 'Video 4.1'}, {label: 'Video 4.2'}]
+ }
+ ]
+ ]
+ },
+ {
+ label: 'Users', icon: 'pi pi-fw pi-users',
+ items: [
+ [
+ {
+ label: 'User 1',
+ items: [{label: 'User 1.1'}, {label: 'User 1.2'}]
+ },
+ {
+ label: 'User 2',
+ items: [{label: 'User 2.1'}, {label: 'User 2.2'}]
+ },
+ ],
+ [
+ {
+ label: 'User 3',
+ items: [{label: 'User 3.1'}, {label: 'User 3.2'}]
+ },
+ {
+ label: 'User 4',
+ items: [{label: 'User 4.1'}, {label: 'User 4.2'}]
+ }
+ ],
+ [
+ {
+ label: 'User 5',
+ items: [{label: 'User 5.1'}, {label: 'User 5.2'}]
+ },
+ {
+ label: 'User 6',
+ items: [{label: 'User 6.1'}, {label: 'User 6.2'}]
+ }
+ ]
+ ]
+ },
+ {
+ label: 'Events', icon: 'pi pi-fw pi-calendar',
+ items: [
+ [
+ {
+ label: 'Event 1',
+ items: [{label: 'Event 1.1'}, {label: 'Event 1.2'}]
+ },
+ {
+ label: 'Event 2',
+ items: [{label: 'Event 2.1'}, {label: 'Event 2.2'}]
+ }
+ ],
+ [
+ {
+ label: 'Event 3',
+ items: [{label: 'Event 3.1'}, {label: 'Event 3.2'}]
+ },
+ {
+ label: 'Event 4',
+ items: [{label: 'Event 4.1'}, {label: 'Event 4.2'}]
+ }
+ ]
+ ]
+ },
+ {
+ label: 'Settings', icon: 'pi pi-fw pi-cog',
+ items: [
+ [
+ {
+ label: 'Setting 1',
+ items: [{label: 'Setting 1.1'}, {label: 'Setting 1.2'}]
+ },
+ {
+ label: 'Setting 2',
+ items: [{label: 'Setting 2.1'}, {label: 'Setting 2.2'}]
+ },
+ {
+ label: 'Setting 3',
+ items: [{label: 'Setting 3.1'}, {label: 'Setting 3.2'}]
+ }
+ ],
+ [
+ {
+ label: 'Setting 4',
+ items: [{label: 'Setting 4.1'}, {label: 'Setting 4.2'}]
+ }
+ ]
+ ]
+ }
+ ]
+ }
+ }
+}
+
+
+
+ Default orientation is "horizontal" with "vertical" as the alternative.
+
+<MegaMenu :model="items" orientation="vertical" />
+
+
+
+ Two slots named "start" and "end" are provided to embed content before or after the items. In additon MegaMenu, offers item customization with the item template that receives the menuitem instance from the model as a parameter.
+
+<MegaMenu :model="items">
+ <template #start>
+ Before
+ </template>
+ <template #item="{item}">
+ <a :href="item.url">{{item.label}}</a>
+ </template>
+ <template #end>
+ After
+ </template>
+</MegaMenu>
+
+
+
+ router-link with route configuration can also be used within templating for further customization.
+
+<MegaMenu :model="items">
+ <template #item="{item}">
+ <router-link :to="item.to" custom v-slot="{href, route, navigate, isActive, isExactActive}">
+ <a :href="href" @click="navigate" :class="{'active-link': isActive, 'active-link-exact': isExactActive}">{{route.fullPath}}</a>
+ </router-link>
+ </template>
+</MegaMenu>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
model | +array | +null | +An array of menuitems. | +
orientation | +string | +horizontal | +Defines the orientation, valid values are horizontal and vertical. | +
exact | +boolean | +true | +Whether to apply 'router-link-active-exact' class if route exactly matches the item path. | +
Name | +Parameters | +
---|---|
item | +item: Menuitem instance | +
start | +- | +
end | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-megamenu | +Container element. | +
p-megamenu-horizontal | +Container element in horizontal orientation. | +
p-megamenu-vertical | +Container element in vertical orientation. | +
p-megamenu-root-list | +Root list element. | +
p-megamenu-panel | +Submenu container. | +
p-megamenu-submenu | +Submenu list element. | +
p-menuitem | +Menuitem element. | +
p-menuitem-active | +Active menuitem element. | +
p-menuitem-text | +Label of a menuitem. | +
p-menuitem-icon | +Icon of a menuitem. | +
p-submenu-icon | +Arrow icon of a submenu. | +
p-megamenu-custom | +Container of the default slot. | +
None.
+Menu is a navigation / command component that supports dynamic and static positioning.
+
+import Menu from 'primevue/menu';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ Menu uses the common MenuModel API to define the items, visit
Menu requires a collection of menuitems as its model.
+
+<Menu :model="items" />
+
+
+
+
+export default {
+ data() {
+ return {
+ items: [
+ {
+ label: 'Update',
+ icon: 'pi pi-refresh',
+ command: () => {
+ this.$toast.add({severity:'success', summary:'Updated', detail:'Data Updated', life: 3000});
+ }
+ },
+ {
+ label: 'Delete',
+ icon: 'pi pi-times',
+ command: () => {
+ this.$toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000});
+ }
+ },
+ {
+ label: 'Vue Website',
+ icon: 'pi pi-external-link',
+ url: 'https://vuejs.org/'
+ },
+ {
+ label: 'Router',
+ icon: 'pi pi-upload',
+ to: '/fileupload'
+ }
+ ]
+ }
+ }
+}
+
+
+
+ Menu supports one level of nesting via subitems of an item.
+
+const items: [
+ {
+ label: 'Options',
+ items: [{label: 'New', icon: 'pi pi-fw pi-plus', command:() => {} },
+ {label: 'Delete', icon: 'pi pi-fw pi-trash', url: 'https://www.primetek.com.tr'}]
+ },
+ {
+ label: 'Account',
+ items: [{label: 'Options', icon: 'pi pi-fw pi-cog', to: '/options'},
+ {label: 'Sign Out', icon: 'pi pi-fw pi-power-off', to: '/logout'} ]
+ }
+];
+
+
+
+ Menu is inline by default whereas popup mode is supported by enabling popup property and calling toggle method with an event of the target.
+ +
+<Button type="button" label="Toggle" @click="toggle" />
+<Menu ref="menu" :model="items" :popup="true" />
+
+
+
+
+toggle(event) {
+ this.$refs.menu.toggle(event);
+}
+
+
+
+ Menu offers content customization with the item template that receives the menuitem instance from the model as a parameter.
+
+<Menu :model="items">
+ <template #item="{item}">
+ <a :href="item.url">{{item.label}}</a>
+ </template>
+</Menu>
+
+
+
+ router-link with route configuration can also be used within templating for further customization.
+
+<Menu :model="items">
+ <template #item="{item}">
+ <router-link :to="item.to" custom v-slot="{href, route, navigate, isActive, isExactActive}">
+ <a :href="href" @click="navigate" :class="{'active-link': isActive, 'active-link-exact': isExactActive}">{{route.fullPath}}</a>
+ </router-link>
+ </template>
+</Menu>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
model | +array | +null | +An array of menuitems. | +
popup | +boolean | +false | +Defines if menu would displayed as a popup. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
autoZIndex | +boolean | +true | +Whether to automatically manage layering. | +
exact | +boolean | +true | +Whether to apply 'router-link-active-exact' class if route exactly matches the item path. | +
Name | +Parameters | +Description | +
---|---|---|
show | +- | +Callback to invoke when the overlay is shown. | +
hide | +- | +Callback to invoke when the overlay is hidden. | +
Name | +Parameters | +Description | +
---|---|---|
toggle | +event: Browser event | +Toggles the visibility of the overlay. | +
show | +event: Browser event | +Shows the overlay. | +
hide | +- | +Hides the overlay. | +
Name | +Parameters | +
---|---|
item | +item: Menuitem instance | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-menu | +Container element. | +
p-menu-list | +List element. | +
p-menuitem | +Menuitem element. | +
p-menuitem-text | +Label of a menuitem. | +
p-menuitem-icon | +Icon of a menuitem. | +
None.
+Menubar is a horizontal menu component.
+
+import Menubar from 'primevue/menubar';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/menubar/menubar.min.js"></script>
+
+
+
+ Menubar uses the common MenuModel API to define the items, visit
Menubar requires a collection of menuitems as its model.
+
+<Menubar :model="items" />
+
+
+
+
+export default {
+ data() {
+ return {
+ items: [
+ {
+ label:'File',
+ icon:'pi pi-fw pi-file',
+ items:[
+ {
+ label:'New',
+ icon:'pi pi-fw pi-plus',
+ items:[
+ {
+ label:'Bookmark',
+ icon:'pi pi-fw pi-bookmark'
+ },
+ {
+ label:'Video',
+ icon:'pi pi-fw pi-video'
+ }
+ ]
+ },
+ {
+ label:'Delete',
+ icon:'pi pi-fw pi-trash'
+ },
+ {
+ separator:true
+ },
+ {
+ label:'Export',
+ icon:'pi pi-fw pi-external-link'
+ }
+ ]
+ },
+ {
+ label:'Edit',
+ icon:'pi pi-fw pi-pencil',
+ items:[
+ {
+ label:'Left',
+ icon:'pi pi-fw pi-align-left'
+ },
+ {
+ label:'Right',
+ icon:'pi pi-fw pi-align-right'
+ },
+ {
+ label:'Center',
+ icon:'pi pi-fw pi-align-center'
+ },
+ {
+ label:'Justify',
+ icon:'pi pi-fw pi-align-justify'
+ }
+ ]
+ },
+ {
+ label:'Users',
+ icon:'pi pi-fw pi-user',
+ items:[
+ {
+ label:'New',
+ icon:'pi pi-fw pi-user-plus',
+
+ },
+ {
+ label:'Delete',
+ icon:'pi pi-fw pi-user-minus',
+
+ },
+ {
+ label:'Search',
+ icon:'pi pi-fw pi-users',
+ items:[
+ {
+ label:'Filter',
+ icon:'pi pi-fw pi-filter',
+ items:[
+ {
+ label:'Print',
+ icon:'pi pi-fw pi-print'
+ }
+ ]
+ },
+ {
+ icon:'pi pi-fw pi-bars',
+ label:'List'
+ }
+ ]
+ }
+ ]
+ },
+ {
+ label:'Events',
+ icon:'pi pi-fw pi-calendar',
+ items:[
+ {
+ label:'Edit',
+ icon:'pi pi-fw pi-pencil',
+ items:[
+ {
+ label:'Save',
+ icon:'pi pi-fw pi-calendar-plus'
+ },
+ {
+ label:'Delete',
+ icon:'pi pi-fw pi-calendar-minus'
+ }
+ ]
+ },
+ {
+ label:'Archieve',
+ icon:'pi pi-fw pi-calendar-times',
+ items:[
+ {
+ label:'Remove',
+ icon:'pi pi-fw pi-calendar-minus'
+ }
+ ]
+ }
+ ]
+ },
+ {
+ label:'Quit',
+ icon:'pi pi-fw pi-power-off'
+ }
+ ]
+ }
+ }
+}
+
+
+
+ Two slots named "start" and "end" are provided to embed content before or after the menubar. In additon Menubar, offers item customization with the item template that receives the menuitem instance from the model as a parameter.
+
+<Menubar :model="items">
+ <template #start>
+ Before
+ </template>
+ <template #item="{item}">
+ <a :href="item.url">{{item.label}}</a>
+ </template>
+ <template #end>
+ After
+ </template>
+</Menubar>
+
+
+
+ router-link with route configuration can also be used within templating for further customization.
+
+<Menubar :model="items">
+ <template #item="{item}">
+ <router-link :to="item.to" custom v-slot="{href, route, navigate, isActive, isExactActive}">
+ <a :href="href" @click="navigate" :class="{'active-link': isActive, 'active-link-exact': isExactActive}">{{route.fullPath}}</a>
+ </router-link>
+ </template>
+</Menubar>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
model | +array | +null | +An array of menuitems. | +
exact | +boolean | +true | +Whether to apply 'router-link-active-exact' class if route exactly matches the item path. | +
Name | +Parameters | +
---|---|
start | +- | +
end | +- | +
item | +item: Menuitem instance | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-menubar | +Container element. | +
p-menubar-root-list | +Root list element. | +
p-submenu-list | +Submenu list element. | +
p-menuitem | +Menuitem element. | +
p-menuitem-active | +Active menuitem element. | +
p-menuitem-text | +Label of a menuitem. | +
p-menuitem-icon | +Icon of a menuitem. | +
p-submenu-icon | +Arrow icon of a submenu. | +
None.
+PrimeVue menu components share a common api to specify the menuitems and submenus.
+ +Menu components require Vue-Router as a dependency so make sure the router is installed in your application.
+ +Core of the API is the MenuItem class that defines various options such as the label, icon and children of an item in a menu.
+
+const items: [
+ {
+ label: 'Options',
+ items: [{label: 'New', icon: 'pi pi-fw pi-plus', command:() => {} },
+ {label: 'Delete', icon: 'pi pi-fw pi-trash', url: 'http://primetek.com.tr'}]
+ },
+ {
+ label: 'Account',
+ items: [{label: 'Options', icon: 'pi pi-fw pi-cog', to: '/options'},
+ {label: 'Sign Out', icon: 'pi pi-fw pi-power-off', to: '/logout'} ]
+ }
+];
+
+
+
+ MenuItem provides the following properties. Note that not all of them may be utilized by the corresponding menu component.
+ +Name | +Type | +Default | +Description | +
---|---|---|---|
label | +string | function | +null | +Property name or getter function to use as the label of an item. | +
icon | +string | +null | +Icon of the item. | +
to | +string | +null | +Route configuration such as path, name and parameters. | +
command | +function | +null | +Callback to execute when item is clicked. | +
url | +string | +null | +External link to navigate when item is clicked. | +
items | +array | +null | +An array of children menuitems. | +
disabled | +boolean/function | +false | +A boolean or a function to return a boolean to specify if the item is disabled. | +
visible | +boolean/function | +true | +A boolean or a function to return a boolean to specify if the item is visible. | +
target | +string | +null | +Specifies where to open the linked document. | +
separator | +boolean | +false | +Defines the item as a separator. | +
style | +object | +null | +Inline style of the menuitem. | +
class | +string | +null | +Style class of the menuitem. | +
key | +object | +null | +Unique identifier of an item. | +
The function to invoke when an item is clicked is defined using the command property.
+
+const items = [
+ {
+ label: 'New',
+ icon: 'pi pi-plus',
+ command: (event) => {
+ // event.originalEvent: Browser event
+ // event.item: Menuitem instance
+ }
+ }
+];
+
+
+
+ Navigation is specified using url property for external links or using to property for internal routing.
+
+const items = [
+ {
+ label: 'Route Path',
+ icon: 'pi pi-plus',
+ to: '/fileupload'
+ },
+ {
+ label: 'Named Route',
+ icon: 'pi pi-plus',
+ to: {name: 'fileupload'}
+ },
+ {
+ label: 'External',
+ icon: 'pi pi-check',
+ url: 'https://www.primefaces.org/primevue'
+ }
+];
+
+
+
+ It is a common case to hide certain items based on conditions such as user roles, visible property is available to implement such cases by supporting functions that returns booleans or simple booleans.
+
+const items = [
+ {
+ label: 'Remove',
+ visible: false
+ },
+ {
+ label: 'Delete',
+ visible: () => this.isUserAdmin()
+ }
+];
+
+
+
+ Separators are special menuitems whose sole purpose is to divide menuitems. A separator is simply configured as below.
+
+const items = [
+ {
+ label: 'Item 1'
+ },
+ {
+ separator: true
+ },
+ {
+ label: 'Item 2'
+ }
+];
+
+
+ Messages is used to display inline messages with various severities.
+Message component is used to display inline messages mostly within forms.
+
+import Message from 'primevue/message';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ Message component requires a content to display.
+
+<Message>Welcome to PrimeVue</Message>
+
+
+
+ Multiple messages can be displayed using the standard v-for directive.
+ +
+<Message v-for="msg of messages" :severity="msg.severity" :key="msg.content">{{msg.content}}</Message>
+
+
+
+
+data() {
+ return {
+ messages: [
+ {severity: 'info', content: 'Dynamic Info Message'},
+ {severity: 'success', content: 'Dynamic Success Message'},
+ {severity: 'warn', content: 'Dynamic Warning Message'}
+ ]
+ }
+}
+
+
+
+ There are four possible values for the severity of a message. Default one is "info".
+ +Messages are closable by default resulting in a close icon being displayed on top right corner. In order to disable closable messages, set closable to false.
+
+<Message severity="success" :closable="false">Order Submitted</Message>
+
+
+
+ + Messages are sticky by default, if you require them to be cleared automatically, disable sticky property and optionally configure the life property to specify how long the message should be displayed which is 3000 ms by + default. +
+
+<Message severity="warn" :life="5000" :sticky="false">This message will hide in 5 seconds.</Message>
+
+
+
+
+import InlineMessage from 'primevue/inlinemessage';
+
+
+
+ InlineMessage component is useful in cases where a single message needs to be displayed related to an element such as forms. It has one property, severity of the message.
+
+<InputText placeholder="Username" class="p-invalid" />
+<InlineMessage>Field is required</InlineMessage>
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
severity | +string | +info | +Severity level of the message. | +
closable | +boolean | +true | +Whether the message can be closed manually using the close icon. | +
sticky | +boolean | +null | +When enabled, message is not removed automatically. | +
life | +number | +3000 | +Delay in milliseconds to close the message automatically. | +
icon | +string | +null | +Display a custom icon for the message. | +
Name | +Type | +Default | +Description | +
---|---|---|---|
severity | +string | +error | +Severity level of the message. | +
Name | +Parameters | +Description | +
---|---|---|
close | +event: Browser event | +Callback to invoke when a message is closed. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-message | +Container element. | +
p-message-info | +Container element when displaying info messages. | +
p-message-warn | +Container element when displaying warning messages. | +
p-message-error | +Container element when displaying error messages. | +
p-message-success | +Container element when displaying success messages. | +
p-message-close | +Close icon. | +
p-message-icon | +Severity icon. | +
p-message-text | +Content of a message. | +
Name | +Element | +
---|---|
p-inline-message | +Container element. | +
p-inline-message-info | +Container element when displaying info messages. | +
p-inline-message-warn | +Container element when displaying warning messages. | +
p-inline-message-error | +Container element when displaying error messages. | +
p-inline-message-success | +Container element when displaying success messages. | +
p-inline-message-icon | +Severity icon. | +
p-inline-message-text | +Content of a message. | +
None.
+MultiSelect is used to multiple values from a list of options.
+
+import MultiSelect from 'primevue/multiselect';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/multiselect/multiselect.min.js"></script>
+
+
+
+ MultiSelect requires a value to bind and a collection of arbitrary objects along with the optionLabel property to specify the label property of the option.
+
+<MultiSelect v-model="selectedCars" :options="cars" optionLabel="brand" placeholder="Select Brands" />
+
+
+
+
+data() {
+ return {
+ selectedCars: null,
+ cars: [
+ {brand: 'Audi', value: 'Audi'},
+ {brand: 'BMW', value: 'BMW'},
+ {brand: 'Fiat', value: 'Fiat'},
+ {brand: 'Honda', value: 'Honda'},
+ {brand: 'Jaguar', value: 'Jaguar'},
+ {brand: 'Mercedes', value: 'Mercedes'},
+ {brand: 'Renault', value: 'Renault'},
+ {brand: 'Volkswagen', value: 'Volkswagen'},
+ {brand: 'Volvo', value: 'Volvo'}
+ ]
+ }
+}
+
+
+
+ A comma separated list is used by default to display selected items whereas alternative chip mode is provided using the display property to visualize the items as tokens.
+
+<MultiSelect v-model="selectedCars" :options="cars" optionLabel="brand" placeholder="Select Brands" display="chip"/>
+
+
+
+ Options groups are specified with the optionGroupLabel and optionGroupChildren properties.
+
+export default {
+ data() {
+ return {
+ selectedGroupedCities: null,
+ groupedCities: [{
+ label: 'Germany', code: 'DE',
+ items: [
+ {label: 'Berlin', value: 'Berlin'},
+ {label: 'Frankfurt', value: 'Frankfurt'},
+ {label: 'Hamburg', value: 'Hamburg'},
+ {label: 'Munich', value: 'Munich'}
+ ]
+ },
+ {
+ label: 'USA', code: 'US',
+ items: [
+ {label: 'Chicago', value: 'Chicago'},
+ {label: 'Los Angeles', value: 'Los Angeles'},
+ {label: 'New York', value: 'New York'},
+ {label: 'San Francisco', value: 'San Francisco'}
+ ]
+ },
+ {
+ label: 'Japan', code: 'JP',
+ items: [
+ {label: 'Kyoto', value: 'Kyoto'},
+ {label: 'Osaka', value: 'Osaka'},
+ {label: 'Tokyo', value: 'Tokyo'},
+ {label: 'Yokohama', value: 'Yokohama'}
+ ]
+ }]
+ }
+ }
+}
+
+
+
+<MultiSelect v-model="selectedGroupedCities" :options="groupedCities"
+ optionLabel="label" optionGroupLabel="label" optionGroupChildren="items">
+</MultiSelect>
+
+
+
+ + Filtering allows searching items in the list using an input field at the header. In order to use filtering, enable filter property. By default, optionLabel is used when searching and filterFields can be used to customize the + fields being utilized. Furthermore, filterMatchMode is available to define the search algorithm. Valid values are "contains" (default), "startsWith" and "endsWith". +
+ +
+<MultiSelect v-model="selectedCars" :options="cars" :filter="true" optionLabel="brand" placeholder="Select Brands"/>
+
+
+
+ + Label of an option is used as the display text of an item by default, for custom content support define an option template that gets the option instance as a parameter. In addition value, optiongroup, chip, + header, footer, emptyfilter and empty slots are provided for further customization. +
+
+<MultiSelect v-model="selectedCars2" :options="cars" optionLabel="brand" placeholder="Select a Car">
+ <template #value="slotProps">
+ <div class="p-multiselect-car-token" v-for="option of slotProps.value" :key="option.brand">
+ <img :alt="option.brand" :src="'demo/images/car/' + option.brand + '.png'" />
+ <span>{{option.brand}}</span>
+ </div>
+ <template v-if="!slotProps.value || slotProps.value.length === 0">
+ Select Brands
+ </template>
+ </template>
+ <template #option="slotProps">
+ <div class="p-multiselect-car-option">
+ <img :alt="slotProps.option.brand" :src="'demo/images/car/' + slotProps.option.brand + '.png'" />
+ <span>{{slotProps.option.brand}}</span>
+ </div>
+ </template>
+</MultiSelect>
+
+
+
+ Any property of HTMLDivElement are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
options | +array | +null | +An array of selectitems to display as the available options. | +
optionLabel | +string | function | +null | +Property name or getter function to use as the label of an option. | +
optionValue | +string | function | +null | +Property name or getter function to use as the value of an option, defaults to the option itself when not defined. | +
optionDisabled | +string | function | +null | +Property name or getter function to use as the disabled flag of an option, defaults to false when not defined. | +
optionGroupLabel | +string | function | +null | +Property name or getter function to use as the label of an option group. | +
optionGroupChildren | +string | function | +null | +Property name or getter function that refers to the children options of option group. | +
scrollHeight | +string | +200px | +Height of the viewport, a scrollbar is defined if height of list exceeds this value. | +
placeholder | +string | +null | +Label to display when there are no selections. | +
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +
inputId | +string | +null | +Identifier of the underlying input element. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component. | +
panelStyle | +any | +null | +Inline style of the overlay panel. | +
panelClass | +string | +null | +Style class of the overlay panel. | +
panelProps | +object | +null | +Uses to pass all properties of the HTMLDivElement to the overlay panel. | +
filterInputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the filter input inside the overlay panel. | +
closeButtonProps | +object | +null | +Uses to pass all properties of the HTMLButtonElement to the close button inside the overlay panel. | +
dataKey | +string | +null | +A property to uniquely identify an option. | +
filter | +boolean | +false | +When specified, displays a filter input at header. | +
filterPlaceholder | +string | +null | +Placeholder text to show when filter input is empty. | +
filterLocale | +string | +undefined | +Locale to use in filtering. The default locale is the host environment's current locale. | +
filterMatchMode | +string | +contains | +Defines the filtering algorithm to use when searching the options. Valid values are "contains" (default), "startsWith" and "endsWith" | +
filterFields | +array | +null | +Fields used when filtering the options, defaults to optionLabel. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. Special keywords are "body" for document body and "self" for the element itself. | +
display | +string | +comma | +Defines how the selected items are displayed, valid values are "comma" and "chip". | +
selectedItemsLabel | +string | +{0} items selected | +Label to display after exceeding max selected labels. | +
maxSelectedLabels | +number | +null | +Decides how many selected item labels to show at most. | +
selectionLimit | +number | +null | +Maximum number of selectable items. | +
showToggleAll | +boolean | +true | +Whether to show the header checkbox to toggle the selection of all items at once. | +
loading | +boolean | +false | +Whether the multiselect is in loading state. | +
loadingIcon | +string | +pi pi-spinner pi-spin | +Icon to display in loading state. | +
selectAll | +boolean | +false | +Whether all data is selected. | +
resetFilterOnHide | +boolean | +false | +Clears the filter value when hiding the dropdown. | +
virtualScrollerOptions | +object | +null | +Whether to use the virtualScroller feature. The properties of |
+
autoOptionFocus | +boolean | +true | +Whether to focus on the first visible or selected element when the overlay panel is shown. | +
autoFilterFocus | +boolean | +false | +Whether to focus on the filter element when the overlay panel is shown. | +
filterMessage | +string | +{0} results are available | +Text to be displayed in hidden accessible field when filtering returns any results. Defaults to value from PrimeVue locale configuration. | +
selectionMessage | +string | +{0} items selected | +Text to be displayed in hidden accessible field when options are selected. Defaults to value from PrimeVue locale configuration. | +
emptySelectionMessage | +string | +No selected item | +Text to be displayed in hidden accessible field when any option is not selected. Defaults to value from PrimeVue locale configuration. | +
emptyFilterMessage | +string | +No results found | +Text to be displayed when filtering does not return any results. Defaults to value from PrimeVue locale configuration. | +
emptyMessage | +string | +No results found | +Text to be displayed when there are no options available. Defaults to value from PrimeVue locale configuration. | +
tabindex | +number | +0 | +Index of the element in tabbing order. | +
aria-label | +string | +null | +Defines a string value that labels an interactive element. | +
aria-labelledby | +string | +null | +Establishes relationships between the component and label(s) where its value should be one or more element IDs. | +
Name | +Parameters | +Description | +
---|---|---|
change | +
+ event.originalEvent: Original event + event.value: Selected option value + |
+ Callback to invoke on value change. | +
focus | +event | +Callback to invoke when the component receives focus. | +
blur | +event | +Callback to invoke when the component loses focus. | +
before-show | +- | +Callback to invoke before the overlay is shown. | +
before-hide | +- | +Callback to invoke before the overlay is hidden. | +
show | +- | +Callback to invoke when the overlay is shown. | +
hide | +- | +Callback to invoke when the overlay is hidden. | +
filter | +
+ event.originalEvent: Original event + event.value: Filter value + |
+ Callback to invoke on filter input. | +
selectall-change | +
+ event.originalEvent: Original event + event.checked: Whether all data is selected. + |
+ Callback to invoke when all data is selected. | +
Name | +Parameters | +Description | +
---|---|---|
show | +isFocus: Decides whether to focus on the component. Default value is false. | +Shows the overlay. | +
hide | +isFocus: Decides whether to focus on the component. Default value is false. | +Hides the overlay. | +
clearFilter | +- | +Clears filter input. | +
Name | +Parameters | +
---|---|
value | +
+ value: Value of the component + placeholder: Placeholder prop value + |
+
chip | +value: A value in the selection | +
indicator | +- | +
header | +
+ value: Value of the component + options: Displayed options + |
+
footer | +
+ value: Value of the component + options: Displayed options + |
+
option | +
+ option: Option instance + index: Index of the option + |
+
optiongroup | +
+ option: OptionGroup instance + index: Index of the option group + |
+
emptyfilter | +- | +
empty | +- | +
content | +
+ items: An array of objects to display for virtualscroller + styleClass: Style class of the component + contentRef: Referance of the content + getItemOptions: Options of the items + |
+
loader | +options: Options of the loader items for virtualscroller | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-multiselect | +Container element. | +
p-multiselect-label-container | +Container of the label to display selected items. | +
p-multiselect-label-container | +Label to display selected items. | +
p-multiselect-trigger | +Dropdown button. | +
p-multiselect-filter-container | +Container of filter input. | +
p-multiselect-panel | +Overlay panel for items. | +
p-multiselect-items | +List container of items. | +
p-multiselect-item | +An item in the list. | +
p-overlay-open | +Container element when overlay is visible. | +
+ Value to describe the component can either be provided with aria-labelledby or aria-label props. The multiselect component has a combobox role in addition to aria-haspopup and aria-expanded attributes. + The relation between the combobox and the popup is created with aria-controls attribute that refers to the id of the popup listbox. +
+The popup listbox uses listbox as the role with aria-multiselectable enabled. Each list item has an option role along with aria-label, aria-selected and aria-disabled attributes.
+ +
+ Checkbox component at the header uses a hidden native checkbox element internally that is only visible to screen readers. Value to read is defined with the selectAll and unselectAll keys of the aria property from the
+
If filtering is enabled, filterInputProps can be defined to give aria-* props to the input element.
+ +Close button uses close key of the aria property from the
+<span id="dd1">Options</span>
+<MultiSelect aria-labelledby="dd1" />
+
+<MultiSelect aria-label="Options" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the multiselect element. | +
space | +Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. | +
enter | +Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. | +
down arrow | +Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. | +
up arrow | +Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. | +
any printable character | +Opens the popup and moves focus to the option whose label starts with the characters being typed, if there is none then first option receives the focus. | +
Key | +Function | +
---|---|
tab | +Moves focus to the next focusable element in the popup, if there is none then first focusable element receives the focus. | +
shift + tab | +Moves focus to the previous focusable element in the popup, if there is none then last focusable element receives the focus. | +
enter | +Toggles the selection state of the focused option, then moves focus to the multiselect element. | +
space | +Toggles the selection state of the focused option, then moves focus to the multiselect element. | +
escape | +Closes the popup, moves focus to the multiselect element. | +
down arrow | +Moves focus to the next option, if there is none then visual focus does not change. | +
up arrow | +Moves focus to the previous option, if there is none then visual focus does not change. | +
alt + up arrow | +Selects the focused option and closes the popup, then moves focus to the multiselect element. | +
shift + down arrow | +Moves focus to the next option and toggles the selection state. | +
shift + up arrow | +Moves focus to the previous option and toggles the selection state. | +
shift + space | +Selects the items between the most recently selected option and the focused option. | +
home | +Moves focus to the first option. | +
end | +Moves focus to the last option. | +
control + shift + home | +Selects the focused options and all the options up to the first one. | +
control + shift + end | +Selects the focused options and all the options down to the last one. | +
control + a | +Selects all options. | +
pageUp | +Jumps visual focus to first option. | +
pageDown | +Jumps visual focus to last option. | +
any printable character | +Moves focus to the option whose label starts with the characters being typed. | +
Key | +Function | +
---|---|
space | +Toggles the checked state. | +
escape | +Closes the popup and moves focus to the multiselect element. | +
Key | +Function | +
---|---|
down arrow | +Moves focus to the next option, if there is none then visual focus does not change. | +
up arrow | +Moves focus to the previous option, if there is none then visual focus does not change. | +
left arrow | +Removes the visual focus from the current option and moves input cursor to one character left. | +
right arrow | +Removes the visual focus from the current option and moves input cursor to one character right. | +
home | +Moves input cursor at the end, if not then moves focus to the first option. | +
end | +Moves input cursor at the beginning, if not then moves focus to the last option. | +
enter | +Closes the popup and moves focus to the multiselect element. | +
escape | +Closes the popup and moves focus to the multiselect element. | +
tab | +Moves focus to the next focusable element in the popup. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. | +
Key | +Function | +
---|---|
enter | +Closes the popup and moves focus to the multiselect element. | +
space | +Closes the popup and moves focus to the multiselect element. | +
escape | +Closes the popup and moves focus to the multiselect element. | +
None.
+OrderList is used to managed the order of a collection.
+
+import OrderList from 'primevue/orderlist';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/orderlist/orderlist.min.js"></script>
+
+
+
+ OrderList requires an array as its value bound with the v-model directive and a template for its content.
+Header of the component is defined with the "header" template and to define the content of an item in the list a named template called "item" needs to be defined which gets the item and the index via slotProps.
+
+<OrderList v-model="cars" listStyle="height:auto" dataKey="vin">
+ <template #header>
+ List of Cars
+ </template>
+ <template #item="slotProps">
+ <div class="p-caritem">
+ <img :src="'demo/images/car/' + slotProps.item.brand + '.png'">
+ <div>
+ <span class="p-caritem-vin">{{slotProps.item.vin}}</span>
+ <span>{{slotProps.item.year}} - {{slotProps.item.color}}</span>
+ </div>
+ </div>
+ </template>
+</OrderList>
+
+
+
+ + In case you'd need to access the selected items in the list, define a binding to the selection property with the v-model directive so that it gets updated when the user makes a selection. Since it is two-way binding enabled, your + changes to the selection will be reflected as well. Note that this is optional and only necessary when you need to access the selection. +
+ +Use the v-model directive to enable two-way binding.
+ +
+<OrderList v-model="cars" dataKey="vin" v-model:selection="selection">
+ <template #header>
+ List of Cars
+ </template>
+ <template #item="slotProps">
+ <div class="p-caritem">
+ <img :src="'demo/images/car/' + slotProps.item.brand + '.png'">
+ <div>
+ <span class="p-caritem-vin">{{slotProps.item.vin}}</span>
+ <span>{{slotProps.item.year}} - {{slotProps.item.color}}</span>
+ </div>
+ </div>
+ </template>
+</OrderList>
+
+
+
+ It is recommended to provide the name of the field that uniquely identifies the a record in the data via the dataKey property for better performance.
+ ++ In addition to the item template, header is provided to place custom content at the list header. Controls section can also be customized to place content before and after the buttons with controlsstart and + controlsend slots respectively. +
+ +Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +array | +null | +Value of the component. | +
selection | +any | +null | +Selected items in the list. | +
metaKeySelection | +boolean | +true | +
+ Defines whether metaKey is requred or not for the selection. + When true metaKey needs to be pressed to select or unselect an item and + when set to false selection of each item can be toggled individually. On touch enabled devices, metaKeySelection is turned off automatically. + |
+
dataKey | +string | +null | +Name of the field that uniquely identifies the a record in the data. | +
listStyle | +object | +null | +Inline style of the the list element. | +
responsive | +boolean | +true | +Whether the list optimizes layout based on screen size. | +
breakpoint | +string | +960px | +The breakpoint to define the maximum width boundary when responsiveness is enabled. | +
stripedRows | +boolean | +false | +Whether to displays rows with alternating colors. | +
Name | +Parameters | +Description | +
---|---|---|
reorder | +
+ event.originalEvent: browser event + event.value: Ordered list + event.direction: Direction of the change; "up", "down", "bottom", "top" + |
+ Callback to invoke when the list is reordered. | +
selection-change | +
+ event.originalEvent: browser event + event.value: Ordered list + |
+ Callback to invoke when selection changes. | +
Name | +Parameters | +
---|---|
header | +- | +
item | +
+ item: Item of the component + index: Index of the item + |
+
controlsstart | +- | +
controlsend | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-orderlist | +Container element. | +
p-orderlist-list | +List container. | +
p-orderlist-item | +An item in the list | +
None.
+OrganizationChart visualizes hierarchical organization data.
+
+import OrganizationChart from 'primevue/organizationchart';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/organizationchart/organizationchart.min.js"></script>
+
+
+
+ OrganizationChart requires an OrganizationChartNode instance as its root value and at least one template to display node content where node instance is passed via slotProps.
+
+ <OrganizationChart :value="data">
+ <template #default="slotProps">
+ <span>{{slotProps.node.data.label}}</span>
+ </template>
+</OrganizationChart>
+
+
+
+
+export default {
+ data() {
+ return {
+ data: {
+ key: '0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0_0',
+ data: {label: 'Chelsea F.C.'}
+ },
+ {
+ key: '0_0_1',
+ data: {label: 'F.C. Barcelona'}
+ }
+ ]
+ },
+ {
+ key: '0_1',
+ data: {label: 'Real Madrid'},
+ children: [
+ {
+ key: '0_1_0',
+ data: {label: 'Bayern Munich'}
+ },
+ {
+ key: '0_1_1',
+ data: {label: 'Real Madrid'}
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+}
+
+
+
+ API of the OrganizationChartNode has the properties below.
+Name | +Type | +Default | +Description | +
---|---|---|---|
key | +any | +null | +Unique identifier of the node. (required) | +
type | +string | +null | +Type of the node to match a template. | +
styleClass | +string | +null | +Style class of the node content. | +
data | +any | +null | +Data represented by the node. | +
selectable | +boolean | +true | +Whether node is selectable when selection is enabled. | +
collapsible | +boolean | +true | +Whether node is collapsible when node expansion is enabled. | +
children | +array | +null | +Children nodes array. | +
+ All nodes are expanded by default however they can be expanded and collapsed when collapsible is enabled. The optional collapsedKeys property defines the keys that are collapsed, this property is two-way binding enabled so + that user changes or programmatic changes are reflected to the UI. +
+Example below displays the root of chart in previous example as collapsed. Notice that the collapsedKeys is a map whose key is the key of the node and value is true.
+
+ <OrganizationChart :value="data" :collapsible="true" :collapsedKeys="collapsedKeys">
+ <template #default="slotProps">
+ <span>{{slotProps.node.data.label}}</span>
+ </template>
+</OrganizationChart>
+
+
+
+
+export default {
+ data() {
+ return {
+ collapsedKeys: {
+ '0': true
+ },
+ data: {
+ key: '0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0_0',
+ data: {label: 'Chelsea F.C.'}
+ },
+ {
+ key: '0_0_1',
+ data: {label: 'F.C. Barcelona'}
+ }
+ ]
+ },
+ {
+ key: '0_1',
+ data: {label: 'Real Madrid'},
+ children: [
+ {
+ key: '0_1_0',
+ data: {label: 'Bayern Munich'}
+ },
+ {
+ key: '0_1_1',
+ data: {label: 'Real Madrid'}
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+}
+
+
+
+ + Selection is enabled by defining the selectionMode to either "single" or "multiple" and specifying the selectionKeys with the v-model directive. Note that selection on a particular node can be disabled if the + selectable is false on the node instance. +
+
+ <OrganizationChart :value="data" selecionMode="single" v-model:selectionKeys="selectionKeys">
+ <template #default="slotProps">
+ <span>{{slotProps.node.data.label}}</span>
+ </template>
+</OrganizationChart>
+
+
+
+
+export default {
+ data() {
+ return {
+ selectionKeys: null,
+ data: {
+ key: '0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0_0',
+ data: {label: 'Chelsea F.C.'}
+ },
+ {
+ key: '0_0_1',
+ data: {label: 'F.C. Barcelona'}
+ }
+ ]
+ },
+ {
+ key: '0_1',
+ data: {label: 'Real Madrid'},
+ children: [
+ {
+ key: '0_1_0',
+ data: {label: 'Bayern Munich'}
+ },
+ {
+ key: '0_1_1',
+ data: {label: 'Real Madrid'}
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+}
+
+
+
+ The type property of an OrganizationChartNode is used to map a template to a node. If it is undefined, the default template is used.
+ +
+<OrganizationChart :value="data">
+ <template #person="slotProps">
+ <div class="node-header ui-corner-top">{{slotProps.node.data.label}}</div>
+ <div class="node-content">
+ <img :src="'demo/images/organization/' + slotProps.node.data.avatar" width="32">
+ <div>{{slotProps.node.data.name}}</div>
+ </div>
+ </template>
+ <template #default="slotProps">
+ <span>{{slotProps.node.data.label}}</span>
+ </template>
+</OrganizationChart>
+
+
+
+
+export default {
+ data() {
+ return {
+ data: {
+ key: '0',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'CEO', name: 'Walter White', avatar: 'walter.jpg'},
+ children: [
+ {
+ key: '0_0',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'CFO', name:'Saul Goodman', avatar: 'saul.jpg'},
+ children:[{
+ key: '0_0_0',
+ data: {label: 'Tax'},
+ selectable: false,
+ styleClass: 'department-cfo'
+ },
+ {
+ key: '0_0_1',
+ data: {label: 'Legal'},
+ selectable: false,
+ styleClass: 'department-cfo'
+ }],
+ },
+ {
+ key: '0_1',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'COO', name:'Mike E.', avatar: 'mike.jpg'},
+ children:[{
+ key: '0_1_0',
+ data: {label: 'Operations'},
+ selectable: false,
+ styleClass: 'department-coo'
+ }]
+ },
+ {
+ key: '0_2',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'CTO', name:'Jesse Pinkman', avatar: 'jesse.jpg'},
+ children:[{
+ key: '0_2_0',
+ data: {label: 'Development'},
+ selectable: false,
+ styleClass: 'department-cto',
+ children:[{
+ key: '0_2_0_0',
+ data: {label: 'Analysis'},
+ selectable: false,
+ styleClass: 'department-cto'
+ },
+ {
+ key: '0_2_0_1',
+ data: {label: 'Front End'},
+ selectable: false,
+ styleClass: 'department-cto'
+ },
+ {
+ key: '0_2_0_2',
+ data: {label: 'Back End'},
+ selectable: false,
+ styleClass: 'department-cto'
+ }]
+ },
+ {
+ key: '0_2_1',
+ data: {label: 'QA'},
+ selectable: false,
+ styleClass: 'department-cto'
+ },
+ {
+ key: '0_2_2',
+ data: {label: 'R&D'},
+ selectable: false,
+ styleClass: 'department-cto'
+ }]
+ }
+ ]
+ }
+ }
+ }
+}
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
value | +any | +null | +Value of the component. | +
selectionKeys | +object | +null | +A map instance of key-value pairs to represented the selected nodes. | +
selectionMode | +string | +null | +Type of the selection, valid values are "single" and "multiple". | +
collapsible | +boolean | +false | +Whether the nodes can be expanded or toggled. | +
collapsedKeys | +object | +null | +A map instance of key-value pairs to represented the collapsed nodes. | +
Name | +Parameters | +Description | +
---|---|---|
node-select | +node: Node instance | +Callback to invoke when a node is selected. | +
node-unselect | +node: Node instance | +Callback to invoke when a node is unselected. | +
node-expand | +node: Node instance | +Callback to invoke when a node is expanded. | +
node-collapse | +node: Node instance | +Callback to invoke when a node is collapsed. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-organizationchart | +Container element. | +
p-organizationchart-table | +Table container of a node. | +
p-organizationchart-lines | +Connector lines container. | +
p-organizationchart-nodes | +Contained of node children. | +
p-organizationchart-line-right | +Right side line of a node connector. | +
p-organizationchart-line-left | +Left side line of a node connector. | +
p-organizationchart-line-top | +Top side line of a node connector. | +
None.
+OverlayPanel is a container component positioned as connected to its target.
+
+import OverlayPanel from 'primevue/overlaypanel';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/overlaypanel/overlaypanel.min.js"></script>
+
+
+
+ OverlayPanel is accessed via its reference where visibility is controlled using toggle, show and hide methods.
+
+<Button type="button" label="Toggle" @click="toggle" />
+
+<OverlayPanel ref="op">
+ <img src="demo/images/nature/nature1.jpg" alt="Nature Image">
+</OverlayPanel>
+
+
+
+
+toggle(event) {
+ this.$refs.op.toggle(event);
+}
+
+
+
+ Clicking outside the overlay hides the panel, setting dismissable to false disables this behavior. Additionally enabling showCloseIcon property displays a close icon at the top right corner to close the panel.
+
+<OverlayPanel ref="op" :showCloseIcon="true" :dismissable="true">
+ <img src="demo/images/nature/nature1.jpg" alt="Nature Image">
+</OverlayPanel>
+
+
+
+ + OverlayPanel width can be adjusted per screen size with the breakpoints option. In example below, default width is set to 450px and below 961px, width would be 75vw and finally below 641px width becomes 100%. The value of + breakpoints should be an object literal whose keys are the maximum screen sizes and values are the widths per screen. +
+ +
+<OverlayPanel ref="op" :breakpoints="{'960px': '75vw', '640px': '100vw'}" :style="{width: '450px'}">
+ Content
+</OverlayPanel>
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
dismissable | +boolean | +true | +Enables to hide the overlay when outside is clicked. | +
showCloseIcon | +boolean | +false | +When enabled, displays a close icon at top right corner. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
autoZIndex | +boolean | +true | +Whether to automatically manage layering. | +
ariaCloseLabel | +string | +close | +Aria label of the close icon. | +
breakpoints | +object | +null | +Object literal to define widths per screen size. | +
Name | +Parameters | +Description | +
---|---|---|
toggle | +
+ event: Browser event + target: Optional target if event.currentTarget should not be used + |
+ Toggles the visibility of the overlay. | +
show | +
+ event: Browser event + target: Optional target if event.currentTarget should not be used + |
+ Shows the overlay. | +
hide | +- | +Hides the overlay. | +
Name | +Parameters | +Description | +
---|---|---|
show | +- | +Callback to invoke when the overlay is shown. | +
hide | +- | +Callback to invoke when the overlay is hidden. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-overlaypanel | +Container element. | +
p-overlaypanel-content | +Content of the panel. | +
p-overlaypanel-close | +Close icon. | +
None.
+Paginator is a generic component to display content in paged format.
+
+import Paginator from 'primevue/paginator';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ rows and totalRecords are the required properties of the Paginator.
+
+<Paginator :rows="10" :totalRecords="totalItemsCount"></Paginator>
+
+
+
+ first property defines the index of the first item displayed by the paginator.
+ +
+<Paginator :first="offset" :rows="10" :totalRecords="totalItemsCount"></Paginator>
+
+
+
+ Use the v-model directive to enable two-way binding, this is useful in cases where you need to programmatically control the paginator.
+
+<Paginator v-model:first="offset" :rows="10" :totalRecords="totalItemsCount"></Paginator>
+
+
+
+ Number of items per page can be changed by the user using a dropdown with the rowsPerPageOptions property which accepts an array of possible values.
+
+<Paginator v-model:first="offset" :rows="rows" :totalRecords="totalItemsCount" :rowsPerPageOptions="[10,20,30]"></Paginator>
+
+
+
+ As rows also change when the dropdown changes, use the optional v-model directive if you need two-way binding.
+ +
+<Paginator v-model:first="offset" v-model:rows="rows" :totalRecords="totalItemsCount" :rowsPerPageOptions="[10,20,30]"></Paginator>
+
+
+
+ + Paginator elements can be customized using the template property using the predefined keys, default value is "FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown". Here are the available elements that can be + placed inside a paginator in any order. +
+ +Current page report item in the template displays information about the pagination state. Default value is ({currentPage} of {totalPages}) whereas available placeholders are the following;
+There are two templates available named start and end to add custom content to these locations. Both templates get a state object as a slot property to provide the current page, first index and the rows.
+
+<Paginator v-model:first="offset" :rows="10" :totalRecords="totalItemsCount">
+ <template #start="slotProps">
+ Page: {{slotProps.state.page}}
+ First: {{slotProps.state.first}}
+ Rows: {{slotProps.state.rows}}
+ </template>
+ <template #end>
+ <Button type="button" icon="pi pi-search" />
+ </template>
+</Paginator>
+
+
+
+ Paginator provides only one event called page that passes all the information about the change event.
+
+<Paginator :rows="10" :totalRecords="totalItemsCount" @page="onPage($event)"></Paginator>
+
+
+
+
+onPage(event) {
+ //event.page: New page number
+ //event.first: Index of first record
+ //event.rows: Number of rows to display in new page
+ //event.pageCount: Total number of pages
+}
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
totalRecords | +number | +0 | +Number of total records. | +
rows | +number | +0 | +Data count to display per page. | +
first | +number | +0 | +Zero-relative number of the first row to be displayed. | +
pageLinkSize | +number | +5 | +Number of page links to display. | +
rowsPerPageOptions | +array | +null | +Array of integer values to display inside rows per page dropdown. | +
template | +string | +FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown | +Template of the paginator. | +
currentPageReportTemplate | +string | +({currentPage} of {totalPages}) | +Template of the current page report element. Available placeholders are {currentPage},{totalPages},{rows},{first},{last} and {totalRecords} | +
alwaysShow | +boolean | +true | +Whether to show the paginator even there is only one page. | +
Name | +Parameters | +Description | +
---|---|---|
page | +
+ event.page: New page number + event.first: Index of first record + event.rows: Number of rows to display in new page + event.pageCount: Total number of pages + |
+ Callback to invoke when page changes, the event object contains information about the new state. | +
Name | +Parameters | +
---|---|
start | +state: State of the paginator | +
end | +state: State of the paginator | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-paginator | +Container element. | +
p-paginator-first | +First page element. | +
p-paginator-prev | +Previous page element. | +
p-paginator-pages | +Container of page links. | +
p-paginator-page | +A page link. | +
p-paginator-next | +Next pge element. | +
p-paginator-last | +Last page element. | +
p-paginator-rpp-options | +Rows per page dropdown. | +
None.
+Panel is a container with the optional content toggle feature.
++ 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. +
++ 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. +
+
+import Panel from 'primevue/panel';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/panel/panel.min.js"></script>
+
+
+
+ Panel is a container component that accepts content as its children.
+
+<Panel header="Header">
+ 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.
+</Panel>
+
+
+
+ Header of the panel is either defined with the header property or the header template.
+
+<Panel>
+ <template #header>
+ Header Content
+ </template>
+ Content
+</Panel>
+
+
+
+ Content of the panel can be expanded and collapsed using toggleable option.
+
+<Panel header="Header" :toggleable="true">
+ 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.
+</Panel>
+
+
+
+ To control the initial state of the toggleable panel, use the collapsed property.
+
+<Panel header="Header Text" :toggleable="true" :collapsed="true">
+ Content
+</Panel>
+
+
+
+ Use the v-model directive to enable two-way binding.
+ +
+<button type="button" @click="isCollapsed = !isCollapsed">Toggle Programmatically</button>
+<Panel header="Header Text" :toggleable="true" v-model:collapsed="isCollapsed">
+ Content
+</Panel>
+
+
+
+ Additional icons can be placed at the header section of the panel using the special icons slot. For a unified look, it is suggest to add .p-panel-header-icon class to your icons.
+
+<h5>Advanced</h5>
+<Panel header="Header">
+ <template #icons>
+ <button class="p-panel-header-icon p-link mr-2" @click="toggle">
+ <span class="pi pi-cog"></span>
+ </button>
+ <Menu id="config_menu" ref="menu" :model="items" :popup="true" />
+ </template>
+</Panel>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
header | +string | +null | +Header text of the panel. | +
toggleable | +boolean | +null | +Defines if content of panel can be expanded and collapsed. | +
collapsed | +boolean | +null | +Defines the initial state of panel content. | +
toggleButtonProps | +string | +null | +Uses to pass the custom value to read for the button inside the component. | +
Name | +Parameters | +Description | +
---|---|---|
toggle | +
+ event.originalEvent: browser event + event.value: collapsed state as a boolean + |
+ Callback to invoke when a tab toggle. | +
Name | +Parameters | +
---|---|
header | +- | +
icons | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-panel | +Container element. | +
p-panel-header | +Header section. | +
p-panel-title | +Title text of panel. | +
p-panel-header-icon | +Action icons inside header. | +
p-panel-toggler | +Toggle icon. | +
p-panel-content | +Content of panel. | +
+ Toggleable panels use a content toggle button at the header that has aria-controls to define the id of the content section along with aria-expanded for the visibility state. The value to read the button defaults to the + value of the header property and can be customized by defining an aria-label or aria-labelledby via the toggleButtonProps property. +
+The content uses region, defines an id that matches the aria-controls of the content toggle button and aria-labelledby referring to the id of the header.
+ +Key | +Function | +
---|---|
tab | +Moves focus to the next the focusable element in the page tab sequence. | +
shift + tab | +Moves focus to the previous the focusable element in the page tab sequence. | +
enter | +Toggles the visibility of the content. | +
space | +Toggles the visibility of the content. | +
None.
+PanelMenu is a hybrid of Accordion and Tree components.
+
+import PanelMenu from 'primevue/panelmenu';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/panelmenu/panelmenu.min.js"></script>
+
+
+
+ PanelMenu uses the common MenuModel API to define the items, visit
PanelMenu requires a collection of menuitems as its model.
+
+<PanelMenu :model="items" />
+
+
+
+
+export default {
+ data() {
+ return {
+ items: [
+ {
+ label: 'File',
+ icon:'pi pi-fw pi-file',
+ items: [
+ {
+ label: 'New',
+ icon:'pi pi-fw pi-plus',
+ items: [
+ {
+ label: 'Bookmark',
+ icon:'pi pi-fw pi-bookmark'
+ },
+ {
+ label: 'Video',
+ icon:'pi pi-fw pi-video'
+ }
+ ]
+ },
+ {
+ label: 'Delete',
+ icon:'pi pi-fw pi-trash'
+ },
+ {
+ label: 'Export',
+ icon:'pi pi-fw pi-external-link'
+ }
+ ]
+ },
+ {
+ label: 'Edit',
+ icon:'pi pi-fw pi-pencil',
+ items: [
+ {
+ label: 'Left',
+ icon:'pi pi-fw pi-align-left'
+ },
+ {
+ label: 'Right',
+ icon:'pi pi-fw pi-align-right'
+ },
+ {
+ label: 'Center',
+ icon:'pi pi-fw pi-align-center'
+ },
+ {
+ label: 'Justify',
+ icon:'pi pi-fw pi-align-justify'
+ }
+ ]
+ },
+ {
+ label: 'Users',
+ icon:'pi pi-fw pi-user',
+ items: [
+ {
+ label: 'New',
+ icon:'pi pi-fw pi-user-plus',
+
+ },
+ {
+ label: 'Delete',
+ icon:'pi pi-fw pi-user-minus',
+ },
+ {
+ label: 'Search',
+ icon:'pi pi-fw pi-users',
+ items: [
+ {
+ label: 'Filter',
+ icon:'pi pi-fw pi-filter',
+ items: [
+ {
+ label: 'Print',
+ icon:'pi pi-fw pi-print'
+ }
+ ]
+ },
+ {
+ icon:'pi pi-fw pi-bars',
+ label: 'List'
+ }
+ ]
+ }
+ ]
+ },
+ {
+ label: 'Events',
+ icon:'pi pi-fw pi-calendar',
+ items: [
+ {
+ label: 'Edit',
+ icon:'pi pi-fw pi-pencil',
+ items: [
+ {
+ label: 'Save',
+ icon:'pi pi-fw pi-calendar-plus'
+ },
+ {
+ label: 'Delete',
+ icon:'pi pi-fw pi-calendar-minus'
+ }
+ ]
+ },
+ {
+ label: 'Archieve',
+ icon:'pi pi-fw pi-calendar-times',
+ items: [
+ {
+ label: 'Remove',
+ icon:'pi pi-fw pi-calendar-minus'
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ }
+}
+
+
+ PanelMenu offers content customization with the item template that receives the menuitem instance from the model as a parameter.
+
+<PanelMenu :model="items">
+ <template #item="{item}">
+ <a :href="item.url">{{item.label}}</a>
+ </template>
+</PanelMenu>
+
+
+
+ router-link with route configuration can also be used within templating for further customization.
+
+<PanelMenu :model="items">
+ <template #item="{item}">
+ <router-link :to="item.to" custom v-slot="{href, route, navigate, isActive, isExactActive}">
+ <a :href="href" @click="navigate" :class="{'active-link': isActive, 'active-link-exact': isExactActive}">{{route.fullPath}}</a>
+ </router-link>
+ </template>
+</PanelMenu>
+
+
+
+ + If the menuitem has a key defined, PanelMenu state can be controlled programmatically with the expandedKeys property that defines the keys that are expanded. This property is a Map instance whose key is the key of a node and + value is a boolean. Note that expandedKeys also supports two-way binding with the v-model directive. +
+ +Example below expands and collapses all nodes with buttons.
+
+<div>
+ <Button type="button" icon="pi pi-plus" label="Expand All" @click="expandAll" />
+ <Button type="button" icon="pi pi-minus" label="Collapse All" @click="collapseAll" />
+</div>
+<PanelMenu :model="items" v-model:expandedKeys="expandedKeys""></PanelMenu>
+
+
+
+
+export default {
+ data() {
+ return {
+ items: [{
+ key: '0',
+ label: 'File',
+ icon: 'pi pi-fw pi-file',
+ items: [{
+ key: '0_0',
+ label: 'New',
+ icon: 'pi pi-fw pi-plus',
+ items: [{
+ key: '0_0_0',
+ label: 'Bookmark',
+ icon: 'pi pi-fw pi-bookmark'
+ },
+ {
+ key: '0_0_1',
+ label: 'Video',
+ icon: 'pi pi-fw pi-video'
+ }
+ ]
+ },
+ {
+ key: '0_1',
+ label: 'Delete',
+ icon: 'pi pi-fw pi-trash'
+ },
+ {
+ key: '0_2',
+ label: 'Export',
+ icon: 'pi pi-fw pi-external-link'
+ }
+ ]
+ },
+ {
+ key: '1',
+ label: 'Edit',
+ icon: 'pi pi-fw pi-pencil',
+ items: [{
+ key: '1_0',
+ label: 'Left',
+ icon: 'pi pi-fw pi-align-left'
+ },
+ {
+ key: '1_1',
+ label: 'Right',
+ icon: 'pi pi-fw pi-align-right'
+ },
+ {
+ key: '1_2',
+ label: 'Center',
+ icon: 'pi pi-fw pi-align-center'
+ },
+ {
+ key: '1_3',
+ label: 'Justify',
+ icon: 'pi pi-fw pi-align-justify'
+ }
+ ]
+ },
+ {
+ key: '2',
+ label: 'Users',
+ icon: 'pi pi-fw pi-user',
+ items: [{
+ key: '2_0',
+ label: 'New',
+ icon: 'pi pi-fw pi-user-plus',
+
+ },
+ {
+ key: '2_1',
+ label: 'Delete',
+ icon: 'pi pi-fw pi-user-minus',
+ },
+ {
+ key: '2_2',
+ label: 'Search',
+ icon: 'pi pi-fw pi-users',
+ items: [{
+ key: '2_2_0',
+ label: 'Filter',
+ icon: 'pi pi-fw pi-filter',
+ items: [{
+ key: '2_2_0_0',
+ label: 'Print',
+ icon: 'pi pi-fw pi-print'
+ }]
+ },
+ {
+ key: '2_2_1',
+ icon: 'pi pi-fw pi-bars',
+ label: 'List'
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key: '3',
+ label: 'Events',
+ icon: 'pi pi-fw pi-calendar',
+ items: [{
+ key: '3_0',
+ label: 'Edit',
+ icon: 'pi pi-fw pi-pencil',
+ items: [{
+ key: '3_0_0',
+ label: 'Save',
+ icon: 'pi pi-fw pi-calendar-plus'
+ },
+ {
+ key: '3_0_0',
+ label: 'Delete',
+ icon: 'pi pi-fw pi-calendar-minus'
+ }
+ ]
+ },
+ {
+ key: '3_1',
+ label: 'Archieve',
+ icon: 'pi pi-fw pi-calendar-times',
+ items: [{
+ key: '3_1_0',
+ label: 'Remove',
+ icon: 'pi pi-fw pi-calendar-minus'
+ }]
+ }
+ ]
+ }
+ ],
+ expandedKeys: {}
+ }
+ },
+ methods: {
+ expandAll() {
+ for (let node of this.items) {
+ this.expandNode(node);
+ }
+
+ this.expandedKeys = {
+ ...this.expandedKeys
+ };
+ },
+ collapseAll() {
+ this.expandedKeys = {};
+ },
+ expandNode(node) {
+ if (node.items && node.items.length) {
+ this.expandedKeys[node.key] = true;
+
+ for (let child of node.items) {
+ this.expandNode(child);
+ }
+ }
+ }
+ }
+}
+
+
+ In order to display some nodes as expanded by default, simply add their keys to the map.
+
+export default {
+ data() {
+ return {
+ items: //menu model instance,
+ expandedKeys: {}
+ }
+ },
+ mounted() {
+ this.expandedKeys[this.items[0.key]] = true;
+ }
+}
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
model | +array | +null | +An array of menuitems. | +
expandedKeys | +array | +null | +A map of keys to represent the expansion state in controlled mode. | +
exact | +boolean | +true | +Whether to apply 'router-link-active-exact' class if route exactly matches the item path. | +
Name | +Parameters | +
---|---|
item | +item: Menuitem instance | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-panelmenu | +Container element. | +
p-panelmenu-header | +Accordion header of root submenu. | +
p-panelmenu-content | +Accordion content of root submenu. | +
p-submenu-list | +List element. | +
p-menuitem | +Menuitem element. | +
p-menuitem-text | +Label of a menuitem. | +
p-menuitem-icon | +Icon of a menuitem. | +
p-panelmenu-icon | +Arrow icon of an accordion header. | +
None.
+Password displays strength indicator for password fields.
+Suggestions
+
+import Password from 'primevue/password';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/password/password.min.js"></script>
+
+
+
+ A model can be bound using the standard v-model directive.
+
+<Password v-model="value" />
+
+
+
+ Password component uses regular expressions for middle and strong passwords with the following defaults.
+ +^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,}).
+^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})
+It is possible to define your own checks with the mediumRegex and strongRegex properties.
+ +3 slots are included to customize the overlay. These are header, content and footer. Note that content overrides the default meter.
+
+<Password v-model="value4">
+ <template #header>
+ <h6>Pick a password</h6>
+ </template>
+ <template #footer>
+ <Divider />
+ <p class="mt-2">Suggestions</p>
+ <ul class="pl-2 ml-2 mt-0" style="line-height: 1.5">
+ <li>At least one lowercase</li>
+ <li>At least one uppercase</li>
+ <li>At least one numeric</li>
+ <li>Minimum 8 characters</li>
+ </ul>
+ </template>
+</Password>
+
+
+
+ Any property such as name and placeholder are passed to the underlying input element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
inputId | +string | +null | +Identifier of the underlying input element. | +
promptLabel | +string | +null | +Text to prompt password entry. Defaults to PrimeVue |
+
mediumRegex | +string | +^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,}) | +Regex for a medium level password. | +
strongRegex | +string | +^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,}) | +Regex for a strong level password. | +
weakLabel | +string | +null | +Text for a weak password. Defaults to PrimeVue |
+
mediumLabel | +string | +null | +Text for a medium password. Defaults to PrimeVue |
+
strongLabel | +string | +null | +Text for a strong password. Defaults to PrimeVue |
+
feedback | +boolean | +true | +Whether to show the strength indicator or not. | +
toggleMask | +boolean | +false | +Whether to show an icon to display the password as plain text. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. Special keywords are "body" for document body and "self" for the element itself. | +
hideIcon | +string | +pi pi-eye-slash | +Icon to hide displaying the password as plain text. | +
showIcon | +string | +pi pi-eye | +Icon to show displaying the password as plain text. | +
disabled | +boolean | +false | +When present, it specifies that the element should be disabled. | +
placeholder | +string | +null | +Placeholder text for the input. | +
required | +boolean | +false | +When present, it specifies that an input field must be filled out before submitting the form. | +
inputId | +string | +null | +Style class of the component input field. | +
inputClass | +any | +null | +Style class of the input field. | +
inputStyle | +any | +null | +Inline style of the input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component. | +
panelId | +string | +null | +Identifier of the underlying overlay panel element. | +
panelClass | +string | +null | +Style class of the overlay panel. | +
panelStyle | +string | +null | +Inline style of the overlay panel. | +
panelProps | +object | +null | +Uses to pass all properties of the HTMLDivElement to the overlay panel inside the component. | +
Any valid event such as focus, blur and input are passed to the underlying input element.
+ +Name | +Parameters | +
---|---|
header | +- | +
content | +- | +
footer | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-password-panel | +Container of password panel | +
p-password-meter | +Meter element of password strength | +
p-password-info | +Text to display strength | +
+ Value to describe the component can either be provided via label tag combined with id prop or using aria-labelledby, aria-label props. Screen reader is notified about the changes to the strength of the password + using a section that has aria-live while typing. +
+ +
+<label for="pwd1">Password</label>
+<Password inputId="pwd1" />
+
+<span id="pwd2">Password</span>
+<Password aria-labelledby="pwd2" />
+
+<Password aria-label="Password"/>
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the input. | +
escape | +Hides the strength meter if open. | +
None.
+PickList is used to reorder items between different lists.
+
+import PickList from 'primevue/picklist';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/picklist/picklist.min.js"></script>
+
+
+
+ PickList requires a multidimensional array as its value bound with the v-model directive and a template for its content that gets the item instance and the index via slotProps.
+
+<PickList v-model="cars" dataKey="vin">
+ <template #item="slotProps">
+ <div class="p-caritem">
+ <img :src="'demo/images/car/' + slotProps.item.brand + '.png'">
+ <div>
+ <span class="p-caritem-vin">{{slotProps.item.vin}}</span>
+ <span>{{slotProps.item.year}} - {{slotProps.item.color}}</span>
+ </div>
+ </div>
+ </template>
+</PickList>
+
+
+
+ + In addition to the mandatory "item" template, picklist provides "sourceheader" and "targetheader" slots to define content at header sections. Similarly custom content can be placed before and after the button controls for each section can + be templates. View the slots section for more information. +
+
+<PickList v-model="cars" dataKey="vin">
+ <template #sourceheader>
+ Available
+ </template>
+ <template #targetheader>
+ Selected
+ </template>
+ <template #item="slotProps">
+ <div class="p-caritem">
+ <img :src="'demo/images/car/' + slotProps.item.brand + '.png'">
+ <div>
+ <span class="p-caritem-vin">{{slotProps.item.vin}}</span>
+ <span>{{slotProps.item.year}} - {{slotProps.item.color}}</span>
+ </div>
+ </div>
+ </template>
+</PickList>
+
+
+
+ + In case you need to access the selected items in the list, define a binding to the selection property with the v-model directive so that it gets updated when the user makes a selection. Since it is two-way binding enabled, your + changes to the selection will be reflected as well. Note that this is optional and only necessary when you need to access the selection. +
+ +
+<PickList v-model="cars" dataKey="vin" v-model:selection="selection">
+ <template #item="slotProps">
+ <div class="p-caritem">
+ <img :src="'demo/images/car/' + slotProps.item.brand + '.png'">
+ <div>
+ <span class="p-caritem-vin">{{slotProps.item.vin}}</span>
+ <span>{{slotProps.item.year}} - {{slotProps.item.color}}</span>
+ </div>
+ </div>
+ </template>
+</PickList>
+
+
+
+ It is recommended to provide the name of the field that uniquely identifies the a record in the data via the dataKey property for better performance.
+ +Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +array | +null | +Value of the component as a multidimensional array. | +
selection | +array | +null | +Selected items in the list as a multidimensional array. | +
metaKeySelection | +boolean | +true | +
+ Defines whether metaKey is requred or not for the selection. + When true metaKey needs to be pressed to select or unselect an item and + when set to false selection of each item can be toggled individually. On touch enabled devices, metaKeySelection is turned off automatically. + |
+
dataKey | +string | +null | +Name of the field that uniquely identifies the a record in the data. | +
listStyle | +object | +null | +Inline style of the the list element. | +
responsive | +boolean | +true | +Whether the list optimizes layout based on screen size. | +
breakpoint | +string | +960px | +The breakpoint to define the maximum width boundary when responsiveness is enabled. | +
stripedRows | +boolean | +false | +Whether to displays rows with alternating colors. | +
showSourceControls | +boolean | +true | +Whether to show buttons of source list. | +
showTargetControls | +boolean | +true | +Whether to show buttons of target list. | +
Name | +Parameters | +Description | +
---|---|---|
reorder | +
+ event.originalEvent: browser event + event.value: Ordered list + event.direction: Direction of the change; "up", "down", "bottom", "top" + event.listIndex: Index of the list that is ordered, 0 represents the source and 1 represents the target list. + |
+ Callback to invoke when the list is reordered. | +
move-to-target | +
+ event.originalEvent: browser event + event.items: Moved items + |
+ Callback to invoke when one or more items are moved to the target list. | +
move-all-to-target | +
+ event.originalEvent: browser event + event.items: Moved items + |
+ Callback to invoke when all items are moved to the target list. | +
move-to-source | +
+ event.originalEvent: browser event + event.items: Moved items + |
+ Callback to invoke when one or more items are moved to the source list. | +
move-all-to-source | +
+ event.originalEvent: browser event + event.items: Moved items + |
+ Callback to invoke when all items are moved to the source list. | +
selection-change | +
+ event.originalEvent: browser event + event.value: Selected item + |
+ Callback to invoke when one or more items are moved to the other list. | +
Name | +Parameters | +
---|---|
header | +- | +
item | +
+ item: Item of the component + index: Index of the item + |
+
sourceheader | +- | +
targetheader | +- | +
sourcecontrolsstart | +- | +
sourcecontrolsend | +- | +
movecontrolsstart | +- | +
movecontrolsend | +- | +
targetcontrolsstart | +- | +
targetcontrolsend | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-picklist | +Container element. | +
p-picklist-source-controls | +Container of source list buttons. | +
p-picklist-target-controls | +Container of target list buttons. | +
p-picklist-buttons | +Container of buttons. | +
p-picklist-listwrapper | +Parent of a list element. | +
p-picklist-list | +List element. | +
p-picklist-item | +An item in the list. | +
None.
+ProgressBar is a process status indicator.
+
+import ProgressBar from 'primevue/progressbar';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ ProgressBar has two modes; "determinate" (default) and "indeterminate". In determinate mode, a value between 0 and 100 is required to display the progress.
+
+<ProgressBar :value="value" />
+
+
+
+data() {
+ return {
+ value: 0
+ }
+}
+
+
+
+ Indeterminate is simplly enabled using mode property.
+
+<ProgressBar mode="indeterminate"/>
+
+
+
+ A custom label can be placed inside the progress bar via the default slot.
+
+<ProgressBar :value="value">
+ Percent Complete: {{value}}%
+</ProgressBar>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
value | +number | +null | +Current value of the progress. | +
mode | +string | +determinate | +Defines the mode of the progress, valid values are "determinate" and "indeterminate". | +
showValue | +boolean | +true | +Whether to display the progress bar value. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-progressbar | +Container element. | +
p-progressbar-determinate | +Container element of a determinate progressbar. | +
p-progressbar-indeterminate | +Container element of an indeterminate progressbar. | +
p-progressbar-value | +Element whose width changes according to value. | +
p-progressbar-label | +Label element that displays the current value. | +
None.
+ProgressSpinner is a process status indicator.
+
+import ProgressSpinner from 'primevue/progressspinner';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/progressspinner/progressspinner.min.js"></script>
+
+
+
+ ProgressSpinner is defined using ProgressSpinner element.
+
+<ProgressSpinner />
+
+
+
+ Colors of the spinner can be changed by overriding the keyframes animation.
+
+@keyframes p-progress-spinner-color {
+ 100%,
+ 0% {
+ stroke: #d62d20;
+ }
+ 40% {
+ stroke: #0057e7;
+ }
+ 66% {
+ stroke: #008744;
+ }
+ 80%,
+ 90% {
+ stroke: #ffa700;
+ }
+}
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
strokeWidth | +string | +2 | +Width of the circle stroke. | +
fill | +string | +null | +Color for the background of the circle. | +
animationDuration | +string | +2s | +Duration of the rotate animation. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-progress-spinner | +Container element. | +
p-progress-circle | +SVG element. | +
p-progress-path | +Circle element. | +
None.
+RadioButton is an extension to standard radio button element with theming.
+
+import RadioButton from 'primevue/radiobutton';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/radiobutton/radiobutton.min.js"></script>
+
+
+
+ Two-way value binding is defined using the standard v-model directive.
+
+<RadioButton name="city" value="Chicago" v-model="city" />
+<RadioButton name="city" value="Los Angeles" v-model="city" />
+
+
+
+export default {
+ data() {
+ return {
+ city: null
+ }
+ }
+}
+
+
+ As model is two-way binding enabled, giving a default value to the model is enough to display a radio button as checked by default.
+
+export default {
+ data() {
+ return {
+ city: 'Chicago'
+ }
+ }
+}
+
+
+
+ Any valid attribute is passed to the root element implicitly, extended properties are as follows;
+Name | +Type | +Default | +Description | +
---|---|---|---|
value | +any | +null | +Value of the checkbox. | +
modelValue | +any | +null | +Value binding of the checkbox. | +
name | +string | +null | +Name of the input element. | +
disabled | +boolean | +false | +When present, it specifies that the element should be disabled. | +
inputId | +string | +null | +Style class of the component input field. | +
inputClass | +string | +null | +Style class of the input field. | +
inputStyle | +any | +null | +Inline style of the input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component. | +
Any valid event such as focus and blur.
+Name | +Parameters | +Description | +
---|---|---|
click | +- | +Callback to invoke on radio button click. | +
change | +- | +Callback to invoke on radio button value change. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-radiobutton | +Container element | +
p-radiobutton-box | +Container of icon. | +
p-radiobutton-icon | +Icon element. | +
+ RadioButton component uses a hidden native radio button element internally that is only visible to screen readers. Value to describe the component can either be provided via label tag combined with id prop or using + aria-labelledby, aria-label props. +
+ +
+<label for="rb1">One</label>
+<RadioButton inputId="rb1" />
+
+<span id="rb2">Two</span>
+<RadioButton aria-labelledby="rb2" />
+
+<RadioButton aria-label="Three" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the checked radio button, if there is none within the group then first radio button receives the focus. | +
+ + left arrow + up arrow + + | +Moves focus to the previous radio button, if there is none then last radio button receives the focus. | +
+ + right arrow + down arrow + + | +Moves focus to the next radio button, if there is none then first radio button receives the focus. | +
space | +If the focused radio button is unchecked, changes the state to checked. | +
None.
+Rating component is a star based selection input.
+
+import Rating from 'primevue/rating';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/rating/rating.min.js"></script>
+
+
+
+ Two-way value binding is defined using v-model.
+
+<Rating v-model="val" />
+
+
+
+ Number of stars to display is defined with stars property, default is 5.
+
+<Rating v-model="val" :stars="7"/>
+
+
+
+ A cancel icon is displayed to reset the value by default, set cancel as false to remove this option.
+
+<Rating v-model="val" :cancel="false" />
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +number | +null | +Value of the rating. | +
name | +string | +null | +Name of the element. | +
disabled | +boolean | +false | +When present, it specifies that the element should be disabled. | +
readonly | +boolean | +false | +When present, it specifies that component is read-only. | +
stars | +number | +5 | +Number of stars. | +
cancel | +boolean | +true | +When specified a cancel icon is displayed to allow clearing the value. | +
Name | +Parameters | +Description | +
---|---|---|
change | +
+ event.originalEvent: Original event + event.value: Selected option value + |
+ Callback to invoke on value change. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-rating | +Container element | +
p-rating-star | +Star element | +
p-rating-star-on | +Selected star element. | +
p-rating-cancel | +Cancel icon. | +
+ Rating component internally uses radio buttons that are only visible to screen readers. The value to read for item is retrieved from the
Keyboard interaction is derived from the native browser handling of radio buttons in a group.
+Key | +Function | +
---|---|
tab | +Moves focus to the star representing the value, if there is none then first star receives the focus. | +
+ + left arrow + up arrow + + | +Moves focus to the previous star, if there is none then last radio button receives the focus. | +
+ + right arrow + down arrow + + | +Moves focus to the next star, if there is none then first star receives the focus. | +
space | +If the focused star does not represent the value, changes the value to the star value. | +
None.
+PrimeVue components are optimized for different screen sizes.
++ 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. +
++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt + explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non + numquam eius modi. +
++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique + sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil + impedit quo minus. +
++ 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. +
+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt + explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non + numquam eius modi. +
++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique + sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil + impedit quo minus. +
++ 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. +
+Ripple directive adds ripple effect to the host element.
+Ripple is an optional animation for the supported components such as buttons. It is disabled by default and needs to be enabled at your app's entry file (e.g. main.js) during the PrimeVue setup.
+
+import {createApp} from 'vue';
+import PrimeVue from 'primevue/config';
+const app = createApp(App);
+
+app.use(PrimeVue, {ripple: true});
+
+
+
+ Note: That would be it to enable ripple on PrimeVue components, next section describes how to use it with your own components and standard elements.
+ +Ripple is a directive that needs to be imported and configured with a name of your choice. Global configuration is done with the app.directive function.
+
+import Ripple from 'primevue/ripple';
+
+app.directive('ripple', Ripple);
+
+
+
+ Ripple can also be configured locally using the directives property of your component.
+
+directives: {
+ 'ripple': Ripple
+}
+
+
+
+ Once the ripple is configured, add .p-ripple class to the target and attach the directive with the v- prefix.
+
+<div class="p-ripple" v-ripple></div>
+
+
+
+ Default styling of the animation adds a shade of white. This can easily be customized using css that changes the color of .p-ink element.
+
+<div class="p-ripple purple" v-ripple></div>
+
+
+
+
+.p-ripple.purple .p-ink {
+ background: rgba(256,39,176,.3);
+}
+
+
+
+ Name | +Element | +
---|---|
p-ripple | +Host element. | +
p-ink | +Ripple element. | +
p-ink-active | +Ripple element during animating. | +
None.
+ScrollPanel is a cross browser, lightweight and themable alternative to native browser scrollbar.
++ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae et leo duis ut diam. Ultricies mi quis hendrerit dolor magna eget est lorem. Amet + consectetur adipiscing elit ut. Nam libero justo laoreet sit amet. Pharetra massa massa ultricies mi quis hendrerit dolor magna. Est ultricies integer quis auctor elit sed vulputate. Consequat ac felis donec et. Tellus + orci ac auctor augue mauris. Semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a. Tincidunt arcu non sodales neque sodales. Metus aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices. + Sodales ut etiam sit amet nisl purus. Cursus sit amet dictum sit amet. Tristique senectus et netus et malesuada fames ac turpis egestas. Et tortor consequat id porta nibh venenatis cras sed. Diam maecenas ultricies mi + eget mauris. Eget egestas purus viverra accumsan in nisl nisi. Suscipit adipiscing bibendum est ultricies integer. Mattis aliquam faucibus purus in massa tempor nec. +
++ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae et leo duis ut diam. Ultricies mi quis hendrerit dolor magna eget est lorem. Amet + consectetur adipiscing elit ut. Nam libero justo laoreet sit amet. Pharetra massa massa ultricies mi quis hendrerit dolor magna. Est ultricies integer quis auctor elit sed vulputate. Consequat ac felis donec et. Tellus + orci ac auctor augue mauris. Semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a. Tincidunt arcu non sodales neque sodales. Metus aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices. + Sodales ut etiam sit amet nisl purus. Cursus sit amet dictum sit amet. Tristique senectus et netus et malesuada fames ac turpis egestas. Et tortor consequat id porta nibh venenatis cras sed. Diam maecenas ultricies mi + eget mauris. Eget egestas purus viverra accumsan in nisl nisi. Suscipit adipiscing bibendum est ultricies integer. Mattis aliquam faucibus purus in massa tempor nec. +
++ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae et leo duis ut diam. Ultricies mi quis hendrerit dolor magna eget est lorem. Amet + consectetur adipiscing elit ut. Nam libero justo laoreet sit amet. Pharetra massa massa ultricies mi quis hendrerit dolor magna. Est ultricies integer quis auctor elit sed vulputate. Consequat ac felis donec et. Tellus + orci ac auctor augue mauris. Semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a. Tincidunt arcu non sodales neque sodales. Metus aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices. + Sodales ut etiam sit amet nisl purus. Cursus sit amet dictum sit amet. Tristique senectus et netus et malesuada fames ac turpis egestas. Et tortor consequat id porta nibh venenatis cras sed. Diam maecenas ultricies mi + eget mauris. Eget egestas purus viverra accumsan in nisl nisi. Suscipit adipiscing bibendum est ultricies integer. Mattis aliquam faucibus purus in massa tempor nec. +
+
+import ScrollPanel from 'primevue/scrollpanel';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/scrollpanel/scrollpanel.min.js"></script>
+
+
+
+ ScrollPanel usage is similar to any container element.
+
+<ScrollPanel style="width: 100%; height: 200px">
+ content
+</ScrollPanel>
+
+
+
+ Look and feel can easily be customized, here is an example with custom scrollbars.
+
+<ScrollPanel style="width: 100%; height: 200px" class="custom">
+ content
+</ScrollPanel>
+
+
+
+
+.custom .p-scrollpanel-wrapper {
+ border-right: 9px solid #f4f4f4;
+}
+
+.custom .p-scrollpanel-bar {
+ background-color: #1976d2;
+ opacity: 1;
+ transition: background-color .3s;
+}
+
+.custom .p-scrollpanel-bar:hover {
+ background-color: #135ba1;
+}
+
+
+
+ Step factor is 5px by default and can be customized with step option.
+
+<ScrollPanel style="width: 100%; height: 200px" :step="10"3>
+ content
+</ScrollPanel>
+
+
+
+ Any property such as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
step | +number | +5 | +Step factor to scroll the content while pressing the arrow keys. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-scrollpanel | +Container element. | +
p-scrollpanel-wrapper | +Wrapper of content section. | +
p-scrollpanel-content | +Content section. | +
p-scrollpanel-bar | +Scrollbar handle. | +
p-scrollpanel-bar-x | +Scrollbar handle of a horizontal bar. | +
p-scrollpanel-bar-y | +Scrollbar handle of a vertical bar | +
+ Scrollbars of the ScrollPanel has a scrollbar role along with the aria-controls attribute that refers to the id of the scrollable content container and the aria-orientation to indicate the orientation of + scrolling. +
+ +Key | +Function | +
---|---|
down arrow | +Scrolls content down when vertical scrolling is available. | +
up arrow | +Scrolls content up when vertical scrolling is available. | +
left | +Scrolls content left when horizontal scrolling is available. | +
right | +Scrolls content right when horizontal scrolling is available. | +
None.
+ScrollTop gets displayed after a certain scroll position and used to navigates to the top of the page quickly.
+Scroll down the page to display the ScrollTop component.
++ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae et leo duis ut diam. Ultricies mi quis hendrerit dolor magna eget est lorem. Amet consectetur + adipiscing elit ut. Nam libero justo laoreet sit amet. Pharetra massa massa ultricies mi quis hendrerit dolor magna. Est ultricies integer quis auctor elit sed vulputate. Consequat ac felis donec et. Tellus orci ac auctor + augue mauris. Semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a. Tincidunt arcu non sodales neque sodales. Metus aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices. Sodales ut etiam sit amet + nisl purus. Cursus sit amet dictum sit amet. Tristique senectus et netus et malesuada fames ac turpis egestas. Et tortor consequat id porta nibh venenatis cras sed. Diam maecenas ultricies mi eget mauris. Eget egestas purus + viverra accumsan in nisl nisi. Suscipit adipiscing bibendum est ultricies integer. Mattis aliquam faucibus purus in massa tempor nec. +
+
+import ScrollTop from 'primevue/scrolltop';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/scrolltop/scrolltop.min.js"></script>
+
+
+
+ Without any configuration, ScrollTop listens window scroll.
+
+<ScrollTop />
+
+
+
+ When the vertical scroll position reaches a certain value, ScrollTop gets displayed. This value is defined with the threshold property that defaults to 400.
+
+<ScrollTop :threshold="200" />
+
+
+
+ ScrollTop can also be assigned to its parent element by setting target as "parent".
+
+<div style="height: 400px; overflow: auto">
+ Content that overflows to container
+ <ScrollTop />
+</div>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
target | +string | +window | +Target of the ScrollTop, valid values are "window" and "parent". | +
threshold | +number | +400 | +Defines the threshold value of the vertical scroll position of the target to toggle the visibility. | +
icon | +string | +pi pi-chevron-up | +Icon to display. | +
behavior | +string | +smooth | +Defines the scrolling behavi, "smooth" adds an animation and "auto" scrolls with a jump. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-scrolltop | +Container element. | +
p-scrolltop-sticky | +Container element when attached to its parent. | +
None.
+SelectButton is a form component to choose a value from a list of options using button elements.
+
+import SelectButton from 'primevue/selectbutton';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/selectbutton/selectbutton.min.js"></script>
+
+
+
+ SelectButton requires a value to bind and a collection of arbitrary objects along with the optionLabel property to specify the label property of the option.
+
+<SelectButton v-model="selectedCity" :options="cities" optionLabel="name" />
+
+
+
+
+export default {
+ data() {
+ return {
+ selectedCity: null,
+ cities: [
+ {name: 'London', code: 'LND'},
+ {name: 'Paris', code: 'PRS'},
+ {name: 'Rome', code: 'RM'}
+ ]
+ }
+ }
+}
+
+
+
+ SelectButton allows selecting only one item by default and setting multiple option enables choosing more than one item. In multiple case, model property should be an array.
+
+<SelectButton v-model="selectedCity" :options="cities" optionLabel="brand" :multiple="true" />
+
+
+
+ Label of an option is used as the display text of an item by default, for custom content support define an option template that gets the option instance as a parameter.
+
+<SelectButton v-model="selectedCar" :options="cars" optionLabel="brand">
+ <template #option="slotProps">
+ <div class="car-option">
+ <img :alt="slotProps.option.brand" :src="'demo/images/car/' + slotProps.option.brand + '.png'" />
+ <div>{{slotProps.option.brand}}</div>
+ </div>
+ </template>
+</SelectButton>
+
+
+
+ Any valid attribute is passed to the root element implicitly, extended properties are as follows;
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
options | +array | +null | +An array of selectitems to display as the available options. | +
optionLabel | +string | function | +null | +Property name or getter function to use as the label of an option. | +
optionValue | +string | function | +null | +Property name or getter function to use as the value of an option, defaults to the option itself when not defined. | +
optionDisabled | +string | function | +null | +Property name or getter function to use as the disabled flag of an option, defaults to false when not defined. | +
multiple | +boolean | +false | +When specified, allows selecting multiple values. | +
unselectable | +boolean | +true | +Whether selection can be cleared. | +
disabled | +boolean | +false | +When present, it specifies that the element should be disabled. | +
dataKey | +string | +null | +A property to uniquely identify an option. | +
Name | +Parameters | +Description | +
---|---|---|
change | +
+ event.originalEvent: browser event + event.value: Single value or an array of values that are selected. + |
+ Callback to invoke on value change. | +
focus | +event: Browser event | +Callback to invoke on focus. | +
blur | +event: Browser event | +Callback to invoke on blur. | +
Name | +Parameters | +
---|---|
option | +
+ option: Option instance + index: Index of the option + |
+
+ SelectButton component uses hidden native checkbox role for multiple selection and hidden radio role for single selection that is only visible to screen readers. Value to describe the component can be provided via + aria-labelledby property. +
+ +Keyboard interaction is derived from the native browser handling of checkboxs in a group.
+Key | +Function | +
---|---|
tab | +Moves focus to the first selected option, if there is none then first option receives the focus. | +
+ + right arrow + up arrow + + | +Moves focus to the previous option. | +
+ + left arrow + down arrow + + | +Moves focus to the next option. | +
space | +Toggles the checked state of a button. | +
None.
+Sidebar is a panel component displayed as an overlay at the edges of the screen.
+
+import Sidebar from 'primevue/sidebar';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/sidebar/sidebar.min.js"></script>
+
+
+
+ Sidebar is used as a container and visibility is controlled with the visible property that requires a v-model two-way binding.
+
+<Sidebar v-model:visible="visibleLeft">
+ Content
+</Sidebar>
+
+<Button icon="pi pi-arrow-right" @click="visibleLeft = true" />
+
+
+
+ Sidebar can either be located on the left (default), right, top or bottom of the screen depending on the position property.
+
+<Sidebar v-model:visible="visibleRight" position="right">
+ Content
+</Sidebar>
+
+
+
+ Sidebar size can be changed using a fixed value or using one of the three predefined ones.
+
+<Sidebar v-model:visible="visibleLeft" class="p-sidebar-sm"></Sidebar>
+<Sidebar v-model:visible="visibleLeft" class="p-sidebar-md"></Sidebar>
+<Sidebar v-model:visible="visibleLeft" class="p-sidebar-lg"></Sidebar>
+
+
+
+ Full screen mode allows the sidebar to cover whole screen.
+
+<Sidebar v-model:visible="visibleFull" position="full">
+ Content
+</Sidebar>
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
visible | +boolean | +false | +Specifies the visibility of the dialog. | +
position | +string | +left | +Specifies the position of the sidebar, valid values are "left", "right", "top", "bottom" and "full". | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
autoZIndex | +boolean | +true | +Whether to automatically manage layering. | +
dismissable | +boolean | +true | +Whether clicking outside closes the panel. | +
showCloseIcon | +boolean | +true | +Whether to display a close icon inside the panel. | +
modal | +boolean | +true | +Whether to a modal layer behind the sidebar. | +
ariaCloseLabel | +string | +close | +Aria label of the close icon. | +
Name | +Parameters | +Description | +
---|---|---|
hide | +- | +Callback to invoke when sidebar gets hidden. | +
show | +- | +Callback to invoke when sidebar gets shown. | +
Name | +Parameters | +
---|---|
header | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-sidebar | +Container element | +
p-sidebar-left | +Container element of left sidebar. | +
p-sidebar-right | +Container element of right sidebar. | +
p-sidebar-top | +Container element of top sidebar. | +
p-sidebar-bottom | +Container element of bottom sidebar. | +
p-sidebar-full | +Container element of a full screen sidebar. | +
p-sidebar-active | +Container element when sidebar is visible. | +
p-sidebar-close | +Close anchor element. | +
p-sidebar-sm | +Small sized sidebar. | +
p-sidebar-md | +Medium sized sidebar. | +
p-sidebar-lg | +Large sized sidebar. | +
p-sidebar-mask | +Modal layer of the sidebar. | +
None.
+Skeleton is a placeholder to display instead of the actual content.
+
+import Skeleton from 'primevue/skeleton';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/skeleton/skeleton.min.js"></script>
+
+
+
+ Skeleton displays a rectangle in its simplest form.
+
+<Skeleton />
+
+
+
+ The other option is the circle by setting shape property as "circle".
+
+<Skeleton shape="circle"/>
+
+
+
+ In order to customize the size, use width and height properties for rectangles and size for Circle and Square shapes.
+
+<Skeleton width="100%" height="2rem" />
+<Skeleton shape="circle" size="50px" />
+
+
+
+ The default border radius of a rectangle is specified by the theme and can be overriden using the borderRadius property.
+
+<Skeleton borderRadius="16px" />
+
+
+
+ Animation can be turned of by setting animation to "none".
+
+<Skeleton animation="none" />
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
shape | +string | +rectangle | +Shape of the element, options are "rectangle" and "circle". | +
size | +string | +null | +Size of the Circle or Square. | +
width | +string | +100% | +Width of the element. | +
height | +string | +1rem | +Height of the element. | +
borderRadius | +string | +null | +Border radius of the element, defaults to value from theme. | +
animation | +string | +wave | +Type of the animation, valid options are "wave" and "none". | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-skeleton | +Container element. | +
p-skeleton-circle | +Container element of a determinate progressbar. | +
p-skeleton-animation-none | +Container element of an indeterminate progressbar. | +
None.
+Slider is an input component to provide a numerical input.
+
+import Slider from 'primevue/slider';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/slider/slider.min.js"></script>
+
+
+
+ Two-way binding is defined using the standard v-model directive.
+
+<Slider v-model="value" />
+
+
+
+ Range slider provides two handles to define two values. Enable range property and bind an array to implement a range slider.
+ +
+<Slider v-model="value" :range="true" />
+
+
+
+
+export default {
+ data() {
+ return {
+ value: [20,80]
+ }
+ }
+}
+
+
+
+ Default layout of slider is horizontal, use orientation property for the alternative vertical mode.
+
+<Slider v-model="value" orientation="vertical" />
+
+
+
+ Step factor is 1 by default and can be customized with step option.
+
+<Slider v-model="value" :step="20" />
+
+
+
+ Boundaries are specified with min and max attributes.
+
+<Slider v-model="value" :step="20" :min="50" :max="200" />
+
+
+
+ Any valid attribute is passed to the root element implicitly, extended properties are as follows;
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +number | +0 | +Value of the component. | +
min | +number | +0 | +Mininum boundary value. | +
max | +number | +100 | +Maximum boundary value. | +
orientation | +string | +horizontal | +Orientation of the slider, valid values are horizontal and vertical. | +
step | +number | +1 | +Step factor to increment/decrement the value. | +
range | +boolean | +false | +When speficed, allows two boundary values to be picked. | +
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +
tabindex | +number | +null | +Index of the element in tabbing order. | +
Name | +Parameters | +Description | +
---|---|---|
change | +value: Selected option value | +Callback to invoke on value change. | +
slideend | +
+ event.originalEvent: Original event + event.value: New value. + |
+ Callback to invoke when slide ends. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-slider | +Container element | +
p-slider-handle | +Handle element. | +
+ Slider element component uses slider role on the handle in addition to the aria-orientation, aria-valuemin, aria-valuemax and aria-valuenow attributes. Value to describe the component can be defined + using aria-labelledby and aria-label props. +
+ +
+<span id="label_number">Number</span>
+<Slider aria-labelledby="label_number" />
+
+<Slider aria-label="Number" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the slider. | +
+ + left arrow + up arrow + + | +Decrements the value. | +
+ + right arrow + down arrow + + | +Increments the value. | +
home | +Set the minimum value. | +
end | +Set the maximum value. | +
page up | +Increments the value by 10 steps. | +
page down | +Decrements the value by 10 steps. | +
None.
+When pressed, a floating action button can display multiple primary actions that can be performed on a page.
+
+import SpeedDial from 'primevue/speeddial';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/speeddial/speeddial.min.js"></script>
+
+
+
+ + When pressed, a floating action button can display multiple primary actions that can be performed on a page. It has a collection of additional options defined by the model property. SpeedDial's position is calculated according to + the container element with the position type style. +
+ +
+<SpeedDial :model="items" />
+
+
+
+
+items: [
+ {
+ label: 'Add',
+ icon: 'pi pi-pencil',
+ command: () => {
+ this.$toast.add({ severity: 'info', summary: 'Add', detail: 'Data Added' });
+ }
+ },
+ {
+ label: 'Update',
+ icon: 'pi pi-refresh',
+ command: () => {
+ this.$toast.add({ severity: 'success', summary: 'Update', detail: 'Data Updated' });
+ }
+ },
+ {
+ label: 'Delete',
+ icon: 'pi pi-trash',
+ command: () => {
+ this.$toast.add({ severity: 'error', summary: 'Delete', detail: 'Data Deleted' });
+ }
+ },
+ {
+ label: 'Upload',
+ icon: 'pi pi-upload',
+ command: () => {
+ this.$router.push('fileupload');
+ }
+ },
+ {
+ label: 'Vue Website',
+ icon: 'pi pi-external-link',
+ command: () => {
+ window.location.href = 'https://vuejs.org/'
+ }
+ }
+]
+
+
+
+ SpeedDial uses the common MenuModel API to define the items, visit
SpeedDial has 4 types; linear, circle, semi-circle and quarter-circle.
+ ++ Specifies the opening direction of actions. For the linear and semi-circle types; up, down, left and right. For the quarter-circle type; up-left, + up-right, down-left and down-right. +
+ +Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
model | +object | +null | +MenuModel instance to define the action items. | +
visible | +boolean | +false | +Specifies the visibility of the overlay. | +
direction | +string | +up | +Specifies the opening direction of actions. Valid values are 'up', 'down', 'left', 'right', 'up-left', 'up-right', 'down-left' and 'down-right' | +
transitionDelay | +number | +30 | +Transition delay step for each action item. | +
type | +string | +linear | +Specifies the opening type of actions. | +
radius | +number | +0 | +Radius for *circle types. | +
mask | +boolean | +false | +Whether to show a mask element behind the speeddial | +
disabled | +boolean | +false | +Whether the component is disabled. | +
hideOnClickOutside | +boolean | +true | +Whether the actions close when clicked outside. | +
buttonClass | +string | +null | +Style class of the button element. | +
maskClass | +string | +null | +Style class of the mask element. | +
maskStyle | +object | +null | +Inline style of the mask element. | +
showIcon | +string | +pi pi-plus | +Show icon of the button element. | +
hideIcon | +string | +null | +Hide icon of the button element. | +
rotateAnimation | +boolean | +true | +Defined to rotate showIcon when hideIcon is not present. | +
class | +string | +null | +Style class of the element. | +
style | +object | +null | +Inline style of the element. | +
tooltipOptions | +object | +null | +Whether to display the tooltip on items. The modifiers of |
+
Name | +Parameters | +Description | +
---|---|---|
click | +event: Browser event. | +Fired when the button element clicked. | +
show | +- | +Fired when the actions are visible. | +
hide | +- | +Fired when the actions are hidden. | +
Name | +Parameters | +
---|---|
item | +item: Custom template for item | +
button | +toggle: toggle metadata | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-speeddial | +Container element. | +
p-speeddial-button | +Button element of speeddial. | +
p-speeddial-mask | +Mask element of speeddial. | +
p-speeddial-list | +List of the actions. | +
p-speeddial-item | +Each action item of list. | +
None.
+SplitButton groups a set of commands in an overlay with a default command.
+
+import SplitButton from 'primevue/splitbutton';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/splitbutton/splitbutton.min.js"></script>
+
+
+
+ SplitButton has a default command button and a collection of additional options defined by the model property.
+
+<SplitButton label="Save" icon="pi pi-plus" :model="items"></SplitButton>
+
+
+
+
+export default {
+ data() {
+ return {
+ items: [
+ {
+ label: 'Update',
+ icon: 'pi pi-refresh',
+ command: () => {
+ this.$toast.add({severity:'success', summary:'Updated', detail:'Data Updated', life: 3000});
+ }
+ },
+ {
+ label: 'Delete',
+ icon: 'pi pi-times',
+ command: () => {
+ this.$toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000});
+ }
+ },
+ {
+ label: 'Vue Website',
+ icon: 'pi pi-external-link',
+ command: () => {
+ window.location.href = 'https://vuejs.org/'
+ }
+ },
+ {
+ label: 'Upload',
+ icon: 'pi pi-upload',
+ to: '/fileupload'
+ }
+ ]
+ }
+ }
+}
+
+
+
+ SplitButton uses the common MenuModel API to define the items, visit
Different color options are available as severity levels.
+ +
+<SplitButton label="Primary" :model="items"></SplitButton>
+<SplitButton label="Secondary" :model="items" class="p-button-secondary"></SplitButton>
+<SplitButton label="Success" :model="items" class="p-button-success"></SplitButton>
+<SplitButton label="Info" :model="items" class="p-button-info"></SplitButton>
+<SplitButton label="Warning" :model="items" class="p-button-warning"></SplitButton>
+<SplitButton label="Help" :model="items" class="p-button-help"></SplitButton>
+<SplitButton label="Danger" :model="items" class="p-button-danger"></SplitButton>
+
+
+
+ SplitButton can be raised by having "p-button-raised" style class and similarly borders can be made rounded using "p-button-rounded" class.
+
+<SplitButton label="Proceed" :model="items" class="p-button-raised p-button-rounded"></SplitButton>
+
+
+
+ Button part of the content can easily be customized with the default slot instead of using the built-in modes.
+
+<SplitButton :model="items" class="bg-primary border-round">
+ <Button @click="save">
+ <img alt="logo" src="../../assets/images/logo.svg" style="width: 1rem" />
+ <span class="ml-2 flex align-items-center font-bold">PrimeVue</span>
+ </Button>
+</SplitButton>
+
+
+
+ Any property such as tabindex are passed to the underlying input element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
label | +string | +null | +Text of the button. | +
icon | +string | +null | +Name of the icon. | +
model | +object | +null | +MenuModel instance to define the overlay items. | +
autoZIndex | +boolean | +true | +Whether to automatically manage layering. | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. | +
style | +any | +null | +Style class of the component. | +
class | +string | +null | +Inline style of the component. | +
Any valid event such as focus, blur and input are passed to the underlying button element. Following are the additional events to configure the component.
+Name | +Parameters | +Description | +
---|---|---|
click | +event: Browser event | +Callback to invoke when main button is clicked. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-splitbutton | +Container element. | +
p-splitbutton-button | +Dropdown button. | +
p-menu | +Overlay menu. | +
None.
+Splitter is utilized to separate and resize panels.
+
+import Splitter from 'primevue/splitter';
+import SplitterPanel from 'primevue/splitterpanel';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/splitter/splitter.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/splitterpanel/splitterpanel.min.js"></script>
+
+
+
+ Splitter requires two SplitterPanel components to wrap.
+
+<Splitter style="height: 300px">
+ <SplitterPanel>
+ Panel 1
+ </SplitterPanel>
+ <SplitterPanel>
+ Panel 2
+ </SplitterPanel>
+</Splitter>
+
+
+
+ Any number of panels can be nested inside a Splitter.
+
+<Splitter style="height: 300px">
+ <SplitterPanel v-for="item of items" :key="item.key">
+ {{item.content}}
+ </SplitterPanel>
+</Splitter>
+
+
+
+ Default orientation is configured with the layout property and default is the "horizontal" whereas other alternative is the "vertical".
+
+<Splitter style="height: 300px" layout="vertical">
+ <SplitterPanel>
+ Panel 1
+ </SplitterPanel>
+ <SplitterPanel>
+ Panel 2
+ </SplitterPanel>
+</Splitter>
+
+
+
+ When no size is defined, panels are split 50/50, use the size property to give relative widths e.g. 20/80.
+
+<Splitter style="height: 300px">
+ <SplitterPanel :size="20" >
+ Panel 1
+ </SplitterPanel>
+ <SplitterPanel :size="80">
+ Panel 2
+ </SplitterPanel>
+</Splitter>
+
+
+
+ Minimum size defines the lowest boundary for the size of a panel.
+
+<Splitter style="height: 300px">
+ <SplitterPanel :size="20" :minSize="10">
+ Panel 1
+ </SplitterPanel>
+ <SplitterPanel :size="80" :minSize="20">
+ Panel 2
+ </SplitterPanel>
+</Splitter>
+
+
+
+ Splitters can be combined to create advanced layouts.
+
+<Splitter style="height: 300px">
+ <SplitterPanel class="flex align-items-center justify-content-center" :size="20" :minSize="10">
+ Panel 1
+ </SplitterPanel>
+ <SplitterPanel :size="80">
+ <Splitter layout="vertical">
+ <SplitterPanel class="flex align-items-center justify-content-center" :size="15">
+ Panel 2
+ </SplitterPanel>
+ <SplitterPanel :size="85">
+ <Splitter>
+ <SplitterPanel class="flex align-items-center justify-content-center" :size="20">
+ Panel 3
+ </SplitterPanel>
+ <SplitterPanel class="flex align-items-center justify-content-center" :size="80">
+ Panel 4
+ </SplitterPanel>
+ </Splitter>
+ </SplitterPanel>
+ </Splitter>
+ </SplitterPanel>
+</Splitter>
+
+
+
+ + Splitters can be configured as stateful so that when the user visits the page again, the adjusts sizes can be restored. Define a stateKey to enable this feature. Default location of the state is session storage and other option is + the local storage which can be configured using the stateStorage property. +
+
+<Splitter stateKey="mykey" stateStorage="local">
+ <SplitterPanel>
+ Panel 1
+ </SplitterPanel>
+ <SplitterPanel>
+ Panel 2
+ </SplitterPanel>
+</Splitter>
+
+
+
+ Step factor is 5px by default and can be customized with step option.
+
+<Splitter :step="10">
+ <SplitterPanel>
+ Panel 1
+ </SplitterPanel>
+ <SplitterPanel>
+ Panel 2
+ </SplitterPanel>
+</Splitter>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
size | +number | +null | +Size of the element relative to 100%. | +
minSize | +number | +null | +Minimum size of the element relative to 100%. | +
Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
layout | +string | +horizontal | +Orientation of the panels, valid values are "horizontal" and "vertical". | +
gutterSize | +number | +4 | +Size of the divider in pixels. | +
stateKey | +string | +null | +Storage identifier of a stateful Splitter. | +
stateStorage | +string | +session | +Defines where a stateful splitter keeps its state, valid values are "session" for sessionStorage and "local" for localStorage. | +
step | +number | +5 | +Step factor to increment/decrement the size of the panels while pressing the arrow keys. | +
Name | +Parameters | +Description | +
---|---|---|
resizeend | +
+ event.originalEvent: Original event + event.sizes: Sizes of the panels as an array + |
+ Callback to invoke when resize ends. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-splitter | +Container element. | +
p-splitter | +Container element during resize. | +
p-splitter-horizontal | +Container element with horizontal layout. | +
p-splitter-vertical | +Container element with vertical layout. | +
p-splitter-panel | +Splitter panel element. | +
p-splitter-gutter | +Gutter element to use when resizing the panels. | +
p-splitter-gutter-handle | +Handl element of the gutter. | +
Splitter bar defines separator as the role with aria-orientation set to either horizontal or vertical.
+ +Key | +Function | +
---|---|
tab | +Moves focus through the splitter bar. | +
down arrow | +Moves a vertical splitter down. | +
up arrow | +Moves a vertical splitter up. | +
left arrow | +Moves a horizontal splitter to the left. | +
right arrow | +Moves a horizontal splitter to the right. | +
None.
+Steps components is an indicator for the steps in a wizard workflow. Example below uses nested routes with Steps.
+
+import Steps from 'primevue/steps';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/steps/steps.min.js"></script>
+
+
+
+ Steps uses the common MenuModel API to define the items, visit
Steps is integrated with Vue Router and requires a collection of menuitems as its model.
+
+<Steps :model="items" />
+<router-view />
+
+
+
+
+export default {
+ data() {
+ return {
+ items: [{
+ label: 'Personal',
+ to: '/steps'
+ },
+ {
+ label: 'Seat',
+ to: '/steps/seat'
+ },
+ {
+ label: 'Payment',
+ to: '/steps/payment'
+ },
+ {
+ label: 'Confirmation',
+ to: '/steps/confirmation'
+ }]
+ }
+ }
+}
+
+
+
+ Items are readonly by default, if you'd like to make them interactive then disable readonly property.
+
+<Steps :model="items" :readonly="false" />
+<router-view />
+
+
+
+ Steps offers content customization with the item template that receives the menuitem instance from the model as a parameter.
+
+<Steps :model="items">
+ <template #item="{item}">
+ <a :href="item.url">{{item.label}}</a>
+ </template>
+</Steps>
+
+
+
+ router-link with route configuration can also be used within templating for further customization.
+
+<Steps :model="items">
+ <template #item="{item}">
+ <router-link :to="item.to" custom v-slot="{href, route, navigate, isActive, isExactActive}">
+ <a :href="href" @click="navigate" :class="{'active-link': isActive, 'active-link-exact": isExactActive}>{{route.fullPath}}</a>
+ </router-link>
+ </template>
+</Steps>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
id | +string | +null | +Unique identifier of the element. | +
model | +array | +null | +An array of menuitems. | +
readonly | +boolean | +true | +Whether the items are clickable or not. | +
exact | +boolean | +true | +Whether to apply 'router-link-active-exact' class if route exactly matches the item path. | +
Name | +Parameters | +
---|---|
item | +item: Menuitem instance | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-steps | +Container element. | +
p-steps-item | +Menuitem element. | +
p-steps-number | +Number of menuitem. | +
p-steps-title | +Label of menuitem. | +
None.
+StyleClass manages css classes declaratively to during enter/leave animations or just to toggle classes on an element.
+
+import StyleClass from 'primevue/styleclass';
+
+app.directive('styleclass', StyleClass);
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/styleclass/styleclass.min.js"></script>
+
+
+
+ StyleClass has two modes, toggleClass to simply add-remove a class and enter/leave animations.
+ +ToggleClass
+
+<Button label="Toggle p-disabled" v-styleclass="{ selector: '@next', toggleClass: 'p-disabled' }" />
+<InputText class="block mt-3" />
+
+
+
+ Enter/Leave Animation
+
+<Button label="Show" class="mr-2" v-styleclass="{ selector: '.box', enterClass: 'hidden', enterActiveClass: 'my-fadein' }" />
+<Button label="Hide" v-styleclass="{ selector: '.box', leaveActiveClass: 'my-fadeout', leaveToClass: 'hidden' }" />
+<div class="box hidden">Content</div>
+
+
+
+ Target element is defined with the v-styleclass attribute that can either be a valid css query or one of the keywords below.
+Name | +Description | +
---|---|
@next | +Next element. | +
@prev | +Previous element. | +
@parent | +Parent element. | +
@grandparent | +Parent element of the parent. | +
Name | +Type | +Default | +Description | +
---|---|---|---|
selector | +string | +selector | +Selector to define the target element. | +
enterClass | +string | +null | +Class to add when item begins to get displayed. | +
enterActiveClass | +string | +null | +Class to add during enter animation. | +
enterToClass | +string | +null | +Class to add when enter animation is completed. | +
leaveClass | +string | +null | +Class to add when item begins to get hidden. | +
leaveActiveClass | +string | +null | +Class to add during leave animation | +
leaveToClass | +string | +null | +Class to add when leave animation is completed. | +
hideOnOutsideClick | +string | +null | +Whether to trigger leave animation when outside of the element is clicked. | +
toggleClass | +string | +null | +Adds or removes a class when no enter-leave animation is required. | +
Directive has no events.
+ +None.
+Professional support for the open source innovation.
+PRO means high-touch support. Contact us directly from a private JIRA with unlimited support tickets!
+Once you create a case, your request will be routed to our PRO team and they will get in touch within 1 business day.
+Take advantage of the unlimited number of cases. Our PRO team is at your side to solve all the problems you are experiencing.
+We identify, prioritize, fix your defects and provide fix patches.
+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.
+Choose one premium template of your choice with an extended license.
+An enterprise license for all of the ready to use UI blocks to build spectacular applications in no time.
+Direct Access to your issues! Your problems are resolved faster with our instant remote connection.
+Our PRO Team helps resolve critical issues in conference calls and ensure high-value collaboration with your team.
+PRO delivers the premium support and expertise you need. Resources are prioritized for an optimized response to critical issues.
+Be the first to be informed about critical security updates.
++ New feature and enhancement requests are not available in core services and provided via a credit model instead. When you have a feature request we provide an estimate, if you confirm we deliver your request within an estimated + timeframe and deduct the amount of work from your credits. +
+User needs are frequently changing. To meet your needs, we create new components.
+We add and configure new features to existing components to enhance the capabilities of your application.
+A problem might have several different solutions. We offer alternative ways for existing implementations.
+Our team makes accessibility improvements that allow your developers to create more accessible applications.
+Your projects can move forward faster with our effort to create PoC.
+Our experienced team reviews your entire project and improves your code quality.
++ You can purchase additional credits along with the subscription and also anytime during your subscription period. If your subscription term ends with unused credits, they will be added to your new subscription term in case you + extend. +
+TabMenu is a navigation component that displays items as tab headers. Example below uses nested routes with TabMenu.
+
+import TabMenu from 'primevue/tabmenu';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/tabmenu/tabmenu.min.js"></script>
+
+
+
+ TabMenu uses the common MenuModel API to define the items, visit
TabMenu requires a collection of menuitems as its model.
+
+<TabMenu :model="items" />
+
+
+
+
+export default {
+ data() {
+ return {
+ items: [
+ {label: 'Home', icon: 'pi pi-fw pi-home'},
+ {label: 'Calendar', icon: 'pi pi-fw pi-calendar'},
+ {label: 'Edit', icon: 'pi pi-fw pi-pencil'},
+ {label: 'Documentation', icon: 'pi pi-fw pi-file'},
+ {label: 'Settings', icon: 'pi pi-fw pi-cog'}
+ ]
+ }
+ }
+}
+
+
+
+ TabMenu can be also integrated with Vue Router.
+
+<TabMenu :model="items" />
+<router-view />
+
+
+
+
+export default {
+ data() {
+ return {
+ items: [
+ {label: 'Home', icon: 'pi pi-fw pi-home', to: '/tabmenu'},
+ {label: 'Calendar', icon: 'pi pi-fw pi-calendar', to: '/tabmenu/calendar'},
+ {label: 'Edit', icon: 'pi pi-fw pi-pencil', to: '/tabmenu/edit'},
+ {label: 'Documentation', icon: 'pi pi-fw pi-file', to: '/tabmenu/documentation'},
+ {label: 'Settings', icon: 'pi pi-fw pi-cog', to: '/tabmenu/settings'}
+ ]
+ }
+ }
+}
+
+
+
+ Visibility of the content is specified with the activeIndex property that supports one or two-way binding.
+ +
+<TabMenu :model="items" :activeIndex="activeIndex" />
+
+
+
+ Two-way binding requires v-model.
+
+<TabMenu :model="items" v-model:activeIndex="activeIndex" />
+
+
+
+ TabMenu offers content customization with the item template that receives the menuitem instance from the model as a parameter.
+
+<TabMenu :model="items">
+ <template #item="{item}">
+ <a :href="item.url">{{item.label}}</a>
+ </template>
+</TabMenu>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
model | +array | +null | +An array of menuitems. | +
exact | +boolean | +true | +Defines if active route highlight should match the exact route path. | +
activeIndex | +number | +0 | +Active index of menuitem. | +
Name | +Parameters | +Description | +
---|---|---|
tab-change | +
+ event.originalEvent: Browser event + event.index: Index of the selected tab + |
+ Callback to invoke when an active tab is changed. | +
Name | +Parameters | +
---|---|
item | +item: Menuitem instance | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-tabmenu | +Container element. | +
p-tabmenu-nav | +List element. | +
p-tabmenuitem | +Menuitem element. | +
p-highlight | +Active menuitem element. | +
p-menuitem-icon | +Icon of a menuitem. | +
p-menuitem-text | +Text of a menuitem. | +
None.
+TabView is a container component to group content with tabs.
++ 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. +
++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo + enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in + culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
++ 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. +
++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo + enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in + culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
++ 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. +
++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo + enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in + culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
++ 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. +
++ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo + enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. +
++ At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in + culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus. +
+{{ tab.content }}
+{{ tab.content }}
+
+import TabView from 'primevue/tabview';
+import TabPanel from 'primevue/tabpanel';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/tabview/tabview.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/tabpanel/tabpanel.min.js"></script>
+
+
+
+ Tabview element consists of one or more TabPanel elements. Header of the tab is defined using header attribute.
+
+<TabView>
+ <TabPanel header="Header I">
+ Content I
+ </TabPanel>
+ <TabPanel header="Header II">
+ Content II
+ </TabPanel>
+ <TabPanel header="Header III">
+ Content III
+ </TabPanel>
+</TabView>
+
+
+
+ Visibility of the content is specified with the activeIndex property that supports one or two-way binding.
+
+<TabView :activeIndex="activeIndex">
+ <TabPanel header="Header I">
+ Content I
+ </TabPanel>
+ <TabPanel header="Header II">
+ Content II
+ </TabPanel>
+ <TabPanel header="Header III">
+ Content III
+ </TabPanel>
+</TabView>
+
+
+
+ Two-way binding requires v-model.
+
+<TabView v-model:activeIndex="activeIndex">
+ <TabPanel header="Header I">
+ Content I
+ </TabPanel>
+ <TabPanel header="Header II">
+ Content II
+ </TabPanel>
+ <TabPanel header="Header III"">
+ Content III
+ </TabPanel>
+</TabView>
+
+
+
+ A tab can be disabled to prevent the content to be displayed by setting the disabled property on a panel.
+
+<TabView>
+ <TabPanel header="Header I">
+ Content I
+ </TabPanel>
+ <TabPanel header="Header II">
+ Content II
+ </TabPanel>
+ <TabPanel header="Header III" :disabled="true">
+ Content III
+ </TabPanel>
+</TabView>
+
+
+
+ Custom content for the title section of a panel is defined using the header template.
+
+<TabView>
+ <TabPanel>
+ <template #header>
+ <i class="pi pi-calendar"></i>
+ <span>Header I</span>
+ </template>
+ Content I
+ </TabPanel>
+ <TabPanel>
+ <template #header>
+ <span>Header II</span>
+ <i class="pi pi-user"></i>
+ </template>
+ Content II
+ </TabPanel>
+</TabView>
+
+
+
+ Tabs can be controlled programmatically using activeIndex property.
+
+<Button @click="active = 0" class="p-button-text" label="Activate 1st" />
+<Button @click="active = 1" class="p-button-text" label="Activate 2nd" />
+<Button @click="active = 2" class="p-button-text" label="Activate 3rd" />
+
+<TabView v-model:activeIndex="active">
+ <TabPanel header="Header I">
+ Content I
+ </TabPanel>
+ <TabPanel header="Header II">
+ Content II
+ </TabPanel>
+ <TabPanel header="Header III">
+ Content III
+ </TabPanel>
+</TabView>
+
+
+
+
+export default {
+ data() {
+ return {
+ active: 0
+ }
+ }
+}
+
+
+
+ Tabs can be generated dynamically using the standard v-for directive.
+
+<TabView>
+ <TabPanel v-for="tab in tabs" :key="tab.title" :header="tab.title">
+ <p>{{tab.content}}</p>
+ </TabPanel>
+</TabView>
+
+
+
+
+export default {
+ data() {
+ return {
+ tabs: [
+ {title: 'Title 1', content: 'Content 1'},
+ {title: 'Title 3', content: 'Content 2'},
+ {title: 'Title 3', content: 'Content 3'}
+ ]
+ }
+ }
+}
+
+
+
+ + All tabs are rendered when mounted and inactive tabs are hidden with CSS. Enabling lazy option activates the dynamic mode where a tab is only rendered at DOM when it is active. This option is useful to speed up the initial + rendering performance if there are many tabs. +
+ +
+<TabView lazy>
+ <TabPanel header="Header I">
+ Content I
+ </TabPanel>
+ <TabPanel header="Header II">
+ Content II
+ </TabPanel>
+ <TabPanel header="Header III">
+ Content III
+ </TabPanel>
+</TabView>
+
+
+
+ Enable scrollable property to display buttons at each side of the tab headers that scrolls the tab list.
+
+<TabView scrollable>
+ <TabPanel header="Header I">
+ Content I
+ </TabPanel>
+ <TabPanel header="Header II">
+ Content II
+ </TabPanel>
+ <TabPanel header="Header III">
+ Content III
+ </TabPanel>
+</TabView>
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
header | +string | +null | +Orientation of tab headers. | +
headerStyle | +string | +null | +Inline style of the tab header. | +
headerClass | +string | +null | +Style class of the tab header. | +
headerProps | +object | +null | +Uses to pass all properties of the HTMLLiElement to the tab header. | +
headerActionProps | +object | +null | +Uses to pass all properties of the HTMLAnchorElement to the focusable anchor element inside the tab header. | +
contentStyle | +string | +null | +Inline style of the tab content. | +
contentClass | +string | +null | +Style class of the tab content. | +
contentProps | +object | +null | +Uses to pass all properties of the HTMLDivElement to the tab content. | +
disabled | +boolean | +null | +Whether the tab is disabled. | +
Any additional properties like style and class are passed to the main container element.
+Name | +Type | +Default | +Description | +
---|---|---|---|
activeIndex | +number | +0 | +Index of the active tab. | +
lazy | +boolean | +false | +When enabled, hidden tabs are not rendered at all. Defaults to false that hides tabs with css. | +
scrollable | +boolean | +false | +When enabled displays buttons at each side of the tab headers to scroll the tab list. | +
tabindex | +number | +0 | +Index of the element in tabbing order. | +
selectOnFocus | +boolean | +false | +When enabled, the focused tab is activated. | +
previousButtonProps | +object | +null | +Uses to pass all properties of the HTMLButtonElement to the previous button. | +
nextButtonProps | +object | +null | +Uses to pass all properties of the HTMLButtonElement to the next button. | +
Name | +Parameters | +Description | +
---|---|---|
tab-change | +
+ event.originalEvent: Browser event + event.index: Index of the selected tab + |
+ Callback to invoke when an active tab is changed. | +
tab-click | +
+ event.originalEvent: Browser event + event.index: Index of the clicked tab + |
+ Callback to invoke when an active tab is clicked. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-tabview | +Container element. | +
p-tabview-nav | +Container of headers. | +
p-tabview-selected | +Selected tab header. | +
p-tabview-panels | +Container panels. | +
p-tabview-panel | +Content of a tab. | +
+ TabView container is defined with the tablist role, as any attribute is passed to the container element aria-labelledby can be optionally used to specify an element to describe the TabView. Each tab header has a + tab role along with aria-selected state attribute and aria-controls to refer to the corresponding tab content element. The content element of each tab has tabpanel role, an id to match the + aria-controls of the header and aria-labelledby reference to the header as the accessible name. +
+ +Key | +Function | +
---|---|
+ tab + | +Moves focus through the header. | +
+ enter + | +Activates the focused tab header. | +
+ space + | +Activates the focused tab header. | +
+ right arrow + | +Moves focus to the next header. If focus is on the last header, moves focus to the first header. | +
+ left arrow + | +Moves focus to the previous header. If focus is on the first header, moves focus to the last header. | +
+ home + | +Moves focus to the last header. | +
+ end + | +Moves focus to the first header. | +
pageUp | +Moves scroll position to first header. | +
pageDown | +Moves scroll position to last header. | +
None.
+Tag component is used to categorize content.
+
+import Tag from 'primevue/tag';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/tag/tag.min.js"></script>
+
+
+
+ Content of the tag is specified using the value property.
+
+<Tag value="New"></Tag>
+
+
+
+ An icon can also be configured to be displayed next to the value with the icon property.
+
+<Tag value="New" icon="pi pi-plus"></Tag>
+
+
+
+ Different color options are available as severity levels.
+ +Content can easily be customized with the default slot instead of using the built-in display.
+
+<Tag>
+ Content
+</Tag>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
value | +any | +null | +Value to display inside the tag. | +
severity | +string | +null | +Severity type of the tag. | +
rounded | +boolean | +false | +Whether the corners of the tag are rounded. | +
icon | +string | +null | +Icon of the tag to display next to the value. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-tag | +Tag element | +
p-tag-rounded | +Rounded element | +
p-tag-icon | +Icon of the tag | +
p-tag-value | +Value of the tag | +
None.
+Terminal is a text based user interface.
+Enter "date" to display the current date, "greet {0}" for a message and "random" to get a random number.
+
+import Terminal from 'primevue/terminal';
+import TerminalService from 'primevue/terminalservice';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/terminal/terminal.min.js"></script>
+
+
+
+ + Commands are processed using an EventBus implementation called TerminalService. Import this service into your component and subscribe to the command event to process the commands by sending replies with the response event. +
+
+<Terminal welcomeMessage="Welcome to PrimeVue" prompt="primevue $" />
+
+
+
+
+import TerminalService from 'primevue/terminalservice';
+
+export default {
+ methods: {
+ commandHandler(text) {
+ let response;
+ let argsIndex = text.indexOf(' ');
+ let command = argsIndex !== -1 ? text.substring(0, argsIndex) : text;
+
+ switch(command) {
+ case "date":
+ response = 'Today is ' + new Date().toDateString();
+ break;
+
+ case "greet":
+ response = 'Hola ' + text.substring(argsIndex + 1);
+ break;
+
+ case "random":
+ response = Math.floor(Math.random() * 100);
+ break;
+
+ default:
+ response = "Unknown command: " + command;
+ }
+
+ TerminalService.$emit('response', response);
+ }
+ },
+ mounted() {
+ TerminalService.$on('command', this.commandHandler);
+ },
+ beforeUnmount() {
+ TerminalService.$off('command', this.commandHandler);
+ }
+}
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
welcomeMessage | +string | +null | +Initial text to display on terminal. | +
prompt | +string | +null | +Prompt text for each command. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-terminal | +Container element. | +
p-terminal-content | +Content of terminal. | +
p-terminal-prompt | +Prompt text. | +
p-terminal-response | +Command response. | +
p-terminal-input | +Input element to enter commands. | +
None.
+Textarea is a multi-line text input element.
+
+import Textarea from 'primevue/textarea';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/textarea/textarea.min.js"></script>
+
+
+
+ A model can be bound using the standard v-model directive.
+
+<Textarea v-model="value" rows="5" cols="30" />
+
+
+
+ In auto resize mode, textarea grows instead of displaying a scrollbar.
+
+<Textarea v-model="value" :autoResize="true" rows="5" cols="30" />
+
+
+
+ Textarea passes any attribute to the underlying textarea element, additional attributes are the following.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
autoResize | +boolean | +false | +When present, height of textarea changes as being typed. | +
Any valid event such as focus, blur and input are passed to the underlying input element.
+ +Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-inputtextarea | +Textarea element | +
+ Textarea component renders a native textarea element that implicitly includes any passed prop. Value to describe the component can either be provided via label tag combined with id prop or using aria-labelledby, + aria-label props. +
+ +
+<label for="address1">Address 1</label>
+<Textarea id="address1" />
+
+<span id="address2">Address 2</span>
+<Textarea aria-labelledby="address2" />
+
+<Textarea aria-label="Address Details"/>
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the input. | +
None.
+Choose from a variety of themes or develop your own theme easily.
+ ++ 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 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. +
+ ++ PrimeVue offers various free themes and premium themes 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 CSS output of the theme whereas SCSS is kept as a premium feature in the designer. This means free themes are open source and for + customization with SASS, a designer license needs to be acquired. +
+ ++ 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 Material, Bootstrap, Tailwind, FluentUI, Saga, Vela, Arya and legacy themes whereas Designer provides full access to the whole SASS structure and the variables of these + pre-built themes for easier customization. In addition, designer provides exclusive premium themes to subscribers including Soho, Viva, Mira and Nano that are not available in core PrimeVue distribution. +
+ +Whether you have your own style guide or just need a custom theme, Designer API is the right tool to design and bring them to existence.
+ +Visit Designer API HomePage for more information and live demos.
+ ++ PrimeVue utilizes rem units to make sure the components blend in with the rest of your UI perfectly. This also enables scaling, for example changing the size of the components is easy as configuring the font size of your document. + Code below sets the scale of the components based on 16px. If you reqire bigger or smaller components, just change this variable and components will scale accordingly. +
+ +
+html {
+ font-size: 16px;
+}
+
+
+
+ Some commonly used components such as inputs, buttons and datatable also provide per component scaling with special classes. Components with specific scaling options are documented in their own documentation.
+
+<InputText type="text" class="p-inputtext-sm" />
+<Button label="Button" class="p-button-lg" />
+
+
+
+ + Theming styles the components globally, in case you required to change the style of a certain component for a specific use case use the class property and override the defaults. Example below changes the background of the panel. Note + that this is only for local styling, if you require to change the background color of all the panels, a custom theme is a far better choice. +
+
+<Panel header="Custom Header" class="dark-panel"/>
+
+
+
+
+<style lang="scss" scoped>
+::v-deep(.dark-panel.p-panel) {
+ .p-panel-titlebar {
+ background: #212121;
+ }
+
+}
+</style>
+
+
+
+ A couple of utility classes are provided as a solution to common requirements.
+ +Name | +Description | +
---|---|
p-component | +Applies component theming such as font-family and font-size to an element. | +
p-disabled | +Applies an opacity to display as disabled. | +
p-sr-only | +Element becomes visually hidden however accessibility is still available. | +
p-reset | +Resets the browsers defaults. | +
p-link | +Renders a button as a link. | +
p-error | +Indicates an error text. | +
p-invalid | +Styles an form element as invalid. | +
p-text-secondary | +Applies the text color of the theme with the secondary priority. | +
TieredMenu displays submenus in nested overlays.
+
+import TieredMenu from 'primevue/tieredmenu';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ TieredMenu uses the common MenuModel API to define the items, visit
TieredMenu requires a collection of menuitems as its model.
+
+<TieredMenu :model="items" />
+
+
+
+
+export default {
+ data() {
+ return {
+ items: [
+ {
+ label:'File',
+ icon:'pi pi-fw pi-file',
+ items:[
+ {
+ label:'New',
+ icon:'pi pi-fw pi-plus',
+ items:[
+ {
+ label:'Bookmark',
+ icon:'pi pi-fw pi-bookmark'
+ },
+ {
+ label:'Video',
+ icon:'pi pi-fw pi-video'
+ }
+ ]
+ },
+ {
+ label:'Delete',
+ icon:'pi pi-fw pi-trash'
+ },
+ {
+ separator:true
+ },
+ {
+ label:'Export',
+ icon:'pi pi-fw pi-external-link'
+ }
+ ]
+ },
+ {
+ label:'Edit',
+ icon:'pi pi-fw pi-pencil',
+ items:[
+ {
+ label:'Left',
+ icon:'pi pi-fw pi-align-left'
+ },
+ {
+ label:'Right',
+ icon:'pi pi-fw pi-align-right'
+ },
+ {
+ label:'Center',
+ icon:'pi pi-fw pi-align-center'
+ },
+ {
+ label:'Justify',
+ icon:'pi pi-fw pi-align-justify'
+ }
+ ]
+ },
+ {
+ label:'Users',
+ icon:'pi pi-fw pi-user',
+ items:[
+ {
+ label:'New',
+ icon:'pi pi-fw pi-user-plus',
+
+ },
+ {
+ label:'Delete',
+ icon:'pi pi-fw pi-user-minus',
+
+ },
+ {
+ label:'Search',
+ icon:'pi pi-fw pi-users',
+ items:[
+ {
+ label:'Filter',
+ icon:'pi pi-fw pi-filter',
+ items:[
+ {
+ label:'Print',
+ icon:'pi pi-fw pi-print'
+ }
+ ]
+ },
+ {
+ icon:'pi pi-fw pi-bars',
+ label:'List'
+ }
+ ]
+ }
+ ]
+ },
+ {
+ label:'Events',
+ icon:'pi pi-fw pi-calendar',
+ items:[
+ {
+ label:'Edit',
+ icon:'pi pi-fw pi-pencil',
+ items:[
+ {
+ label:'Save',
+ icon:'pi pi-fw pi-calendar-plus'
+ },
+ {
+ label:'Delete',
+ icon:'pi pi-fw pi-calendar-minus'
+ },
+ ]
+ },
+ {
+ label:'Archieve',
+ icon:'pi pi-fw pi-calendar-times',
+ items:[
+ {
+ label:'Remove',
+ icon:'pi pi-fw pi-calendar-minus'
+ }
+ ]
+ }
+ ]
+ },
+ {
+ separator:true
+ },
+ {
+ label:'Quit',
+ icon:'pi pi-fw pi-power-off'
+ }
+ ]
+ }
+ }
+}
+
+
+
+ TieredMenu is inline by default whereas popup mode is supported by enabling popup property and calling toggle method with an event of the target.
+ +
+<Button type="button" label="Toggle" @click="toggle" />
+<TieredMenu ref="menu" :model="items" :popup="true" />
+
+
+
+
+toggle(event) {
+ this.$refs.menu.toggle(event);
+}
+
+
+
+ TieredMenu offers content customization with the item template that receives the menuitem instance from the model as a parameter.
+
+<TieredMenu :model="items">
+ <template #item="{item}">
+ <a :href="item.url">{{item.label}}</a>
+ </template>
+</TieredMenu>
+
+
+
+ router-link with route configuration can also be used within templating for further customization.
+
+<TieredMenu :model="items">
+ <template #item="{item}">
+ <router-link :to="item.to" custom v-slot="{href, route, navigate, isActive, isExactActive}">
+ <a :href="href" @click="navigate" :class="{'active-link': isActive, 'active-link-exact": isExactActive}>{{route.fullPath}}</a>
+ </router-link>
+ </template>
+</TieredMenu>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
model | +array | +null | +An array of menuitems. | +
popup | +boolean | +false | +Defines if menu would displayed as a popup. | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
autoZIndex | +boolean | +true | +Whether to automatically manage layering. | +
exact | +boolean | +true | +Whether to apply 'router-link-active-exact' class if route exactly matches the item path. | +
Name | +Parameters | +Description | +
---|---|---|
toggle | +event: Browser event | +Toggles the visibility of the overlay. | +
show | +event: Browser event | +Shows the overlay. | +
hide | +- | +Hides the overlay. | +
Name | +Parameters | +
---|---|
item | +item: Menuitem instance | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-tieredmenu | +Container element. | +
p-submenu-list | +Submenu list element. | +
p-menuitem | +Menuitem element. | +
p-menuitem-active | +Active menuitem element. | +
p-menuitem-text | +Label of a menuitem. | +
p-menuitem-icon | +Icon of a menuitem. | +
p-submenu-icon | +Arrow icon of a submenu. | +
None.
+Timeline visualizes a series of chained events.
++ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, + cupiditate neque quas! +
+ + +
+import Timeline from 'primevue/timeline';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/timeline/timeline.min.js"></script>
+
+
+
+ + Timeline receives the events with the value property as a collection of arbitrary objects. In addition, content template is required to display the representation of an event. Example below is a sample events array that is + used throughout the documentation. +
+
+export default {
+ data() {
+ return {
+ events: [
+ {status: 'Ordered', date: '15/10/2020 10:30', icon: 'pi pi-shopping-cart', color: '#9C27B0', image: 'game-controller.jpg'},
+ {status: 'Processing', date: '15/10/2020 14:00', icon: 'pi pi-cog', color: '#673AB7'},
+ {status: 'Shipped', date: '15/10/2020 16:15', icon: 'pi pi-shopping-cart', color: '#FF9800'},
+ {status: 'Delivered', date: '16/10/2020 10:00', icon: 'pi pi-check', color: '#607D8B'}
+ ],
+ events2: [
+ "2020", "2021", "2022", "2023"
+ ]
+ }
+ }
+}
+
+
+
+
+<Timeline :value="events">
+ <template #content="slotProps">
+ {{slotProps.item.status}}
+ </template>
+</Timeline>
+
+
+
+ Default layout of the timeline is vertical, setting layout to "horizontal" displays the items horizontally.
+
+<Timeline :value="events" layout="horizontal>
+ <template #content="slotProps">
+ {{slotProps.item.status}}
+ </template>
+</Timeline>
+
+
+
+ Location of the timeline bar is defined using the align property.
+
+<Timeline :value="events" align="right">
+ <template #content="slotProps">
+ {{slotProps.item.status}}
+ </template>
+</Timeline>
+
+
+
+ In addition, the "alternate" alignment option make the contents take turns around the timeline bar.
+
+<Timeline :value="events" align="alternate">
+ <template #content="slotProps">
+ {{slotProps.item.status}}
+ </template>
+</Timeline>
+
+
+
+ Content to be placed at the other side of the bar is defined with the opposite template.
+
+<Timeline :value="events">
+ <template #opposite="slotProps">
+ <small class="p-text-secondary">{{slotProps.item.date}}</small>
+ </template>
+ <template #content="slotProps">
+ {{slotProps.item.status}}
+ </template>
+</Timeline>
+
+
+
+ marker template allows placing a custom event marker instead of the default one. Below is an example with custom markers and content.
+
+<Timeline :value="events" align="alternate" class="customized-timeline">
+ <template #marker="slotProps">
+ <span class="custom-marker shadow-2" :style="{backgroundColor: slotProps.item.color}">
+ <i :class="slotProps.item.icon"></i>
+ </span>
+ </template>
+ <template #content="slotProps">
+ <Card>
+ <template #title>
+ {{slotProps.item.status}}
+ </template>
+ <template #subtitle>
+ {{slotProps.item.date}}
+ </template>
+ <template #content>
+ <img v-if="slotProps.item.image" :src="'demo/images/product/' + slotProps.item.image" :alt="slotProps.item.name" width="200" class="shadow-2" />
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt
+ quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque quas!</p>
+ <Button label="Read more" class="p-button-text"></Button>
+ </template>
+ </Card>
+ </template>
+</Timeline>
+
+
+
+ + Connector is an element that binds two events together, use the connector slot to use your own element instead of the default one. If you just require to customize simple properties like the color and width, apply the + "p-timeline-event-connector" class to your element to use the built-in positioning. +
+
+<Timeline :value="events">
+ <template #content="slotProps">
+ {{slotProps.item.status}}
+ </template>
+ <template #connector>
+ <div class="p-timeline-event-connector" style="width:4px; color: blue"></div>
+ </template>
+</Timeline>
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
value | +array | +null | +An array of events to display. | +
align | +string | +left | +Position of the timeline bar relative to the content. Valid values are "left", "right" and "alternate" for vertical layout and "top", "bottom" for horizontal layout. | +
layout | +string | +vertical | +Orientation of the timeline, valid values are "vertical" and "horizontal". | +
dataKey | +string | +null | +Name of the field that uniquely identifies the a record in the data. | +
Name | +Parameters | +
---|---|
opposite | +
+ item: Position of the event + index: Index of the event + |
+
marker | +
+ item: Custom marker of the event + index: Index of the event + |
+
content | +
+ item: Content of the event + index: Index of the event + |
+
connector | +
+ item: Connector of the event + index: Index of the event + |
+
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-timeline | +Container element. | +
p-timeline-left | +Container element when alignment is left. | +
p-timeline-right | +Container element when alignment is right. | +
p-timeline-top | +Container element when alignment is top. | +
p-timeline-bottom | +Container element when alignment is bottom. | +
p-timeline-alternate | +Container element when alignment is alternating. | +
p-timeline-vertical | +Container element of a vertical timeline. | +
p-timeline-horizontal | +Container element of a horizontal timeline. | +
p-timeline-event | +Event element. | +
p-timeline-event-opposite | +Opposite of an event content. | +
p-timeline-event-content | +Event content. | +
p-timeline-event-separator | +Separator element of an event. | +
p-timeline-event-marker | +Marker element of an event. | +
p-timeline-event-connector | +Connector element of an event. | +
None.
+Toast is used to display messages in an overlay.
+{{ slotProps.message.detail }}
+Toast messages are dynamically created using a ToastService that needs to be installed globally before the application instance is created.
+
+import {createApp} from 'vue';
+import ToastService from 'primevue/toastservice';
+
+const app = createApp(App);
+app.use(ToastService);
+
+
+
+
+import Toast from 'primevue/toast';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/toast/toast.min.js"></script>
+
+
+
+ + Ideal location of a Toast is the main application template so that it can be used by any component within the application. A single message is represented by the Message interface in PrimeVue that defines various properties such as + severity, summary and detail. +
+ +
+<template>
+ <Toast />
+<template>
+
+
+
+ $toast is available as a property in the application instance.
+
+export default {
+ mounted() {
+ this.$toast.add({severity:'success', summary: 'Success Message', detail:'Order submitted', life: 3000});
+ }
+}
+
+
+
+ The toast instance can be injected with the useToast function.
+
+import { defineComponent } from "vue";
+import { useToast } from "primevue/usetoast";
+
+export default defineComponent({
+ setup() {
+ const toast = useToast();
+ toast.add({severity:'info', summary: 'Info Message', detail:'Message Content', life: 3000});
+ }
+})
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
severity | +string | +null | +Severity of the message. | +
summary | +element | +null | +Summary content of the message. | +
detail | +element | +null | +Detail content of the message. | +
closable | +boolean | +true | +Whether the message can be closed manually using the close icon. | +
life | +number | +null | +Delay in milliseconds to close the message automatically. Messages with no life defined becomes sticky. | +
group | +string | +null | +Key of the Toast to display the message. | +
styleClass | +string | +null | +Style class of the message. | +
contentStyleClass | +string | +null | +Style class of the content. | +
Name | +Parameters | +Description | +
---|---|---|
add | +message: Message instance | +Displays the message in a suitable Toast component. | +
removeGroup | +group: Name of the message group | +Clears the messages that belongs to the group. | +
removeAllGroup | +- | +Clears all the messages. | +
There are four possible values for the severity of a message. Info is the default.
+ ++ There are four positions available for the toast container defined by the position property that defaults to "top-right". Other valid values are "top-left", "top-center", "bottom-left", "bottom-center", "bottom-right" and "center". +
+
+<Toast />
+<Toast position="top-left" />
+<Toast position="top-center" />
+<Toast position="top-right" />
+<Toast position="center" />
+<Toast position="bottom-left" />
+<Toast position="bottom-center" />
+<Toast position="bottom-right" />
+
+
+
+ A message can be targeted to a specific Toast component if their group properties match. Messages without a group are forwarded to the default Toast component that does not have a group defined.
+ +
+<Toast />
+<Toast position="mykey" />
+
+
+
+
+this.$toast.add({severity:'success', summary: 'Default Message'});
+this.$toast.add({severity:'success', summary: 'Specific Message', group: 'mykey'});
+
+
+
+ removeGroup(group) clears the messages for a specific Toast whereas removeAllGroups() method clears all messages.
+ +Templating allows customizing the content where the message instance is available as the implicit variable.
+
+<Toast position="bottom-center" group="bc">
+ <template #message="slotProps">
+ <div class="flex flex-column">
+ <div class="text-center">
+ <i class="pi pi-exclamation-triangle" style="font-size: 3rem"></i>
+ <h4>{{slotProps.message.summary}}</h4>
+ <p>{{slotProps.message.detail}}</p>
+ </div>
+ <div class="grid p-fluid">
+ <div class="col-6">
+ <Button class="p-button-success" label="Yes" @click="onConfirm" />
+ </div>
+ <div class="col-6">
+ <Button class="p-button-secondary" label="No" @click="onReject" />
+ </div>
+ </div>
+ </div>
+ </template>
+</Toast>
+
+
+
+
+ + Toast styling can be adjusted per screen size with the breakpoints option. The value of breakpoints should be an object literal whose keys are the maximum screen sizes and values are the styles per screen. In example below, + width of the toast messages cover the whole page on screens whose widths is smaller than 921px. +
+
+<Toast :breakpoints="{'920px': {width: '100%', right: '0', left: '0'}}"></Toast>
+
+
+
+ ToastSeverity constants API is provided to easily choose a severity of the message with typescript.
+
+import {ToastSeverity} from 'primevue/api';
+
+export default {
+ methods: {
+ showInfo() {
+ this.$toast.add({severity: ToastSeverity.INFO, summary: 'Info Message', detail:'Message Content', life: 3000});
+ }
+ }
+}
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
group | +string | +null | +Unique identifier of a message group. | +
position | +string | +top-right | +Position of the toast in viewport. | +
autoZIndex | +boolean | +true | +Whether to automatically manage layering. | +
baseZIndex | +number | +0 | +Base zIndex value to use in layering. | +
breakpoints | +object | +null | +Object literal to define styles per screen size. | +
Name | +Parameters | +
---|---|
message | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-toast | +Main container element. | +
p-toast-message | +Container of a message item. | +
p-toast-icon-close | +Close icon of a message. | +
p-toast-icon | +Severity icon. | +
p-toast-message-content | +Container of message texts. | +
p-toast-summary | +Summary of the message. | +
p-toast-detail | +Detail of the message. | +
None.
+ToggleButton is used to select a boolean value using a button.
+
+import ToggleButton from 'primevue/togglebutton';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/togglebutton/togglebutton.min.js"></script>
+
+
+
+ Two-way binding to a boolean property is defined using the standard v-model directive.
+
+<ToggleButton v-model="checked" />
+
+
+
+ As model is two-way binding enabled, setting the bound value as true displays the state as checked.
+
+export default {
+ data() {
+ return {
+ checked: true
+ }
+ }
+}
+
+
+
+ Icons and Labels can be customized using onLabel, offLabel, onIcon and offIcon properties.
+
+<ToggleButton v-model="checked" onLabel="I confirm" offLabel="I reject" onIcon="pi pi-check" offIcon="pi pi-times" />
+
+
+
+ Any valid attribute is passed to the root element implicitly, extended properties are as follows;
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
onIcon | +string | +null | +Icon for the on state. | +
offIcon | +string | +null | +Icon for the off state. | +
onLabel | +string | +yes | +Label for the on state. | +
offLabel | +string | +no | +Label for the off state. | +
iconPos | +string | +left | +Position of the icon, valid values are "left" and "right". | +
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +
tabindex | +number | +null | +Index of the element in tabbing order. | +
inputId | +string | +null | +Style class of the component input field. | +
inputClass | +string | +null | +Style class of the input field. | +
inputStyle | +any | +null | +Inline style of the input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component. | +
Name | +Parameters | +Description | +
---|---|---|
change | +event: Browser event | +Callback to invoke on value change. | +
focus | +event: Browser event | +Callback to invoke when the component receives focus. | +
blur | +event: Browser event | +Callback to invoke when the component loses focus. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-togglebutton | +Container element | +
p-button-icon | +Icon element. | +
p-button-text | +Label element. | +
+ ToggleButton component uses an element with button role and updates aria-pressed state for screen readers. Value to describe the component can be defined with aria-labelledby or aria-label props, it is highly + suggested to use either of these props as the component changes the label displayed which will result in screen readers to read different labels when the component receives focus. To prevent this, always provide an aria label that does + not change related to state. +
+ +
+<span id="rememberme">Remember Me</span>
+<ToggleButton aria-labelledby="rememberme" />
+
+<ToggleButton aria-label="Remember Me" />
+
+
+
+ Keyboard interaction is derived from the native browser handling of checkboxs in a group.
+Key | +Function | +
---|---|
tab | +Moves focus to the button. | +
space | +Toggles the checked state. | +
None.
+Toolbar is a grouping component for buttons and other content.
+
+import Toolbar from 'primevue/toolbar';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/toolbar/toolbar.min.js"></script>
+
+
+
+ Toolbar provides start and end templates to place content at these sections.
+
+<Toolbar>
+ <template #start>
+ <Button label="New" icon="pi pi-plus" class="mr-2" />
+ <Button label="Upload" icon="pi pi-upload" class="p-button-success" />
+ <i class="pi pi-bars p-toolbar-separator mr-2" />
+ <SplitButton label="Save" icon="pi pi-check" :model="items" class="p-button-warning"></SplitButton>
+ </template>
+
+ <template #end>
+ <Button icon="pi pi-search" class="mr-2" />
+ <Button icon="pi pi-calendar" class="p-button-success mr-2" />
+ <Button icon="pi pi-times" class="p-button-danger" />
+ </template>
+</Toolbar>
+
+
+
+ Name | +Parameters | +
---|---|
start | +- | +
end | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-toolbar | +Main container element. | +
p-toolbar-group-left | +Left content container. | +
p-toolbar-group-right | +Right content container. | +
+ Toolbar uses toolbar role to the root element, aria-orientation is not included as it defaults to "horizontal". Any valid attribute is passed to the root element so you may add additional properties like + aria-labelledby to define the element if required. +
+ +Component does not include any interactive elements. Arbitrary content can be placed with templating and elements like buttons inside should follow the page tab sequence.
+None.
+Tooltip directive provides advisory information for a component.
+Tooltip is a directive that needs to be imported and configured with a name of your choice. Global configuration is done with the app.directive function.
+
+import Tooltip from 'primevue/tooltip';
+
+app.directive('tooltip', Tooltip);
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ Tooltip can also be configured locally using the directives property of your component.
+
+directives: {
+ 'tooltip': Tooltip
+}
+
+
+
+ Once the tooltip is configured, it can be attached to a target using the v- prefix.
+
+<InputText type="text" v-tooltip="'Enter your username'" />
+
+
+
+ Also, more than one value can be used.
+
+<InputText type="text" v-tooltip="{ value: 'Enter your username', disabled: true }" />
+
+
+
+ There are four choices to position the tooltip, default value is "right" and alternatives are "top", "bottom", "left". Position is specified using a modifier.
+
+<InputText type="text" v-tooltip.right="'Enter your username'" />
+<InputText type="text" v-tooltip.top="'Enter your username'" />
+<InputText type="text" v-tooltip.bottom="'Enter your username'" />
+<InputText type="text" v-tooltip.left="'Enter your username'" />
+
+
+
+ Tooltip gets displayed on hover event of its target by default, other option is the focus event to display and blur to hide.
+
+<InputText type="text" v-tooltip.focus="'Enter your username'" />
+
+
+
+ As seen in positions and event sections, tooltip is configured via modifiers that can be chained. Tooltip below, gets displayed at the top of the input at focus event.
+
+<InputText type="text" v-tooltip.top.focus="'Enter your username'" />
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
value | +string | +null | +Text of the tooltip | +
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +
class | +string | +null | +When present, it adds a custom class to the tooltip. | +
escape | +boolean | +false | +By default the tooltip contents are not rendered as text. Set to true to support html tags in the content. | +
fitContent | +boolean | +true | +Automatically adjusts the element position when there is not enough space on the selected position. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-tooltip | +Input element. | +
p-tooltip-arrow | +Arrow of the tooltip. | +
p-tooltip-text | +Text of the tooltip | +
None.
+Tree is used to display hierarchical data.
+
+import Tree from 'primevue/tree';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+ Tree component requires an array of TreeNode objects as its value.
+ +Name | +Type | +Default | +Description | +
---|---|---|---|
key | +any | +null | +Mandatory unique key of the node. | +
label | +string | +null | +Label of the node. | +
data | +any | +null | +Data represented by the node. | +
type | +string | +null | +Type of the node to match a template. | +
icon | +string | +null | +Icon of the node to display next to content. | +
expandedIcon | +string | +null | +Icon to use in expanded state. | +
collapsedIcon | +string | +null | +Icon to use in collapsed state. | +
children | +TreeNode[] | +null | +An array of treenodes as children. | +
style | +string | +null | +Inline style of the node. | +
styleClass | +string | +null | +Style class of the node. | +
selectable | +boolean | +null | +Whether the node is selectable when selection mode is enabled. | +
leaf | +boolean | +null | +Specifies if the node has children. Used in lazy loading. | +
Example below loads the tree nodes from a remote datasource via a service called NodeService.
+
+<Tree :value="nodes"></Tree>
+
+
+
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ nodes: null
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeNodes().then(data => this.nodes = data);
+ }
+}
+
+
+
+
+export default class NodeService {
+
+ getTreeNodes() {
+ return fetch('demo/data/treenodes.json').then(res => res.json())
+ .then(d => d.root);
+ }
+
+}
+
+
+
+ The json response sample would be as following.
+
+{
+ "root": [
+ {
+ "key": "0",
+ "label": "Documents",
+ "data": "Documents Folder",
+ "icon": "pi pi-fw pi-inbox",
+ "children": [{
+ "key": "0-0",
+ "label": "Work",
+ "data": "Work Folder",
+ "icon": "pi pi-fw pi-cog",
+ "children": [{ "key": "0-0-0", "label": "Expenses.doc", "icon": "pi pi-fw pi-file", "data": "Expenses Document" }, { "key": "0-0-1", "label": "Resume.doc", "icon": "pi pi-fw pi-file", "data": "Resume Document" }]
+ },
+ {
+ "key": "0-1",
+ "label": "Home",
+ "data": "Home Folder",
+ "icon": "pi pi-fw pi-home",
+ "children": [{ "key": "0-1-0", "label": "Invoices.txt", "icon": "pi pi-fw pi-file", "data": "Invoices for this month" }]
+ }]
+ },
+ {
+ "key": "1",
+ "label": "Events",
+ "data": "Events Folder",
+ "icon": "pi pi-fw pi-calendar",
+ "children": [
+ { "key": "1-0", "label": "Meeting", "icon": "pi pi-fw pi-calendar-plus", "data": "Meeting" },
+ { "key": "1-1", "label": "Product Launch", "icon": "pi pi-fw pi-calendar-plus", "data": "Product Launch" },
+ { "key": "1-2", "label": "Report Review", "icon": "pi pi-fw pi-calendar-plus", "data": "Report Review" }]
+ },
+ {
+ "key": "2",
+ "label": "Movies",
+ "data": "Movies Folder",
+ "icon": "pi pi-fw pi-star-fill",
+ "children": [{
+ "key": "2-0",
+ "icon": "pi pi-fw pi-star-fill",
+ "label": "Al Pacino",
+ "data": "Pacino Movies",
+ "children": [{ "key": "2-0-0", "label": "Scarface", "icon": "pi pi-fw pi-video", "data": "Scarface Movie" }, { "key": "2-0-1", "label": "Serpico", "icon": "pi pi-fw pi-video", "data": "Serpico Movie" }]
+ },
+ {
+ "key": "2-1",
+ "label": "Robert De Niro",
+ "icon": "pi pi-fw pi-star-fill",
+ "data": "De Niro Movies",
+ "children": [{ "key": "2-1-0", "label": "Goodfellas", "icon": "pi pi-fw pi-video", "data": "Goodfellas Movie" }, { "key": "2-1-1", "label": "Untouchables", "icon": "pi pi-fw pi-video", "data": "Untouchables Movie" }]
+ }]
+ }
+ ]
+}
+
+
+
+ + Tree state can be controlled programmatically with the expandedKeys property that defines the keys that are expanded. This property is a Map instance whose key is the key of a node and value is a boolean. Note that + expandedKeys also supports two-way binding with the v-model directive. +
+ +Example below expands and collapses all nodes with buttons.
+
+<div>
+ <Button type="button" icon="pi pi-plus" label="Expand All" @click="expandAll" />
+ <Button type="button" icon="pi pi-minus" label="Collapse All" @click="collapseAll" />
+</div>
+<Tree :value="nodes" :expandedKeys="expandedKeys"></Tree>
+
+
+
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ nodes: null,
+ expandedKeys: {}
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeNodes().then(data => this.nodes = data);
+ },
+ methods: {
+ expandAll() {
+ for (let node of this.nodes) {
+ this.expandNode(node);
+ }
+
+ this.expandedKeys = {...this.expandedKeys};
+ },
+ collapseAll() {
+ this.expandedKeys = {};
+ },
+ expandNode(node) {
+ this.expandedKeys[node.key] = true;
+ if (node.children && node.children.length) {
+ for (let child of node.children) {
+ this.expandNode(child);
+ }
+ }
+ }
+ }
+}
+
+
+
+ To display some nodes as expanded by default, simply add their keys to the map.
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ nodes: null,
+ expandedKeys: {}
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeNodes().then(data => {
+ this.nodes = data;
+ this.expandedKeys[this.nodes[0].key] = true;
+ this.expandedKeys[this.nodes[1].key] = true;
+ });
+ }
+}
+
+
+
+ + Tree supports single, multiple and checkbox selection modes. Define the selectionKeys with the v-model directive and the selectionMode properties to enable the selection. By default in multiple selection + mode, metaKey is necessary to add to existing selections however this can be configured with metaKeySelection property. Note that in touch enabled devices, Tree does not require metaKey. In addition selection on a particular node + can be disabled if the selectable is false on the node instance. +
+ ++ Similarly to the expandedKeys, selectionKeys is a Map instance whose key is the key of a node and value is a boolean in "single" and "multiple" cases. On the other hand in "checkbox" mode, instead of a boolean, value should + be an object that has "checked" and "partialChecked" properties to represent the checked state of a node. +
+
+<h3>Single Selection</h3>
+<Tree :value="nodes" selectionMode="single" v-model:selectionKeys="selectedKey1"></Tree>
+
+<h3>Multiple Selection with MetaKey</h3>
+<Tree :value="nodes" selectionMode="multiple" v-model:selectionKeys="selectedKeys1"></Tree>
+
+<h3>Multiple Selection without MetaKey</h3>
+<Tree :value="nodes" selectionMode="multiple" v-model:selectionKeys="selectedKeys2" :metaKeySelection="false"></Tree>
+
+<h3>Checkbox Selection</h3>
+<Tree :value="nodes" selectionMode="checkbox" v-model:selectionKeys="selectedKeys3"></Tree>
+
+<h3>Events</h3>
+<Tree :value="nodes" selectionMode="single" v-model:selectionKeys="selectedKey2" :metaKeySelection="false"
+ @node-select="onNodeSelect" @node-unselect="onNodeUnselect"></Tree>
+
+
+
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ selectedKey1: null,
+ selectedKey2: null,
+ selectedKeys1: null,
+ selectedKeys2: null,
+ selectedKeys3: null,
+ nodes: null
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeNodes().then(data => this.nodes = data);
+ },
+ methods: {
+ onNodeSelect(node) {
+ this.$toast.add({severity:'success', summary: 'Node Selected', detail: node.label, life: 3000});
+ },
+ onNodeUnselect(node) {
+ this.$toast.add({severity:'success', summary: 'Node Unselected', detail: node.label, life: 3000});
+ }
+ }
+}
+
+
+
+ To display some nodes as selected by default, simply add their keys to the map.
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ selectedKey1: null,
+ selectedKey2: null,
+ selectedKeys1: null,
+ selectedKeys2: null,
+ selectedKeys3: null,
+ nodes: null
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeNodes().then(data => {
+ this.nodes = data;
+
+ //single preselection
+ this.selectedKey1[this.nodes[0].key] = true;
+
+ //multiple preselection
+ this.selectedKeys2[this.nodes[0].key] = true;
+ this.selectedKeys2[this.nodes[1].key] = true;
+
+ //checkbox preselection
+ this.selectedKeys2[this.nodes[1].key] = {checked: true};
+ });
+ }
+}
+
+
+
+ + Lazy Loading is handy to deal with huge datasets. Idea is instead of loading the whole tree, load child nodes on demand using expand expand. The important part is setting leaf to true on a node instance so that even without + children, tree would render an expand icon. Example below uses an in memory collection to mimic a lazy loading scenario with timeouts. +
+ +
+<Tree :value="nodes" @node-expand="onNodeExpand" :loading="loading"></Tree>
+
+
+
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ loading: false,
+ nodes: null
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.loading = true;
+
+ setTimeout(() => {
+ this.nodes = this.initateNodes();
+ this.loading = false;
+ }, 2000);
+ },
+ methods: {
+ onNodeExpand(node) {
+ if (!node.children) {
+ this.loading = true;
+
+ setTimeout(() => {
+ let _node = {...node};
+ _node.children = [];
+
+ for (let i = 0; i < 3; i++) {
+ _node.children.push({
+ key: node.key + '-' + i,
+ label: 'Lazy ' + node.label + '-' + i
+ });
+ }
+
+ let _nodes = {...this.nodes}
+ _nodes[parseInt(node.key, 10)] = _node;
+
+ this.nodes = _nodes;
+ this.loading = false;
+ }, 500);
+ }
+ },
+ initateNodes() {
+ return [{
+ key: '0',
+ label: 'Node 0',
+ leaf: false
+ },
+ {
+ key: '1',
+ label: 'Node 1',
+ leaf: false
+ },
+ {
+ key: '2',
+ label: 'Node 2',
+ leaf: false
+ }];
+ }
+ }
+}
+
+
+
+ The type property of a TreeNode is used to map a template to a node to create the node label. If it is undefined and no default template is available, label of the node is used.
+
+<Tree :value="nodes">
+ <template #default="slotProps">
+ <b>{{slotProps.node.label}}</b>
+ </template>
+ <template #url="slotProps">
+ <a :href="slotProps.node.data">{{slotProps.node.label}}</a>
+ </template>
+</Tree>
+
+
+
+
+export default {
+ data() {
+ return {
+ nodes: [
+ {
+ key: '0',
+ label: 'Introduction',
+ children: [
+ {key: '0-0', label: 'What is Vue.js?', data:'https://vuejs.org/v2/guide/#What-is-Vue-js', type: 'url'},
+ {key: '0-1', label: 'Getting Started', data: 'https://vuejs.org/v2/guide/#Getting-Started', type: 'url'},
+ {key: '0-2', label: 'Declarative Rendering', data:'https://vuejs.org/v2/guide/#Declarative-Rendering', type: 'url'},
+ {key: '0-3', label: 'Conditionals and Loops', data: 'https://vuejs.org/v2/guide/#Conditionals-and-Loops', type: 'url'}
+ ]
+ },
+ {
+ key: '1',
+ label: 'Components In-Depth',
+ children: [
+ {key: '1-0', label: 'Component Registration', data: 'https://vuejs.org/v2/guide/components-registration.html', type: 'url'},
+ {key: '1-1', llabel: 'Props', data: 'https://vuejs.org/v2/guide/components-props.html', type: 'url'},
+ {key: '1-2', llabel: 'Custom Events', data: 'https://vuejs.org/v2/guide/components-custom-events.html', type: 'url'},
+ {key: '1-3', llabel: 'Slots', data: 'https://vuejs.org/v2/guide/components-slots.html', type: 'url'}
+ ]
+ }
+ ]
+ }
+ }
+}
+
+
+
+ Scrolling is used to preserve space as content of the tree is dynamic and enabled by scrollHeight property.
+
+<Tree :value="nodes1" scrollHeight="200px"></Tree>
+
+
+
+ + In cases where viewport should adjust itself according to the table parent's height instead of a fixed viewport height, set scrollHeight option as flex. In example below, table is inside a Dialog where viewport size + dynamically responds to the dialog size changes such as maximizing. +
+ +
+<Button type="button" icon="pi pi-external-link" label="View" @click="dialogVisible = true"></Button>
+
+<Dialog header="Flex Scroll" v-model:visible="dialogVisible" :style="{width: '50vw'}" maximizable
+ :contentStyle="{height: '300px'}" class="p-fluid">
+ <Tree :value="nodes2" scrollHeight="flex"></Tree>
+ <template #footer>
+ <Button type="button" icon="pi pi-check" @click="dialogVisible = false" class="p-button-text"></Button>
+ </template>
+</Dialog>
+
+
+
+ + Filtering is enabled by setting the filter property to true, by default label property of a node is used to compare against the value in the text field, in order to customize which field(s) should be used during search, define the + filterBy property as a comma separated list. +
+ ++ In addition filterMode specifies the filtering strategy. In lenient mode when the query matches a node, children of the node are not searched further as all descendants of the node are included. On the other hand, in + strict mode when the query matches a node, filtering continues on all descendants. +
+ +
+<h3>Lenient Filter</h3>
+<Tree :value="nodes" :filter="true" filterMode="lenient"></Tree>
+
+<h3>Strict Filter</h3>
+<Tree :value="nodes" :filter="true" filterMode="strict"></Tree>
+
+
+
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ nodes: null,
+ expandedKeys: {}
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeNodes().then(data => this.nodes = data);
+ },
+ methods: {
+ expandAll() {
+ for (let node of this.nodes) {
+ this.expandNode(node);
+ }
+
+ this.expandedKeys = {...this.expandedKeys};
+ },
+ collapseAll() {
+ this.expandedKeys = {};
+ },
+ expandNode(node) {
+ if (node.children << node.children.length) {
+ this.expandedKeys[node.key] = true;
+
+ for (let child of node.children) {
+ this.expandNode(child);
+ }
+ }
+ }
+ }
+}
+
+
+
+ Any property such as style and class are passed to the underlying root element. Following is the additional property to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
value | +array | +null | +An array of treenodes. | +
expandedKeys | +array | +null | +A map of keys to represent the expansion state in controlled mode. | +
selectionMode | +string | +null | +Defines the selection mode, valid values "single", "multiple", and "checkbox". | +
selectionKeys | +any | +null | +A map of keys to control the selection state. | +
metaKeySelection | +boolean | +true | ++ Defines how multiple items can be selected, when true metaKey needs to be pressed to select or unselect an item and when set to false selection of each item can be toggled individually. On touch enabled devices, + metaKeySelection is turned off automatically. + | +
loading | +boolean | +false | +Whether to display loading indicator. | +
loadingIcon | +string | +pi pi-spin | +Icon to display when tree is loading. | +
filter | +boolean | +false | +When specified, displays an input field to filter the items. | +
filterBy | +string | +label | +When filtering is enabled, filterBy decides which field or fields (comma separated) to search against. | +
filterMode | +string | +lenient | +Mode for filtering valid values are "lenient" and "strict". Default is lenient. | +
filterPlaceholder | +string | +null | +Placeholder text to show when filter input is empty. | +
filterLocale | +string | +undefined | +Locale to use in filtering. The default locale is the host environment's current locale. | +
scrollHeight | +string | +null | +Height of the scroll viewport in fixed units or the "flex" keyword for a dynamic size. | +
Name | +Parameters | +Description | +
---|---|---|
node-select | +node: Node instance | +Callback to invoke when a node is selected. | +
node-unselect | +node: Node instance | +Callback to invoke when a node is unselected. | +
node-expand | +node: Node instance | +Callback to invoke when a node is expanded. | +
node-collapse | +node: Node instance | +Callback to invoke when a node is collapsed. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-tree | +Main container element | +
p-tree-horizontal | +Main container element in horizontal mode | +
p-tree-container | +Container of nodes | +
p-treenode | +A treenode element | +
p-treenode-content | +Content of a treenode | +
p-treenode-toggler | +Toggle element | +
p-treenode-toggler-icon | +Toggle icon | +
p-treenode-icon | +Icon of a treenode | +
p-treenode-label | +Label of a treenode | +
p-treenode-children | +Container element for node children | +
None.
+Filtering updates the node based on the constraints.
+Lazy loading is handy when dealing with huge datasets. This example imitates a lazy loading case with timeouts.
+Scrolling is used to preserve space in cases when rendering large data.
+Scrollable viewport is fixed.
++ Flex scroll feature makes the scrollable viewport section dynamic so that it can grow or shrink relative to the parent size of the tree. Click the button below to display maximizable Dialog where data viewport adjusts itself + according to the size changes. +
+ + + +Tree supports single, multiple and checkbox as selection modes.
+Tree is used to display hierarchical data.
+
+import TreeSelect from 'primevue/treeselect';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/treeselect/treeselect.min.js"></script>
+
+
+
+ TreeSelect component requires an array of TreeNode objects as its options and keys of the nodes as its value.
+ +
+<TreeSelect v-model="selectedNodeKey" :options="nodes" placeholder="Select Item" />
+
+
+
+ In example below, nodes are retrieved from a remote data source.
+ +
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ selectedNodeKey: null,
+ nodes: null
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeNodes().then(data => this.nodes = data);
+ }
+}
+
+
+
+
+export default class NodeService {
+
+ getTreeNodes() {
+ return fetch('demo/data/treenodes.json').then(res => res.json())
+ .then(d => d.root);
+ }
+
+}
+
+
+
+ The json response sample would be as following.
+
+{
+ "root": [
+ {
+ "key": "0",
+ "label": "Documents",
+ "data": "Documents Folder",
+ "icon": "pi pi-fw pi-inbox",
+ "children": [{
+ "key": "0-0",
+ "label": "Work",
+ "data": "Work Folder",
+ "icon": "pi pi-fw pi-cog",
+ "children": [{ "key": "0-0-0", "label": "Expenses.doc", "icon": "pi pi-fw pi-file", "data": "Expenses Document" }, { "key": "0-0-1", "label": "Resume.doc", "icon": "pi pi-fw pi-file", "data": "Resume Document" }]
+ },
+ {
+ "key": "0-1",
+ "label": "Home",
+ "data": "Home Folder",
+ "icon": "pi pi-fw pi-home",
+ "children": [{ "key": "0-1-0", "label": "Invoices.txt", "icon": "pi pi-fw pi-file", "data": "Invoices for this month" }]
+ }]
+ },
+ {
+ "key": "1",
+ "label": "Events",
+ "data": "Events Folder",
+ "icon": "pi pi-fw pi-calendar",
+ "children": [
+ { "key": "1-0", "label": "Meeting", "icon": "pi pi-fw pi-calendar-plus", "data": "Meeting" },
+ { "key": "1-1", "label": "Product Launch", "icon": "pi pi-fw pi-calendar-plus", "data": "Product Launch" },
+ { "key": "1-2", "label": "Report Review", "icon": "pi pi-fw pi-calendar-plus", "data": "Report Review" }]
+ },
+ {
+ "key": "2",
+ "label": "Movies",
+ "data": "Movies Folder",
+ "icon": "pi pi-fw pi-star-fill",
+ "children": [{
+ "key": "2-0",
+ "icon": "pi pi-fw pi-star-fill",
+ "label": "Al Pacino",
+ "data": "Pacino Movies",
+ "children": [{ "key": "2-0-0", "label": "Scarface", "icon": "pi pi-fw pi-video", "data": "Scarface Movie" }, { "key": "2-0-1", "label": "Serpico", "icon": "pi pi-fw pi-video", "data": "Serpico Movie" }]
+ },
+ {
+ "key": "2-1",
+ "label": "Robert De Niro",
+ "icon": "pi pi-fw pi-star-fill",
+ "data": "De Niro Movies",
+ "children": [{ "key": "2-1-0", "label": "Goodfellas", "icon": "pi pi-fw pi-video", "data": "Goodfellas Movie" }, { "key": "2-1-1", "label": "Untouchables", "icon": "pi pi-fw pi-video", "data": "Untouchables Movie" }]
+ }]
+ }
+ ]
+}
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
key | +any | +null | +Mandatory unique key of the node. | +
label | +string | +null | +Label of the node. | +
data | +any | +null | +Data represented by the node. | +
type | +string | +null | +Type of the node to match a template. | +
icon | +string | +null | +Icon of the node to display next to content. | +
children | +TreeNode[] | +null | +An array of treenodes as children. | +
style | +string | +null | +Inline style of the node. | +
styleClass | +string | +null | +Style class of the node. | +
selectable | +boolean | +null | +Whether the node is selectable when selection mode is enabled. | +
leaf | +boolean | +null | +Specifies if the node has children. Used in lazy loading. | +
TreeSelects offers "single", "multiple" and "checkbox" alternatives for the selection behavior that is defined by the selectionMode option.
+
+<TreeSelect v-model="selectedValue1" :options="nodes" selectionMode="single" placeholder="Select Item" />
+
+<TreeSelect v-model="selectedValue2" :options="nodes" selectionMode="multiple" placeholder="Select Items" />
+
+<TreeSelect v-model="selectedValue3" :options="nodes" selectionMode="checkbox" placeholder="Select Items" />
+
+
+
+ + Value passed to and from the TreeSelect via the v-model directive should be a an object with key-value pairs where key is the node key and value is a boolean to indicate selection. On the other hand in "checkbox" mode, instead of a + boolean, value should be an object that has "checked" and "partialChecked" properties to represent the checked state of a node. Best way to clarify it is prepopulating a TreeSelect with an existing value. +
+ +
+data() {
+ return {
+ selectedValue1: {'2-1': true},
+ selectedValue2: {'1-1': true, '0-0-0': true},
+ selectedValue2: {'1': {checked: true, partialChecked: true}, '1-0': {checked: true}}
+ nodes: null
+ }
+},
+
+
+ A comma separated list is used by default to display selected items whereas alternative chip mode is provided using the display property to visualize the items as tokens.
+
+<TreeSelect v-model="selectedValue" display="chip" :options="nodes" selectionMode="multiple" placeholder="Select Items" />
+
+
+
+ + Label of an option is used as the display text of an item by default, for custom content support define a value template that gets the selected nodes as a parameter. In addition header, footer and empty slots + are provided for further customization. +
+
+<TreeSelect v-model="selectedNodes" :options="nodes" placeholder="Select Items">
+ <template #value="{value}">
+ Custom Content
+ </template>
+</TreeSelect>
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +any | +null | +Value of the component. | +
options | +array | +null | +An array of treenodes. | +
scrollHeight | +string | +200px | +Height of the viewport, a scrollbar is defined if height of list exceeds this value. | +
placeholder | +string | +null | +Label to display when there are no selections. | +
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +
tabindex | +string | +null | +Index of the element in tabbing order. | +
selectionMode | +string | +null | +Defines the selection mode, valid values "single", "multiple", and "checkbox". | +
appendTo | +string | +body | +A valid query selector or an HTMLElement to specify where the overlay gets attached. Special keywords are "body" for document body and "self" for the element itself. | +
emptyMessage | +string | +No results found | +Text to display when there are no options available. Defaults to value from PrimeVue locale configuration. | +
display | +string | +comma | +Defines how the selected items are displayed, valid values are "comma" and "chip". | +
metaKeySelection | +boolean | +true | ++ Defines how multiple items can be selected, when true metaKey needs to be pressed to select or unselect an item and when set to false selection of each item can be toggled individually. On touch enabled devices, + metaKeySelection is turned off automatically. + | +
inputId | +string | +null | +Identifier of the underlying input element. | +
inputClass | +string | +null | +Style class of the input field. | +
inputStyle | +any | +null | +Inline style of the input field. | +
panelClass | +string | +null | +Style class of the overlay panel. | +
Name | +Parameters | +Description | +
---|---|---|
change | +event: Selected node keys | +Callback to invoke on value change. | +
before-show | +- | +Callback to invoke before the overlay is shown. | +
before-hide | +- | +Callback to invoke before the overlay is hidden. | +
show | +- | +Callback to invoke when the overlay is shown. | +
hide | +- | +Callback to invoke when the overlay is hidden. | +
node-select | +node: Node instance | +Callback to invoke when a node is selected. | +
node-unselect | +node: Node instance | +Callback to invoke when a node is unselected. | +
node-expand | +node: Node instance | +Callback to invoke when a node is expanded. | +
node-collapse | +node: Node instance | +Callback to invoke when a node is collapsed. | +
Name | +Parameters | +Description | +
---|---|---|
show | +- | +Shows the overlay. | +
hide | +- | +Hides the overlay. | +
Name | +Parameters | +
---|---|
value | +
+ value: Selected nodes + placeholder: Placeholder value + |
+
header | +
+ value: Value of the component + options: TreeNode options + |
+
footer | +
+ value: Value of the component + options: TreeNode options + |
+
empty | +- | +
indicator | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-treeselect | +Container element. | +
p-treeselect-label-container | +Container of the label to display selected items. | +
p-treeselect-label | +Label to display selected items. | +
p-treeselect-trigger | +Dropdown button. | +
p-treeselect-panel | +Overlay panel for items. | +
p-treeselect-items-wrapper | +List container of items. | +
+ Value to describe the component can either be provided with aria-labelledby or aria-label props. The treeselect element has a combobox role in addition to aria-haspopup and aria-expanded attributes. + The relation between the combobox and the popup is created with aria-controls that refers to the id of the popup. +
++ The popup list has an id that refers to the aria-controls attribute of the combobox element and uses tree as the role. Each list item has a treeitem role along with aria-label, + aria-selected and aria-expanded attributes. In checkbox selection, aria-checked is used instead of aria-selected. Checkbox and toggle icons are hidden from screen readers as their parent element with + treeitem role and attributes are used instead for readers and keyboard support. The container element of a treenode has the group role. The aria-setsize, aria-posinset and aria-level attributes are + calculated implicitly and added to each treeitem. +
+ +
+<span id="dd1">Options</span>
+<TreeSelect aria-labelledby="dd1" />
+
+<TreeSelect aria-label="Options" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the treeselect element. | +
space | +Opens the popup and moves visual focus to the selected treenode, if there is none then first treenode receives the focus. | +
down arrow | +Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. | +
Key | +Function | +
---|---|
tab | +Moves focus to the next focusable element in the popup, if there is none then first focusable element receives the focus. | +
shift + tab | +Moves focus to the previous focusable element in the popup, if there is none then last focusable element receives the focus. | +
enter | +Selects the focused option, closes the popup if selection mode is single. | +
space | +Selects the focused option, closes the popup if selection mode is single. | +
escape | +Closes the popup, moves focus to the treeselect element. | +
down arrow | +Moves focus to the next treenode. | +
up arrow | +Moves focus to the previous treenode. | +
right arrow | +If node is closed, opens the node otherwise moves focus to the first child node. | +
left arrow | +If node is open, closes the node otherwise moves focus to the parent node. | +
None.
+TreeSelect is a form component to choose from hierarchical data.
++ Columns can be resized using drag drop by setting the resizableColumns to true. There are two resize modes; "fit" and "expand". Fit is the default one and the overall table width does not change when a column is resized. In + "expand" mode, table width also changes along with the column width. +
+MultiSelect component can be used to implement column toggle functionality.
+TreeTable is used to display hierarchical data in tabular format.
+
+import TreeTable from 'primevue/treetable';
+import Column from 'primevue/column';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/treetable/treetable.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/column/column.min.js"></script>
+
+
+
+ Tree component requires an array of TreeNode objects as its value and columns defined with Column component.
+ +Name | +Type | +Default | +Description | +
---|---|---|---|
key | +any | +null | +Mandatory unique key of the node. | +
data | +any | +null | +Data represented by the node. | +
children | +TreeNode[] | +null | +An array of treenodes as children. | +
style | +string | +null | +Inline style of the node. | +
styleClass | +string | +null | +Style class of the node. | +
leaf | +boolean | +null | +Specifies if the node has children. Used in lazy loading. | +
Example below loads the nodes from a remote datasource via a service called NodeService.
+
+<TreeTable :value="nodes">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+
+
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ nodes: null
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeTableNodes().then(data => this.nodes = data);
+ }
+}
+
+
+
+
+export default class NodeService {
+
+ getTreeTableNodes() {
+ return fetch('demo/data/treetablenodes.json').then(res => res.json())
+ .then(d => d.root);
+ }
+
+}
+
+
+
+ The json response sample would be as following.
+ +
+{
+ "root":
+ [
+ {
+ "key": "0",
+ "data":{
+ "name":"Applications",
+ "size":"100kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "0-0",
+ "data":{
+ "name":"Vue",
+ "size":"25kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "0-0-0",
+ "data":{
+ "name":"Vue.app",
+ "size":"10kb",
+ "type":"Application"
+ }
+ },
+ {
+ "key": "0-0-1",
+ "data":{
+ "name":"native.app",
+ "size":"10kb",
+ "type":"Application"
+ }
+ },
+ {
+ "key": "0-0-2",
+ "data":{
+ "name":"mobile.app",
+ "size":"5kb",
+ "type":"Application"
+ }
+ }
+ ]
+ },
+ {
+ "key": "0-1",
+ "data":{
+ "name":"editor.app",
+ "size":"25kb",
+ "type":"Application"
+ }
+ },
+ {
+ "key": "0-2",
+ "data":{
+ "name":"settings.app",
+ "size":"50kb",
+ "type":"Application"
+ }
+ }
+ ]
+ },
+ {
+ "key": "1",
+ "data":{
+ "name":"Cloud",
+ "size":"20kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "1-0",
+ "data":{
+ "name":"backup-1.zip",
+ "size":"10kb",
+ "type":"Zip"
+ }
+ },
+ {
+ "key": "1-1",
+ "data":{
+ "name":"backup-2.zip",
+ "size":"10kb",
+ "type":"Zip"
+ }
+ }
+ ]
+ },
+ {
+ "key": "2",
+ "data": {
+ "name":"Desktop",
+ "size":"150kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "2-0",
+ "data":{
+ "name":"note-meeting.txt",
+ "size":"50kb",
+ "type":"Text"
+ }
+ },
+ {
+ "key": "2-1",
+ "data":{
+ "name":"note-todo.txt",
+ "size":"100kb",
+ "type":"Text"
+ }
+ }
+ ]
+ },
+ {
+ "key": "3",
+ "data":{
+ "name":"Documents",
+ "size":"75kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "3-0",
+ "data":{
+ "name":"Work",
+ "size":"55kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "3-0-0",
+ "data":{
+ "name":"Expenses.doc",
+ "size":"30kb",
+ "type":"Document"
+ }
+ },
+ {
+ "key": "3-0-1",
+ "data":{
+ "name":"Resume.doc",
+ "size":"25kb",
+ "type":"Resume"
+ }
+ }
+ ]
+ },
+ {
+ "key": "3-1",
+ "data":{
+ "name":"Home",
+ "size":"20kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "3-1-0",
+ "data":{
+ "name":"Invoices",
+ "size":"20kb",
+ "type":"Text"
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "key": "4",
+ "data": {
+ "name":"Downloads",
+ "size":"25kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "4-0",
+ "data": {
+ "name":"Spanish",
+ "size":"10kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "4-0-0",
+ "data":{
+ "name":"tutorial-a1.txt",
+ "size":"5kb",
+ "type":"Text"
+ }
+ },
+ {
+ "key": "4-0-1",
+ "data":{
+ "name":"tutorial-a2.txt",
+ "size":"5kb",
+ "type":"Text"
+ }
+ }
+ ]
+ },
+ {
+ "key": "4-1",
+ "data":{
+ "name":"Travel",
+ "size":"15kb",
+ "type":"Text"
+ },
+ "children":[
+ {
+ "key": "4-1-0",
+ "data":{
+ "name":"Hotel.pdf",
+ "size":"10kb",
+ "type":"PDF"
+ }
+ },
+ {
+ "key": "4-1-1",
+ "data":{
+ "name":"Flight.pdf",
+ "size":"5kb",
+ "type":"PDF"
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "key": "5",
+ "data": {
+ "name":"Main",
+ "size":"50kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "5-0",
+ "data":{
+ "name":"bin",
+ "size":"50kb",
+ "type":"Link"
+ }
+ },
+ {
+ "key": "5-1",
+ "data":{
+ "name":"etc",
+ "size":"100kb",
+ "type":"Link"
+ }
+ },
+ {
+ "key": "5-2",
+ "data":{
+ "name":"var",
+ "size":"100kb",
+ "type":"Link"
+ }
+ }
+ ]
+ },
+ {
+ "key": "6",
+ "data":{
+ "name":"Other",
+ "size":"5kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "6-0",
+ "data":{
+ "name":"todo.txt",
+ "size":"3kb",
+ "type":"Text"
+ }
+ },
+ {
+ "key": "6-1",
+ "data":{
+ "name":"logo.png",
+ "size":"2kb",
+ "type":"Picture"
+ }
+ }
+ ]
+ },
+ {
+ "key": "7",
+ "data":{
+ "name":"Pictures",
+ "size":"150kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "7-0",
+ "data":{
+ "name":"barcelona.jpg",
+ "size":"90kb",
+ "type":"Picture"
+ }
+ },
+ {
+ "key": "7-1",
+ "data":{
+ "name":"primevue.png",
+ "size":"30kb",
+ "type":"Picture"
+ }
+ },
+ {
+ "key": "7-2",
+ "data":{
+ "name":"prime.jpg",
+ "size":"30kb",
+ "type":"Picture"
+ }
+ }
+ ]
+ },
+ {
+ "key": "8",
+ "data":{
+ "name":"Videos",
+ "size":"1500kb",
+ "type":"Folder"
+ },
+ "children":[
+ {
+ "key": "8-0",
+ "data":{
+ "name":"primefaces.mkv",
+ "size":"1000kb",
+ "type":"Video"
+ }
+ },
+ {
+ "key": "8-1",
+ "data":{
+ "name":"intro.avi",
+ "size":"500kb",
+ "type":"Video"
+ }
+ }
+ ]
+ }
+ ]
+}
+
+
+ Column components can be dynamically generated using a v-for as well.
+ +
+<TreeTable :value="nodes">
+ <Column v-for="col of columns" :key="col.field"
+ :field="col.field" :header="col.header" :expander="col.expander"></Column>
+</TreeTable>
+
+
+
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ nodes: null,
+ columns: null
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+
+ this.columns = [
+ {field: 'name', header: 'Vin', expander: true},
+ {field: 'size', header: 'Size'},
+ {field: 'type', header: 'Type'}
+ ];
+ },
+ mounted() {
+ this.nodeService.getTreeTableNodes().then(data => this.nodes = data);
+ }
+}
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
columnKey | +any | +null | +Identifier of a column if field property is not defined. | +
expander | +boolean | +false | +Whether the column would display a toggle icon. | +
field | +string | +null | +Property name or a getter function of a row data. | +
sortField | +string | +null | +Property name or a getter function of a row data used for sorting, defaults to field. | +
sortable | +any | +false | +Defines if a column is sortable. | +
header | +any | +null | +Header content of the column. | +
footer | +any | +null | +Footer content of the column. | +
headerStyle | +object | +null | +Inline style of the column. | +
headerClass | +string | +null | +Style class of the column. | +
bodyStyle | +object | +null | +Inline style of the column. | +
bodyClass | +string | +null | +Style class of the column. | +
footerStyle | +object | +null | +Inline style of the column. | +
footerClass | +string | +null | +Style class of the column. | +
filterHeaderStyle | +object | +null | +Inline style of the column filter header. | +
filterHeaderClass | +string | +null | +Style class of the column filter header. | +
filterMatchMode | +string | +startsWith | +Defines filterMatchMode; "startsWith", "contains", "endsWidth", "equals", "notEquals", "in" and "custom". | +
excludeGlobalFilter | +boolean | +false | +Whether to exclude from global filtering or not. | +
hidden | +boolean | +false | +Whether the column is rendered. | +
+ Tree state can be controlled programmatically with the expandedKeys property that defines the keys that are expanded. This property is a Map instance whose key is the key of a node and value is a boolean. Note that + expandedKeys also supports two-way binding with the v-model directive. +
+ +Example below expands and collapses all nodes with buttons.
+
+<div style="margin-bottom: 1em">
+ <Button type="button" icon="pi pi-plus" label="Expand All" @click="expandAll" />
+ <Button type="button" icon="pi pi-minus" label="Collapse All" @click="collapseAll" />
+</div>
+<TreeTable :value="nodes" :expandedKeys="expandedKeys">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+
+
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ nodes: null,
+ expandedKeys: {}
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeTableNodes().then(data => this.nodes = data);
+ },
+ methods: {
+ expandAll() {
+ for (let node of this.nodes) {
+ this.expandNode(node);
+ }
+
+ this.expandedKeys = {...this.expandedKeys};
+ },
+ collapseAll() {
+ this.expandedKeys = {};
+ },
+ expandNode(node) {
+ if (node.children && node.children.length) {
+ this.expandedKeys[node.key] = true;
+
+ for (let child of node.children) {
+ this.expandNode(child);
+ }
+ }
+ }
+ }
+}
+
+
+
+ To display some nodes as expanded by default, simply add their keys to the map.
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ nodes: null,
+ expandedKeys: {}
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeTableNodes().then(data => {
+ this.nodes = data;
+ this.expandedKeys[this.nodes[0].key] = true;
+ this.expandedKeys[this.nodes[1].key] = true;
+ });
+ }
+}
+
+
+
+ + Field data of a corresponding node is displayed as the cell content by default, this can be customized using a body template where current node data and column properties are passed via the slot props. On the other hand, + header and footer sections of a column can either be defined with the properties or the templates. Similarly TreeTable itself also provides header and footer properties along with the templates for the main header and footer + of the table. +
+ +
+<TreeTable :value="nodes">
+ <template #header>
+ FileSystem
+ </template>
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+ <Column headerStyle="width: 8em" bodyStyle="text-align: center">
+ <template #header>
+ <Button type="button" icon="pi pi-cog"></Button>
+ </template>
+ <template #body="slotProps">
+ <Button type="button" icon="pi pi-search" class="p-button-success" style="margin-right: .5em"></Button>
+ <Button type="button" icon="pi pi-pencil" class="p-button-warning"></Button>
+ </template>
+ </Column>
+ <template #footer>
+ <div style="text-align:left">
+ <Button icon="pi pi-refresh" />
+ </div>
+ </template>
+</TreeTable>
+
+
+
+ In addition to the regular table, a smal and a large version are available with different paddings. For a table with smaller paddings use p-treetable-sm class and for a larger one use p-treetable-lg.
+ +
+<TreeTable :value="nodes" class="p-treetable-sm">
+ <template #header>
+ Small Table
+ </template>
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+<TreeTable :value="nodes">
+ <template #header>
+ Small Table
+ </template>
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+<TreeTable :value="nodes" class="p-treetable-lg">
+ <template #header>
+ Small Table
+ </template>
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+
+
+
+ Pagination is enabled by setting paginator property to true and defining the rows property defines the number of rows per page. See the
+<TreeTable :value="nodes" :paginator="true" :rows="10">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+
+
+ paginatorstart and paginatorend templates are available to specify custom content at the left and right side.
+
+<TreeTable :value="nodes" :paginator="true" :rows="10">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+ <template #paginatorstart>
+ <Button type="button" icon="pi pi-refresh" />
+ </template>
+ <template #paginatorend>
+ <Button type="button" icon="pi pi-cloud" />
+ </template>
+</TreeTable>
+
+
+
+ + Paginator can also be programmed programmatically using a binding to the first property that defines the index of the first element to display. For example setting first to zero will reset the paginator to the very first page. This + property also supports the v-model directive in case you'd like your binding to be updated whenever the user changes the page. +
+
+<TreeTable :value="nodes" :paginator="true" :rows="10" :first="firstRecordIndex">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+
+
+ Enabling sortable property at column component would be enough to make a column sortable. The property to use when sorting is the field by default and can be customized using the sortField.
+ +
+<TreeTable :value="nodes" sortMode="single">
+ <Column field="name" header="Name" :expander="true" :sortable="true"></Column>
+ <Column field="size" header="Size" :sortable="true"></Column>
+ <Column field="type" header="Type" :sortable="true"></Column>
+</TreeTable>
+
+
+
+ By default sorting is executed on the clicked column only. To enable multiple field sorting, set sortMode property to "multiple" and use metakey when clicking on another column.
+
+<TreeTable :value="nodes" sortMode="multiple">
+ <Column field="name" header="Name" :expander="true" :sortable="true"></Column>
+ <Column field="size" header="Size" :sortable="true"></Column>
+ <Column field="type" header="Type" :sortable="true"></Column>
+</TreeTable>
+
+
+
+ + In case you'd like to display the table as sorted per a single column by default on mount or programmatically apply sort, use sortField and sortOrder properties. These two properties also support the v-model directive to get + updated when the user applies sort a column. +
+
+<TreeTable :value="nodes" sortField="size" :sortOrder="1"">
+ <Column field="name" header="Name" :expander="true" :sortable="true"></Column>
+ <Column field="size" header="Size" :sortable="true"></Column>
+ <Column field="type" header="Type" :sortable="true"></Column>
+</TreeTable>
+
+<TreeTable :value="nodes" sortMode="single" sortField="dynamicSortField" :sortOrder="dynamicSortOrder">
+ <Column field="name" header="Name" :expander="true" :sortable="true"></Column>
+ <Column field="size" header="Size" :sortable="true"></Column>
+ <Column field="type" header="Type" :sortable="true"></Column>
+</TreeTable>
+
+
+
+ In multiple mode, use the multiSortMeta property and bind an array of SortMeta objects instead.
+
+<TreeTable :value="nodes" sortMode="multiple" :multiSortMeta="multiSortMeta">
+ <Column field="name" header="Name" :expander="true" :sortable="true"></Column>
+ <Column field="size" header="Size" :sortable="true"></Column>
+ <Column field="type" header="Type" :sortable="true"></Column>
+</TreeTable>
+
+
+
+
+data() {
+ return {
+ multiSortMeta: [
+ {field: 'year', order: 1},
+ {field: 'brand', order: -1}
+ ]
+ }
+}
+
+
+
+ + Filtering is enabled by defining a filter template per column to populate the filters property of the TreeTable. The filters property should be an key-value object where keys are the field name and the value is the filter + value. The filter template receives the column properties via the slotProps and accepts any form element as the filter element. Default match mode is "startsWith" and this can be configured per column using the + filterMatchMode property that also accepts "contains", "endsWith", "equals", "notEquals" and "in" as available modes. +
+Optionally a global filter is available to search against all the fields, in this case the special global keyword should be the property to be populated.
+ ++ In addition filterMode specifies the filtering strategy. In lenient mode when the query matches a node, children of the node are not searched further as all descendants of the node are included. On the other hand, in + strict mode when the query matches a node, filtering continues on all descendants. +
+
+<TreeTable :value="nodes" :filters="filters" filterMode="lenient">
+ <template #header>
+ <div style="text-align: right">
+ <i class="pi pi-search" style="margin: 4px 4px 0px 0px;"></i>
+ <InputText v-model="filters['global']" placeholder="Global Search" size="50" />
+ </div>
+ </template>
+ <Column field="name" header="Name" :expander="true">
+ <template #filter>
+ <InputText type="text" v-model="filters['name']" class="p-column-filter" />
+ </template>
+ </Column>
+ <Column field="size" header="Size">
+ <template #filter>
+ <InputText type="text" v-model="filters['size']" class="p-column-filter" />
+ </template>
+ </Column>
+ <Column field="type" header="Type">
+ <template #filter>
+ <InputText type="text" v-model="filters['type']" class="p-column-filter" />
+ </template>
+ </Column>
+</TreeTable>
+
+
+
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ filters: {},
+ nodes: null
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeTableNodes().then(data => this.nodes = data);
+ }
+}
+
+
+
+ + Tree supports single, multiple and checkbox selection modes. Define the selectionKeys with the v-model operator and the selectionMode properties to enable the selection. By default in multiple selection + mode, metaKey is necessary to add to existing selections however this can be configured with metaKeySelection property. Note that in touch enabled devices, Tree does not require metaKey. In addition selection on a particular node + can be disabled if the selectable is false on the node instance. +
+ ++ Similarly to the expandedKeys, selectionKeys is a Map instance whose key is the key of a node and value is a boolean in "single" and "multiple" cases. On the other hand in "checkbox" mode, instead of a boolean, value should + be an object that has "checked" and "partialChecked" properties to represent the checked state of a node. +
+
+<TreeTable :value="nodes" selectionMode="multiple" v-model:selectionKeys="selectedKeys1">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+<h3>Multiple Selection without MetaKey</h3>
+<TreeTable :value="nodes" selectionMode="multiple" v-model:selectionKeys="selectedKeys2" :metaKeySelection="false">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+<h3>Checkbox Selection</h3>
+<TreeTable :value="nodes" selectionMode="checkbox" v-model:selectionKeys="selectedKeys3">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+<h3>Events</h3>
+<TreeTable :value="nodes" selectionMode="single" v-model:selectionKeys="selectedKey2"
+ @node-select="onNodeSelect" @node-unselect="onNodeUnselect">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+
+
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ selectedKey1: null,
+ selectedKey2: null,
+ selectedKeys1: null,
+ selectedKeys2: null,
+ selectedKeys3: null,
+ nodes: null
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeTableNodes().then(data => this.nodes = data);
+ },
+ methods: {
+ onNodeSelect(node) {
+ this.$toast.add({severity:'success', summary: 'Node Selected', detail: node.data.name, life: 3000});
+ },
+ onNodeUnselect(node) {
+ this.$toast.add({severity:'success', summary: 'Node Unselected', detail: node.data.name, life: 3000});
+ }
+ }
+}
+
+
+
+ To display some nodes as selected by default, simply add their keys to the map.
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ selectedKey1: null,
+ selectedKey2: null,
+ selectedKeys1: null,
+ selectedKeys2: null,
+ selectedKeys3: null,
+ nodes: null
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeTableNodes().then(data => {
+ this.nodes = data;
+
+ //single preselection
+ this.selectedKey1[this.nodes[0].key] = true;
+
+ //multiple preselection
+ this.selectedKeys2[this.nodes[0].key] = true;
+ this.selectedKeys2[this.nodes[1].key] = true;
+
+ //checkbox preselection
+ this.selectedKeys2[this.nodes[1].key] = {checked: true};
+ });
+ }
+}
+
+
+
+ TreeTable supports both horizontal and vertical scrolling with support for frozen columns. Scrollable TreeTable is enabled using scrollable property and scrollHeight to define the viewport height.
+
+<TreeTable :value="nodes" style="margin-bottom: 2rem" :scrollable="true" scrollHeight="400px">
+ <Column field="name" header="Name" :expander="true" style="min-width:200px"></Column>
+ <Column field="size" header="Size" style="min-width:200px"></Column>
+ <Column field="type" header="Type" style="min-width:200px"></Column>
+</TreeTable>
+
+
+
+ Scrollable treetable uses flex layout so there are a couple of rules to consider when adjusting the widths of columns.
+
+<Column field="vin" header="Vin" style="flex: 0 0 4rem"></Column>
+
+
+
+ + In cases where viewport should adjust itself according to the table parent's height instead of a fixed viewport height, set scrollHeight option as flex. In example below, table is inside a Dialog where viewport size dynamically responds + to the dialog size changes such as maximizing. FlexScroll can also be used for cases where scrollable viewport should be responsive with respect to the window size for full page scroll. +
+
+<Button label="Show" icon="pi pi-external-link" @click="openDialog" />
+<Dialog header="Flex Scroll" v-model:visible="dialogVisible" :style="{width: '50vw'}" :maximizable="true" :modal="true" :contentStyle="{height: '300px'}">
+ <TreeTable :value="nodes" :scrollable="true" scrollHeight="flex">
+ <Column field="name" header="Name" :expander="true" style="min-width:200px"></Column>
+ <Column field="size" header="Size" style="min-width:200px"></Column>
+ <Column field="type" header="Type" style="min-width:200px"></Column>
+ </TreeTable>
+ <template #footer>
+ <Button label="Yes" icon="pi pi-check" @click="closeDialog" />
+ <Button label="No" icon="pi pi-times" @click="closeDialog" class="p-button-secondary"/>
+ </template>
+</Dialog>
+
+
+
+ For horizontal scrolling, it is required to set scrollDirection to "horizontal" and give fixed widths to columns.
+
+<TreeTable :value="nodes" :scrollable="true" scrollDirection="horizontal">
+ <Column field="name" header="Name" :expander="true" style="width:200px"></Column>
+ <Column field="size" header="Size" style="width:200px"></Column>
+ <Column field="type" header="Type" style="width:200px"></Column>
+</TreeTable>
+
+
+
+ Set scrollDirection to "both" and give fixed widths to columns to scroll both ways.
+
+<TreeTable :value="customers" :scrollable="true" scrollHeight="400px" scrollDirection="both">
+ <Column field="name" header="Name" :expander="true" style="width:200px"></Column>
+ <Column field="size" header="Size" style="width:200px"></Column>
+ <Column field="type" header="Type" style="width:200px"></Column>
+</TreeTable>
+
+
+
+ Certain columns can be frozen by using the frozen property of the column component. In addition alignFrozen is available to define whether the column should be fixed on the left or right.
+ +
+<TreeTable :value="customers" :scrollable="true" scrollHeight="400px" scrollDirection="both">
+ <Column field="name" header="Name" :expander="true" style="width:200px" frozen></Column>
+ <Column field="size" header="Size" style="width:200px"></Column>
+ <Column field="type" header="Type" style="width:200px" frozen alignFrozen="right"></Column>
+</TreeTable>
+
+
+
+ + Lazy Loading is handy to deal with huge datasets. Idea is instead of loading the whole tree, load nodes on demand when necessary. The important part when lazy loading nodes is setting leaf to true on a node instance so that even + without children, tree would render an expand icon. Example below uses an in memory collection to mimic a lazy loading scenario with timeouts. +
+ ++ In addition lazy loading of root level nodes is implemented by handling pagination and sorting using page and sort events by making a remote query using the information passed to the events such as first offset, number of + rows and sort field for ordering. Filtering is handled differently as filter elements are defined using templates, use the event you prefer on your form elements such as input, change, blur to make a remote call by passing the filters + property to update the displayed data. Note that, in lazy filtering, totalRecords should also be updated to align the data with the paginator. +
+ . + +Example below uses an in memory collection to mimic a lazy loading scenario with timeouts.
+ +
+<TreeTable :value="nodes" :lazy="true" :paginator="true" :rows="rows" :loading="loading"
+ @node-expand="onExpand" @page="onPage" :totalRecords="totalRecords">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+
+
+
+export default {
+ data() {
+ return {
+ nodes: null,
+ rows: 10,
+ loading: false,
+ totalRecords: 0
+ }
+ },
+ mounted() {
+ this.loading = true;
+
+ setTimeout(() => {
+ this.loading = false;
+ this.nodes = this.loadNodes(0, this.rows);
+ this.totalRecords = 1000;
+ }, 1000);
+ },
+ methods: {
+ onExpand(node) {
+ if (!node.children) {
+ this.loading = true;
+
+ setTimeout(() => {
+ let lazyNode = {...node};
+
+ lazyNode.children = [
+ {
+ data: {
+ name: lazyNode.data.name + ' - 0',
+ size: Math.floor(Math.random() * 1000) + 1 + 'kb',
+ type: 'File'
+ },
+ },
+ {
+ data: {
+ name: lazyNode.data.name + ' - 1',
+ size: Math.floor(Math.random() * 1000) + 1 + 'kb',
+ type: 'File'
+ }
+ }
+ ];
+
+ let nodes = this.nodes.map(n => {
+ if (n.key === node.key) {
+ n = lazyNode;
+ }
+
+ return n;
+ });
+
+ this.loading = false;
+ this.nodes = nodes;
+ }, 250);
+ }
+ },
+ onPage(event) {
+ this.loading = true;
+
+ //imitate delay of a backend call
+ setTimeout(() => {
+ this.loading = false;
+ this.nodes = this.loadNodes(event.first, this.rows);
+ }, 1000);
+ },
+ loadNodes(first, rows) {
+ let nodes = [];
+
+ for(let i = 0; i < rows; i++) {
+ let node = {
+ key: (first + i),
+ data: {
+ name: 'Item ' + (first + i),
+ size: Math.floor(Math.random() * 1000) + 1 + 'kb',
+ type: 'Type ' + (first + i)
+ },
+ leaf: false
+ };
+
+ nodes.push(node);
+ }
+
+ return nodes;
+ }
+ }
+}
+
+
+
+ + Columns can be resized using drag drop by setting the resizableColumns to true. There are two resize modes; "fit" and "expand". Fit is the default one and the overall table width does not change when a column is resized. In + "expand" mode, table width also changes along with the column width. column-resize-end is a callback that passes the resized column header and delta change as a parameter. +
+
+<h3>Fit Mode</h3>
+<TreeTable :value="nodes" :resizableColumns="true" columnResizeMode="fit">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+<h3>Expand Mode</h3>
+<TreeTable :value="nodes" :resizableColumns="true" columnResizeMode="expand">
+ <Column field="name" header="Name" :expander="true"></Column>
+ <Column field="size" header="Size"></Column>
+ <Column field="type" header="Type"></Column>
+</TreeTable>
+
+
+
+ It is important to note that when you need to change column widths, since table width is 100%, giving fixed pixel widths does not work well as browsers scale them, instead give percentage widths.
+
+<TreeTable :value="nodes" :resizableColumns="true">
+ <Column field="name" header="Name" :expander="true"></Column headerStyle="width: 20%">
+ <Column field="size" header="Size" headerStyle="width: 40%"></Column>
+ <Column field="type" header="Type headerStyle="width: 40%""></Column>
+</TreeTable>
+
+
+
+ TreeTable display can be optimized according to screen sizes using the built-in responsiveLayout property. Currently only available option is "scroll" that displays a horizontal scrollbar for small devices.
+
+<TreeTable :value="nodes" responsiveLayout="scroll">
+ <Column field="name" header="Name" :expander="true" style="min-width:200px"></Column>
+ <Column field="size" header="Size" style="min-width:200px"></Column>
+ <Column field="type" header="Type" style="min-width:200px"></Column>
+</TreeTable>
+
+
+
+ Any property such as style and class are passed to the underlying root element. Following is the additional property to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
value | +array | +null | +An array of treenodes. | +
expandedKeys | +array | +null | +A map of keys to represent the state of the tree expansion state in controlled mode. | +
selectionKeys | +any | +null | +A map of keys to control the selection state. | +
selectionMode | +string | +null | +Defines the selection mode, valid values "single", "multiple", and "checkbox". | +
metaKeySelection | +boolean | +true | ++ Defines how multiple items can be selected, when true metaKey needs to be pressed to select or unselect an item and when set to false selection of each item can be toggled individually. On touch enabled devices, + metaKeySelection is turned off automatically. + | +
rows | +number | +null | +Number of rows to display per page. | +
first | +number | +0 | +Index of the first row to be displayed. | +
totalRecords | +number | +null | +Number of total records, defaults to length of value when not defined. | +
paginator | +boolean | +false | +When specified as true, enables the pagination. | +
paginatorPosition | +string | +bottom | +Position of the paginator, options are "top","bottom" or "both". | +
alwaysShowPaginator | +boolean | +true | +Whether to show it even there is only one page. | +
paginatorTemplate | +string | +
+ FirstPageLink PrevPageLink PageLinks + NextPageLink LastPageLink RowsPerPageDropdown + |
+ Template of the paginator. See the |
+
pageLinkSize | +number | +5 | +Number of page links to display. | +
rowsPerPageOptions | +array | +null | +Array of integer values to display inside rows per page dropdown. | +
currentPageReportTemplate | +string | +({currentPage} of {totalPages}) | +Template of the current page report element. | +
lazy | +boolean | +false | +Defines if data is loaded and interacted with in lazy manner. | +
loading | +boolean | +false | +Displays a loader to indicate data load is in progress. | +
loadingIcon | +string | +pi pi-spinner | +The icon to show while indicating data load is in progress. | +
rowHover | +boolean | +false | +When enabled, background of the rows change on hover. | +
autoLayout | +boolean | +false | +Whether the cell widths scale according to their content or not. | +
sortField | +string | +null | +Property name or a getter function of a row data used for sorting by default. | +
sortOrder | +number | +null | +Order to sort the data by default. | +
defaultSortOrder | +number | +1 | +Default sort order of an unsorted column. | +
multiSortMeta | +array | +null | +An array of SortMeta objects to sort the data by default in multiple sort mode. | +
sortMode | +string | +single | +Defines whether sorting works on single column or on multiple columns. | +
removableSort | +boolean | +false | +When enabled, columns can have an un-sorted state. | +
filters | +object | +null | +Filters object with key-value pairs to define the filters. | +
filterMode | +string | +lenient | +Mode for filtering valid values are "lenient" and "strict". Default is lenient. | +
filterLocale | +string | +undefined | +Locale to use in filtering. The default locale is the host environment's current locale. | +
resizableColumns | +boolean | +false | +When enabled, columns can be resized using drag and drop. | +
columnResizeMode | +string | +fit | +
+ Defines whether the overall table width should change on column resize, + valid values are "fit" and "expand". + |
+
indentation | +number | +1 | +Indentation factor as rem value for children nodes. Defaults to 1rem. | +
showGridlines | +boolean | +false | +Whether to show grid lines between cells. | +
scrollable | +boolean | +false | +When specified, enables horizontal and/or vertical scrolling. | +
scrollDirection | +string | +vertical | +Orientation of the scrolling, options are "vertical", "horizontal" and "both". | +
scrollHeight | +string | +null | +Height of the scroll viewport in fixed pixels or the "flex" keyword for a dynamic size. | +
responsiveLayout | +string | +stack | +Defines the responsive mode, currently only option is scroll.. | +
Name | +Parameters | +Description | +
---|---|---|
page | +
+ event.originalEvent: Browser event + event.page: New page number + event.pageCount: Total page count + event.first: Index of first record + event.rows: Number of rows to display in new page + event.sortField: Field to sort against + event.sortOrder: Sort order as integer + event.multiSortMeta: MultiSort metadata + event.filters: Collection of active filters + event.filterMatchModes: Match modes per field + |
+ Callback to invoke on pagination. Sort and Filter information is also available for lazy loading implementation. | +
sort | +
+ event.originalEvent: Browser event + event.first: Index of first record + event.rows: Number of rows to display in new page + event.sortField: Field to sort against + event.sortOrder: Sort order as integer + event.multiSortMeta: MultiSort metadata + event.filters: Collection of active filters + event.filterMatchModes: Match modes per field + |
+ Callback to invoke on sort. Page and Filter information is also available for lazy loading implementation. | +
filter | +
+ event.originalEvent: Browser event + event.first: Index of first record + event.rows: Number of rows to display in new page + event.sortField: Field to sort against + event.sortOrder: Sort order as integer + event.multiSortMeta: MultiSort metadata + event.filters: Collection of active filters + event.filteredValue: Filtered collection + event.filterMatchModes: Match modes per field + |
+ Event to emit after filtering, not triggered in lazy mode. | +
node-select | +node: Node instance | +Callback to invoke when a node is selected. | +
node-unselect | +node: Node instance | +Callback to invoke when a node is unselected. | +
node-expand | +node: Node instance | +Callback to invoke when a node is expanded. | +
node-collapse | +node: Node instance | +Callback to invoke when a node is collapsed. | +
column-resize-end | +
+ event.element: DOM element of the resized column. + event.delta: Change in column width + |
+ Callback to invoke when a column is resized. | +
Name | +Parameters | +
---|---|
header | +- | +
paginatorstart | +- | +
paginatorend | +- | +
empty | +- | +
footer | +- | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-treetable | +Container element. | +
p-treetable-scrollable | +Container element when table is scrollable. | +
p-treetable-header | +Header section. | +
p-treetable-footer | +Footer section. | +
p-treetable-wrapper | +Wrapper of table element. | +
p-treetable-table | +Table element. | +
p-treetable-thead | +Table thead element. | +
p-treetable-tbody | +Table tbody element. | +
p-treetable-tfoot | +Table tfoot element. | +
p-column-title | +Title of a column. | +
p-sortable-column | +Sortable column header. | +
p-frozen-column | +Frozen column header. | +
p-treetable-toggler | +Toggle element for a row. | +
p-treetable-emptymessage | +Cell containing the empty message. | +
None.
+Filtering is enabled by defining a filter template per column to populate the filters property of the TreTable.
++ Lazy mode is handy to deal with large datasets, instead of loading the entire data, small chunks of data is loaded by invoking corresponding callbacks everytime paging or sorting. In addition, children of a node can be loaded on + demand at onNodeExpand event as well. Sample belows imitates lazy paging by using an in memory list.. +
+Pagination is enabled by setting paginator property to true and defining the rows attribute as the number of root level nodes per page.
+TreeTable display can be optimized according for different screen sizes.
+Built-in responsiveness using the responsiveLayout property set to scroll.
+Custom implementation using media queries.
+Data scrolling is available horizontally, vertically or both with support for frozen columns.
++ Flex scroll feature makes the scrollable viewport section dynamic instead of a fixed value so that it can grow or shrink relative to the parent size of the table. Click the button below to display a maximizable Dialog where data + viewport adjusts itself according to the size changes. +
+ + +TreeTable supports single, multiple and checkbox as selection modes.
+In addition to a regular table, a smaller and a larger alternatives available.
+TreeTable supports both single column and multiple column sorting..
+Custom content at header, body and footer sections are supported via templating.
+
+import TriStateCheckbox from 'primevue/tristatecheckbox';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+<script src="https://unpkg.com/primevue@^3/tristatecheckbox/tristatecheckbox.min.js"></script>
+
+
+
+ A model can be bound using the standard v-model directive.
+
+<TriStateCheckbox v-model="value" />
+
+
+
+ Any property such as name and autofocus are passed to the underlying input element. Following is the additional property to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +boolean | +null | +Value of the component. | +
disabled | +boolean | +false | +When specified, disables the component. | +
tabindex | +number | +0 | +Index of the element in tabbing order. | +
inputId | +string | +null | +Style class of the component input field. | +
inputProps | +object | +null | +Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component. | +
Any valid event such as focus and blur.
+ +Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-chkbox | +Container element | +
p-tristatechkbox | +Container element | +
p-chkbox-box | +Container of icon. | +
p-chkbox-icon | +Icon element. | +
+ TriStateCheckbox component uses an element with checkbox role. Value to describe the component can either be provided with aria-labelledby or aria-label props. Component adds an element with aria-live attribute
+ that is only visible to screen readers to read the value displayed. Values to read are defined with the trueLabel, falseLabel and nullLabel keys of the aria property from the
+
+<span id="chkbox1">Remember Me</span>
+<TriStateCheckbox aria-labelledby="chkbox1" />
+
+<TriStateCheckbox aria-label="Remember Me" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the checkbox. | +
space | +Toggles between the values. | +
enter | +Toggles between the values. | +
None.
+TriStateCheckbox is used to select either "true", "false" or "null" as the value.
+PrimeOne for Figma uses the latest powerful features like components, variants, auto layout, styles and interactive components. It'll always follow the best practices.
+ +Save countless hours on every project with a carefully designed system that uses Prime UI Suite components. Start producing design results in no time.
+ +PrimeOne is designed based on Lara Blue Light and Lara Blue Dark themes. Easily change the themes of your designs using Figma's Swap Library feature.
+ +You'll be able to download two Figma files for light and dark themes.
+ +UI Kit license is perpetual so requires one time payment, not subscription based.
+ +Yes, your license allows you to sell your projects that utilize the UI Kit implementations.
+ +There is no limit, you are able to use UI Kit in multiple projects for multiple clients.
++ Yes, after the purchase, please contact us so we can transfer the license to your client. +
+ +Yes, contractors are also able to use the UI Kit within your company.
+ +No, enterprise license is per company so each subsidiary company needs to purchase a separate license.
+ +All updates will be totally free of charge for existing customers for an unlimited period.
++ Support is provided by PrimeTek via a dedicated forum channel monitored by PrimeTek support staff. +
+ +Support service at the forum does not have a time limit.
+ +Due to the license, it is not possible to use the UI Kit in an open source project where the design files are publicly available.
+PrimeVue components can be easily used/integrated with Vuelidate. In this example, a register panel is simulated using Vuelidate.
+
+import VirtualScroller from 'primevue/virtualscroller';
+
+
+
+
+<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
+
+
+
+
+ VirtualScroller is used to display huge data. It periodically adds special elements defined according to the scroll's position to the DOM. The item and itemSize properties and item template are required on component.
+ In addition, an initial array is required based on the total number of items to display.
+ VirtualScroller automatically calculates how many items will be displayed in the view according to itemSize using a specified scroll height. Its scroll height can be adjusted with scrollHeight property or height property of
+ CSS.
+
+<VirtualScroller :items="basicItems" :itemSize="50">
+ <template v-slot:item="{ item, options }">
+ <div :class="['scroll-item p-2', {'odd': options.odd}]" style="height: 50px">{{ item }}</div>
+ </template>
+</VirtualScroller>
+
+
+
+
+export default {
+ data() {
+ return {
+ basicItems: null
+ }
+ },
+ mounted() {
+ this.basicItems = Array.from({ length: 100000 }).map((_, i) => `Item #${i}`);
+ }
+}
+
+
+
+ VirtualScroller has a special loader. It can be activated with the showLoader property. In addition, loader template can be used to add custom loaders to item elements.
+ +
+<VirtualScroller :items="basicItems" :itemSize="50" showLoader :delay="250">
+ <template v-slot:item="{ item, options }">
+ <div :class="['scroll-item p-2', {'odd': options.odd}]" style="height: 50px">{{ item }}</div>
+ </template>
+ <template v-slot:loader="{ options }">
+ <div :class="['scroll-item p-2', {'odd': options.odd}]" style="height: 50px" >
+ <Skeleton :width="options.even ? '60%' : '50%'" height="1.3rem" />
+ </div>
+ </template>
+</VirtualScroller>
+
+
+
+ Lazy mode is handy to deal with large datasets, instead of loading the entire data, small chunks of data is loaded by invoking lazy-load event.
+ +
+<VirtualScroller :items="lazyItems" :itemSize="50" showLoader :delay="250" :loading="lazyLoading" :lazy=true @lazy-load="onLazyLoad">
+ <template v-slot:item="{ item, options }">
+ <div :class="['scroll-item p-2', {'odd': options.odd}]" style="height: 50px">{{ item }}</div>
+ </template>
+</VirtualScroller>
+
+
+
+
+export default {
+ data() {
+ return {
+ lazyItems: null,
+ lazyLoading: false,
+ loadLazyTimeout: null,
+ }
+ },
+ mounted() {
+ this.lazyItems = Array.from({ length: 100000 });
+ },
+ methods: {
+ onLazyLoad(event) {
+ this.lazyLoading = true;
+
+ if (this.loadLazyTimeout) {
+ clearTimeout(this.loadLazyTimeout);
+ }
+
+ //imitate delay of a backend call
+ this.loadLazyTimeout = setTimeout(() => {
+ const { first, last } = event;
+ const lazyItems = [...this.lazyItems];
+
+ for (let i = first; i < last; i++) {
+ lazyItems[i] = `Item #${i}`;
+ }
+
+ this.lazyItems = lazyItems;
+ this.lazyLoading = false;
+
+ }, Math.random() * 1000 + 250);
+ }
+ }
+}
+
+
+
+ Name | +Type | +Default | +Description | +
---|---|---|---|
id | +string | +null | +Unique identifier of the element. | +
style | +any | +null | +Inline style of the component. | +
class | +string | +null | +Style class of the component. | +
items | +array | +null | +An array of objects to display. | +
itemSize | +number / [number, number] | +null | +The height/width of item according to orientation. | +
scrollHeight | +string | +null | +Height of the scroll viewport. | +
scrollWidth | +string | +null | +Width of the scroll viewport. | +
orientation | +string | +'vertical' | +The orientation of scrollbar, valid values are 'vertical', 'horizontal' and 'both'. | +
numToleratedItems | +number | +null | +
+ Determines how many additional elements to add to the DOM outside of the view. + According to the scrolls made up and down, extra items are added in a certain algorithm in the form of multiples of this number. + Default value is half the number of items shown in the view. + |
+
delay | +number | +0 | +Delay in scroll before new data is loaded. | +
lazy | +boolean | +false | +Defines if data is loaded and interacted with in lazy manner. | +
disabled | +boolean | +false | +If disabled, the VirtualScroller feature is eliminated and the content is displayed directly. | +
loaderDisabled | +boolean | +false | +Used to implement a custom loader instead of using the loader feature in the VirtualScroller. | +
loading | +boolean | +false | +Whether the data is loaded. | +
showSpacer | +boolean | +true | +Used to implement a custom spacer instead of using the spacer feature in the VirtualScroller. | +
showLoader | +boolean | +false | +Whether to show loader. | +
tabindex | +number | +0 | +Index of the element in tabbing order. | +
Name | +Parameters | +Description | +
---|---|---|
scroll | +event: Browser event | +Callback to invoke when scroll position changes. | +
scroll-index-change | +
+ event.first: First index of the new data range to be loaded. + event.last: Last index of the new data range to be loaded. + |
+ Callback to invoke when scroll position and item's range in view changes. | +
lazy-load | +
+ event.first: First index of the new data range to be loaded. + event.last: Last index of the new data range to be loaded. + |
+ Callback to invoke in lazy mode to load new data. | +
Name | +Parameters | +Description | +
---|---|---|
scrollTo | +
+ left: Left position of scroll. + top: Top position of scroll + behavior: Behavior of scroll, valid values are 'auto' and 'smooth' + |
+ Scroll to move to a specific position. | +
scrollToIndex | +
+ index: Index of item according to orientation mode. + behavior: Behavior of scroll, valid values are 'auto' and 'smooth' + |
+ Scroll to move to a specific item. | +
scrollInView | +
+ index: Index of item according to orientation mode. + to: Defines the location of the item in view, valid values are 'to-start' and 'to-end'. + behavior: Behavior of scroll, valid values are 'auto' and 'smooth' + |
+ It is used to move the specified index into the view. It is a method that will usually be needed when keyboard support is added to the virtualScroller component. | +
getRenderedRange | +- | +Returns the range of items added to the DOM. | +
Name | +Parameters | +
---|---|
content | +
+ items: An array of objects to display. + styleClass: Style class of the component + contentRef: Referance of the content + getItemOptions: Options of the items + loading: Whether the data is loaded + getLoaderOptions: Loader options of the items while the data is loading. + itemSize: The height/width of item according to orientation. + rows: The number of the rendered rows. + columns: The number of the rendered columns. + spacerStyle: The style of spacer element. + contentStyle: The style of content element. + vertical: Whether the orientation is vertical. + horizontal: Whether the orientation is horizontal. + both: Whether the orientation is both. + |
+
item | +
+ item: Item instance + options: Options of the item instance + |
+
loader | +options: Options of the loader items | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-virtualscroller | +Container element. | +
p-virtualscroller-content | +Content element. | +
p-virtualscroller-loader | +Loader element. | +
None.
+VirtualScroller is a performant approach to handle huge data efficiently.
+