Zubra UI
Code for
GitHub

pricing-block

Pricing plans side by side, with a monthly or yearly switch, a featured plan, and what each includes. Choosing a plan fires choose with the plan and period.

Try it: events appear here (periodchange, choose).

Source: pricing-block.zb, and its registry item.

Install

Compiled (any project)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/pricing-block.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/pricing-block.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/pricing-block.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/pricing-block.json
One file, no dependencies (5.3 KB gzipped)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/pricing-block.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/pricing-block.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/pricing-block.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/pricing-block.json
.zb source (to edit it with Zubra)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/pricing-block.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/pricing-block.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/pricing-block.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/pricing-block.json
No build: a script tag, straight from this site
HTML
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/pricing-block.js"></script>

The compiled install writes src/components/zubra/pricing-block.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed , with the plain elements of the components it's made of; it's smaller on a page with one to three components, the shared runtime with more.

Usage

index.html
<pricing-block
  heading="Simple pricing"
  intro="Start free. Upgrade when your group grows."
></pricing-block>

<script type="module">
  import './components/zubra/pricing-block.js';

  const element = document.querySelector('pricing-block');
  element.plans = [
    {
      id: 'free',
      name: 'Free',
      description: 'For trying it out',
      monthly: 0,
      yearly: 0,
      features: ['One project', 'Up to 3 people', 'Community help'],
      cta: 'Start free',
    },
    {
      id: 'team',
      name: 'Team',
      description: 'For small groups',
      monthly: 12,
      yearly: 120,
      features: ['Unlimited projects', 'Up to 10 people', 'Email help'],
      featured: true,
    },
    {
      id: 'org',
      name: 'Organisation',
      description: 'For bigger groups',
      monthly: 49,
      yearly: 490,
      features: ['Everything in Team', 'Single sign-on', 'Priority help'],
      cta: 'Talk to us',
    },
  ];
  element.addEventListener('periodchange', (event) => console.log('periodchange', event.detail));
  element.addEventListener('choose', (event) => console.log('choose', event.detail));
</script>
Example.jsx
import './components/zubra/pricing-block.js';

const plans = [
  {
    id: 'free',
    name: 'Free',
    description: 'For trying it out',
    monthly: 0,
    yearly: 0,
    features: ['One project', 'Up to 3 people', 'Community help'],
    cta: 'Start free',
  },
  {
    id: 'team',
    name: 'Team',
    description: 'For small groups',
    monthly: 12,
    yearly: 120,
    features: ['Unlimited projects', 'Up to 10 people', 'Email help'],
    featured: true,
  },
  {
    id: 'org',
    name: 'Organisation',
    description: 'For bigger groups',
    monthly: 49,
    yearly: 490,
    features: ['Everything in Team', 'Single sign-on', 'Priority help'],
    cta: 'Talk to us',
  },
];

export function PricingBlockExample() {
  return (
    <pricing-block
      heading="Simple pricing"
      intro="Start free. Upgrade when your group grows."
      plans={plans}
      onperiodchange={(event) => console.log('periodchange', event.detail)}
      onchoose={(event) => console.log('choose', event.detail)}
    ></pricing-block>
  );
}
Example.vue
<script setup>
import './components/zubra/pricing-block.js';
const plans = [
  {
    id: 'free',
    name: 'Free',
    description: 'For trying it out',
    monthly: 0,
    yearly: 0,
    features: ['One project', 'Up to 3 people', 'Community help'],
    cta: 'Start free',
  },
  {
    id: 'team',
    name: 'Team',
    description: 'For small groups',
    monthly: 12,
    yearly: 120,
    features: ['Unlimited projects', 'Up to 10 people', 'Email help'],
    featured: true,
  },
  {
    id: 'org',
    name: 'Organisation',
    description: 'For bigger groups',
    monthly: 49,
    yearly: 490,
    features: ['Everything in Team', 'Single sign-on', 'Priority help'],
    cta: 'Talk to us',
  },
];
const onPeriodchange = (event) => console.log('periodchange', event.detail);
const onChoose = (event) => console.log('choose', event.detail);
</script>

<template>
  <pricing-block
    heading="Simple pricing"
    intro="Start free. Upgrade when your group grows."
    :plans.prop="plans"
    @periodchange="onPeriodchange"
    @choose="onChoose"
  ></pricing-block>
</template>

<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) -->
Example.svelte
<script>
  import './components/zubra/pricing-block.js';
  const plans = [
    {
      id: 'free',
      name: 'Free',
      description: 'For trying it out',
      monthly: 0,
      yearly: 0,
      features: ['One project', 'Up to 3 people', 'Community help'],
      cta: 'Start free',
    },
    {
      id: 'team',
      name: 'Team',
      description: 'For small groups',
      monthly: 12,
      yearly: 120,
      features: ['Unlimited projects', 'Up to 10 people', 'Email help'],
      featured: true,
    },
    {
      id: 'org',
      name: 'Organisation',
      description: 'For bigger groups',
      monthly: 49,
      yearly: 490,
      features: ['Everything in Team', 'Single sign-on', 'Priority help'],
      cta: 'Talk to us',
    },
  ];
</script>

<pricing-block
  heading="Simple pricing"
  intro="Start free. Upgrade when your group grows."
  {plans}
  onperiodchange={(event) => console.log('periodchange', event.detail)}
  onchoose={(event) => console.log('choose', event.detail)}
></pricing-block>
example.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/pricing-block.js';

@Component({
  selector: 'app-pricing-block-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <pricing-block
      heading="Simple pricing"
      intro="Start free. Upgrade when your group grows."
      [plans]="plans"
      (periodchange)="onPeriodchange($event)"
      (choose)="onChoose($event)"
    ></pricing-block>
  `,
})
export class PricingBlockExample {
  plans = [
    {
      id: 'free',
      name: 'Free',
      description: 'For trying it out',
      monthly: 0,
      yearly: 0,
      features: ['One project', 'Up to 3 people', 'Community help'],
      cta: 'Start free',
    },
    {
      id: 'team',
      name: 'Team',
      description: 'For small groups',
      monthly: 12,
      yearly: 120,
      features: ['Unlimited projects', 'Up to 10 people', 'Email help'],
      featured: true,
    },
    {
      id: 'org',
      name: 'Organisation',
      description: 'For bigger groups',
      monthly: 49,
      yearly: 490,
      features: ['Everything in Team', 'Single sign-on', 'Priority help'],
      cta: 'Talk to us',
    },
  ];

  onPeriodchange(event: Event) {
    console.log('periodchange', (event as CustomEvent).detail);
  }

  onChoose(event: Event) {
    console.log('choose', (event as CustomEvent).detail);
  }
}

API

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
plans
property only
{ id, name, description, monthly, yearly, features, cta }[][]
period"monthly" | "yearly""monthly"
currencystring"USD"
localestring""
headingstring"Pricing"
introstring""
Events
EventWhen
periodchangeThe billing period changed; detail is "monthly" or "yearly".
chooseA plan was chosen; detail is { plan, period } (the plan's id).

Size

2.2 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 18.8 KB.

Theme

Every component reads shadcn/ui's CSS variables, so any shadcn theme works. Pick a look or a colour, or paste a theme's CSS.

Look: colours, fonts, corners and motion

Accent colour