O componente PricingPlans oferece um layout flexível para exibir uma lista de componentes PricingPlan usando o slot padrão ou a prop plans.
<template>
<NPricingPlans>
<NPricingPlan
v-for="(plan, index) in plans"
:key="index"
v-bind="plan"
/>
</NPricingPlans>
</template>
plans, mas também com o slot padrão.Use a prop plans como um array de objetos com as propriedades do componente PricingPlan.
<script setup lang="ts">
import type { PricingPlanProps } from '@nitro/ui'
const plans = ref<PricingPlanProps[]>([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<NPricingPlans :plans="plans" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { PricingPlanProps } from '@nitro/ui'
const plans = ref<PricingPlanProps[]>([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<NPricingPlans :plans="plans" />
</template>
Use a prop orientation para alterar a orientação do PricingPlans. O padrão é horizontal.
<script setup lang="ts">
import type { PricingPlanProps } from '@nitro/ui'
const plans = ref<PricingPlanProps[]>([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<NPricingPlans orientation="vertical" :plans="plans" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { PricingPlanProps } from '@nitro/ui'
const plans = ref<PricingPlanProps[]>([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<NPricingPlans orientation="vertical" :plans="plans" />
</template>
plans em vez do slot padrão, a orientation dos planos é invertida automaticamente, de horizontal para vertical e vice-versa.Use a prop compact para reduzir o espaçamento entre os planos quando um deles está escalado, para um melhor equilíbrio visual.
<script setup lang="ts">
import type { PricingPlanProps } from '@nitro/ui'
const plans = ref<PricingPlanProps[]>([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
scale: true,
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<NPricingPlans compact :plans="plans" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { PricingPlanProps } from '@nitro/ui'
const plans = ref<PricingPlanProps[]>([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
scale: true,
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<NPricingPlans compact :plans="plans" />
</template>
Use a prop scale para ajustar o espaçamento entre os planos quando um deles está escalado, para um melhor equilíbrio visual.
<script setup lang="ts">
import type { PricingPlanProps } from '@nitro/ui'
const plans = ref<PricingPlanProps[]>([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
scale: true,
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<NPricingPlans scale :plans="plans" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { PricingPlanProps } from '@nitro/ui'
const plans = ref<PricingPlanProps[]>([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
scale: true,
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<NPricingPlans scale :plans="plans" />
</template>
Use o componente PricingPlans em uma página para criar uma página de preços:
<script setup lang="ts">
const { data: plans } = await useAsyncData('plans', () => queryCollection('plans').all())
</script>
<template>
<NPage>
<NPageHero title="Pricing" />
<NPageBody>
<NContainer>
<NPricingPlans :plans="plans" />
</NContainer>
</NPageBody>
</NPage>
</template>
plans são buscados usando queryCollection do módulo @nuxt/content.| Prop | Default | Type |
|---|---|---|
as | 'div' | anyThe element or component this component should render as. |
plans | PricingPlanProps[] | |
orientation | 'horizontal' | "horizontal" | "vertical"The orientation of the pricing plans. |
compact | false | boolean When |
scale | false | boolean When |
ui | { base?: any; } |
| Slot | Type |
|---|---|
badge | { ui: object; } |
title | {} |
description | {} |
price | {} |
discount | {} |
billing | { ui: object; } |
features | {} |
button | { ui: object; } |
header | {} |
body | {} |
footer | {} |
tagline | {} |
terms | {} |
default | {} |
export default defineAppConfig({
ui: {
pricingPlans: {
base: 'flex flex-col gap-y-8',
variants: {
orientation: {
horizontal: 'lg:grid lg:grid-cols-[repeat(var(--count),minmax(0,1fr))]',
vertical: ''
},
compact: {
false: 'gap-x-8'
},
scale: {
true: ''
}
},
compoundVariants: [
{
compact: false,
scale: true,
class: 'lg:gap-x-13'
}
]
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nitro/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
pricingPlans: {
base: 'flex flex-col gap-y-8',
variants: {
orientation: {
horizontal: 'lg:grid lg:grid-cols-[repeat(var(--count),minmax(0,1fr))]',
vertical: ''
},
compact: {
false: 'gap-x-8'
},
scale: {
true: ''
}
},
compoundVariants: [
{
compact: false,
scale: true,
class: 'lg:gap-x-13'
}
]
}
}
})
]
})