2022-09-09 20:41:18 +00:00
|
|
|
<template>
|
2022-09-12 13:27:56 +00:00
|
|
|
<ClientOnly>
|
2022-09-14 14:26:41 +00:00
|
|
|
<AppDoc name="BadgeDemo" :sources="sources" github="badge/BadgeDemo.vue">
|
|
|
|
<h5>Getting Started</h5>
|
|
|
|
<p>Badge can either be used as a standalone component or as a directive.</p>
|
2022-09-09 20:41:18 +00:00
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<h5>Component</h5>
|
|
|
|
<h6>Import via Module</h6>
|
|
|
|
<pre v-code.script><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
import Badge from 'primevue/badge';
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<h6>Import via CDN</h6>
|
|
|
|
<pre v-code><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
|
|
|
|
<script src="https://unpkg.com/primevue@^3/badge/badge.min.js"></script>
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<p>Content of the badge is specified using the <i>value</i> property.</p>
|
|
|
|
<pre v-code><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
<Badge value="2"></Badge>
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<h5>Directive</h5>
|
|
|
|
<h6>Import via Module</h6>
|
|
|
|
<pre v-code.script><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
import BadgeDirective from 'primevue/badgedirective';
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<h6>Import via CDN</h6>
|
|
|
|
<pre v-code><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
|
|
|
|
<script src="https://unpkg.com/primevue@^3/badgedirective/badgedirective.min.js"></script>
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<p>When used as a directive, badge needs to be configured at the application with a name of your choice.</p>
|
|
|
|
<pre v-code.script><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
import BadgeDirective from 'primevue/badgedirective';
|
|
|
|
|
|
|
|
app.directive('badge', BadgeDirective);
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<p>Next step is attaching it to an element.</p>
|
|
|
|
<pre v-code><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
<i class="pi pi-bell" v-badge="2"></i>
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<h5>Severities</h5>
|
|
|
|
<p>Different color options are available as severity levels. When used as a component use the <i>severity</i> property to apply a severity and use a <i>modifier</i> as the severity value in directive mode.</p>
|
2022-09-09 20:41:18 +00:00
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<ul>
|
|
|
|
<li>success</li>
|
|
|
|
<li>info</li>
|
|
|
|
<li>warning</li>
|
|
|
|
<li>danger</li>
|
|
|
|
</ul>
|
2022-09-09 20:41:18 +00:00
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<pre v-code><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
<Badge value="2" severity="success"></Badge>
|
|
|
|
|
|
|
|
<i class="pi pi-bell" v-badge.success="2"></i>
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<h5>Button Badges</h5>
|
|
|
|
<p>Buttons provide integrated badge support with the <i>badge</i> and <i>badgeClass</i> properties.</p>
|
2022-09-09 20:41:18 +00:00
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<pre v-code><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
<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" />
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<h5>Sizes</h5>
|
|
|
|
<p>Badge sizes are adjusted with the <i>size</i> property that accepts "large" and "xlarge" as the possible alternatives to the default size. Currently sizes only apply to component mode.</p>
|
|
|
|
<pre v-code><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
<Badge value="2"></Badge>
|
|
|
|
<Badge value="4" size="large" severity="warning"></Badge>
|
|
|
|
<Badge value="6" size="xlarge" severity="success"></Badge>
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<p>In addition, when placed inside another element, badge sizes can also derive their size from their parent.</p>
|
|
|
|
<pre v-code><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
<h1>Heading 1 <Badge value="New"></Badge></h1>
|
|
|
|
<h2>Heading 2 <Badge value="New"></Badge></h2>
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<h5>Templating</h5>
|
|
|
|
<p>Content can easily be customized with the default slot instead of using the built-in display.</p>
|
|
|
|
<pre v-code><code>
|
2022-09-09 20:41:18 +00:00
|
|
|
<Badge>
|
|
|
|
Content
|
|
|
|
</Badge>
|
|
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
<h5>Properties</h5>
|
|
|
|
<p>Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.</p>
|
|
|
|
<div class="doc-tablewrapper">
|
|
|
|
<table class="doc-table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Type</th>
|
|
|
|
<th>Default</th>
|
|
|
|
<th>Description</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>value</td>
|
|
|
|
<td>any</td>
|
|
|
|
<td>null</td>
|
|
|
|
<td>Value to display inside the badge.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>severity</td>
|
|
|
|
<td>string</td>
|
|
|
|
<td>null</td>
|
|
|
|
<td>Severity type of the badge.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>size</td>
|
|
|
|
<td>string</td>
|
|
|
|
<td>null</td>
|
|
|
|
<td>Size of the badge, valid options are "large" and "xlarge".</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<h5>Styling</h5>
|
|
|
|
<p>Following is the list of structural style classes, for theming classes visit <nuxt-link to="/theming">theming</nuxt-link> page.</p>
|
|
|
|
<div class="doc-tablewrapper">
|
|
|
|
<table class="doc-table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Element</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>p-badge</td>
|
|
|
|
<td>Badge element</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-overlay-badge</td>
|
|
|
|
<td>Wrapper of a badge and its target.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-badge-dot</td>
|
|
|
|
<td>Badge element with no value.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-badge-success</td>
|
|
|
|
<td>Badge element with success severity.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-badge-info</td>
|
|
|
|
<td>Badge element with info severity.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-badge-warning</td>
|
|
|
|
<td>Badge element with warning severity.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-badge-danger</td>
|
|
|
|
<td>Badge element with danger severity.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-badge-lg</td>
|
|
|
|
<td>Large badge element</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-badge-xl</td>
|
|
|
|
<td>Extra large badge element</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<h5>Dependencies</h5>
|
|
|
|
<p>None.</p>
|
|
|
|
</AppDoc>
|
|
|
|
</ClientOnly>
|
2022-09-09 20:41:18 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
sources: {
|
|
|
|
'options-api': {
|
|
|
|
tabName: 'Options API Source',
|
|
|
|
content: `
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<h5>Numbers</h5>
|
|
|
|
<Badge value="2" class="mr-2"></Badge>
|
|
|
|
<Badge value="8" severity="success" class="mr-2"></Badge>
|
|
|
|
<Badge value="4" severity="info" class="mr-2"></Badge>
|
|
|
|
<Badge value="12" severity="warning" class="mr-2"></Badge>
|
|
|
|
<Badge value="3" severity="danger"></Badge>
|
|
|
|
|
|
|
|
<h5 class="mb-4">Positioned Badge</h5>
|
|
|
|
<i class="pi pi-bell mr-4 p-text-secondary" style="font-size: 2rem" v-badge="2"></i>
|
|
|
|
<i class="pi pi-calendar mr-4 p-text-secondary" style="font-size: 2rem" v-badge.danger="'10+'"></i>
|
|
|
|
<i class="pi pi-envelope p-text-secondary" style="font-size: 2rem" v-badge.danger></i>
|
|
|
|
|
|
|
|
<h5>Button Badge</h5>
|
|
|
|
<Button type="button" label="Emails" badge="8" class="mr-2" />
|
|
|
|
<Button type="button" label="Messages" icon="pi pi-users" class="p-button-warning" badge="8" badgeClass="p-badge-danger" />
|
|
|
|
|
|
|
|
<h5>Sizes</h5>
|
|
|
|
<Badge value="2" class="mr-2"></Badge>
|
|
|
|
<Badge value="4" class="mr-2" size="large" severity="warning"></Badge>
|
|
|
|
<Badge value="6" size="xlarge" severity="success"></Badge>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
}
|
|
|
|
<\\/script>
|
|
|
|
`
|
|
|
|
},
|
|
|
|
'composition-api': {
|
|
|
|
tabName: 'Composition API Source',
|
|
|
|
content: `
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<h5>Numbers</h5>
|
|
|
|
<Badge value="2" class="mr-2"></Badge>
|
|
|
|
<Badge value="8" severity="success" class="mr-2"></Badge>
|
|
|
|
<Badge value="4" severity="info" class="mr-2"></Badge>
|
|
|
|
<Badge value="12" severity="warning" class="mr-2"></Badge>
|
|
|
|
<Badge value="3" severity="danger"></Badge>
|
|
|
|
|
|
|
|
<h5 class="mb-4">Positioned Badge</h5>
|
|
|
|
<i class="pi pi-bell mr-4 p-text-secondary" style="font-size: 2rem" v-badge="2"></i>
|
|
|
|
<i class="pi pi-calendar mr-4 p-text-secondary" style="font-size: 2rem" v-badge.danger="'10+'"></i>
|
|
|
|
<i class="pi pi-envelope p-text-secondary" style="font-size: 2rem" v-badge.danger></i>
|
|
|
|
|
|
|
|
<h5>Button Badge</h5>
|
|
|
|
<Button type="button" label="Emails" badge="8" class="mr-2" />
|
|
|
|
<Button type="button" label="Messages" icon="pi pi-users" class="p-button-warning" badge="8" badgeClass="p-badge-danger" />
|
|
|
|
|
|
|
|
<h5>Sizes</h5>
|
|
|
|
<Badge value="2" class="mr-2"></Badge>
|
|
|
|
<Badge value="4" class="mr-2" size="large" severity="warning"></Badge>
|
|
|
|
<Badge value="6" size="xlarge" severity="success"></Badge>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
}
|
|
|
|
<\\/script>`
|
|
|
|
},
|
|
|
|
'browser-source': {
|
|
|
|
tabName: 'Browser Source',
|
|
|
|
imports: `<script src="https://unpkg.com/primevue@^3/badge/badge.min.js"><\\/script>
|
|
|
|
<script src="https://unpkg.com/primevue@^3/badgedirective/badgedirective.min.js"><\\/script>`,
|
|
|
|
content: `<div id="app">
|
|
|
|
<h5>Numbers</h5>
|
|
|
|
<p-badge value="2" class="mr-2"></p-badge>
|
|
|
|
<p-badge value="8" severity="success" class="mr-2"></p-badge>
|
|
|
|
<p-badge value="4" severity="info" class="mr-2"></p-badge>
|
|
|
|
<p-badge value="12" severity="warning" class="mr-2"></p-badge>
|
|
|
|
<p-badge value="3" severity="danger"></p-badge>
|
|
|
|
|
|
|
|
<h5 class="mb-4">Positioned Badge</h5>
|
|
|
|
<i class="pi pi-bell mr-4 p-text-secondary" style="font-size: 2rem" v-badge="2"></i>
|
|
|
|
<i class="pi pi-calendar mr-4 p-text-secondary" style="font-size: 2rem" v-badge.danger="'10+'"></i>
|
|
|
|
<i class="pi pi-envelope p-text-secondary" style="font-size: 2rem" v-badge.danger></i>
|
|
|
|
|
|
|
|
<h5>Button Badge</h5>
|
|
|
|
<p-button type="button" label="Emails" badge="8" class="mr-2"></p-button>
|
|
|
|
<p-button type="button" label="Messages" icon="pi pi-users" class="p-button-warning" badge="8" badgeClass="p-badge-danger"></p-button>
|
|
|
|
|
|
|
|
<h5>Sizes</h5>
|
|
|
|
<p-badge value="2" class="mr-2"></p-badge>
|
|
|
|
<p-badge value="4" class="mr-2" size="large" severity="warning"></p-badge>
|
|
|
|
<p-badge value="6" size="xlarge" severity="success"></p-badge>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script type="module">
|
|
|
|
const { createApp } = Vue;
|
|
|
|
const BadgeDirective = primevue.badgedirective;
|
|
|
|
|
|
|
|
const App = {
|
|
|
|
components: {
|
|
|
|
"p-badge": primevue.badge,
|
|
|
|
"p-button": primevue.button
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const app = createApp(App);
|
|
|
|
app.use(primevue.config.default);
|
|
|
|
app.directive('badge', BadgeDirective);
|
|
|
|
app.mount('#app');
|
|
|
|
<\\/script>`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|