@buyloop/pricing-tiers
v0.3.7
Published
The `PricingTiers` component is a React component for rendering a pricing list using Buyloop's public API. It allows you to display pricing information for different tiers, and you can customize its behavior with various properties.
Downloads
1
Readme
Buyloop PricingTiers Component Documentation
The PricingTiers
component is a React component for rendering a pricing list using Buyloop's public API. It allows you to display pricing information for different tiers, and you can customize its behavior with various properties.
Installation
You can install the PricingTiers
component via npm:
npm install @buyloop/pricing-tiers
Usage
Import the PricingTiers
component into your React application and use it as follows:
import PricingTiers from "@buyloop/pricing-tiers";
function MyApp() {
return (
<PricingTiers
buyloop-api-key={"your_buyloop_public_api_key"}
pricingTemplateId={"your_pricing_template_id"}
language={language}
callbackFunction={(pricingTier, selectedPrice) =>
console.log(`Price tier selected: ${pricingTier.displayName}, price: ${selectedPrice.value}${selectedPrice.currency}`)}
showUnavailableFeatures={true} // Optional, set to true to display unavailable features with strikethrough
/>
);
}
Make sure to replace "your_buyloop_public_api_key" and "your_pricing_template_id" with your actual API key and pricing template ID.
Properties
The PricingTiers
component accepts the following properties:
buyloop-api-key
(string, required): Your Buyloop public API key, which can be generated in the "Developers" section of the Buyloop admin UI.pricingTemplateId
(string, required): The ID of the pricing template to render.language
(string, required): The language to render in ISO 639-1 code formatcallbackFunction
(function, required): A callback function that will be called once a pricing tier is selected. It receives the selected PricingTier as an input argument. You can customize the behavior in this function.showUnavailableFeatures
(boolean, optional): If set to true, unavailable features on tiers will be rendered with strikethrough. If set to false, they will not be displayed. Default is false.
Styling the Component
The PricingTiers
component uses standard Material-UI components and can be styled in various ways to match your application's design. You can apply styles globally through your application's theme, create a dedicated theme for the PricingTiers
component, or directly use CSS to customize its appearance.
Global Theme Styling
To style the PricingTiers
component using your application's global theme, you can define the styling options in your theme configuration. Here's an example of how to customize the component using the global theme:
const theme = createTheme({
palette: {
mode: 'light',
primary: {
main: '#8DDFCB',
contrastText: '#82A0D8',
},
secondary: {
main: '#ECEE81',
},
text: {
primary: '#414141',
secondary: '#555555',
disabled: '#E2E2E2',
},
background: {
paper: '#EDB7ED',
},
error: {
main: '#ac350c',
},
},
typography: {
fontFamily: 'courier',
h1: {
fontSize: '5rem',
fontWeight: 400,
},
h2: {
fontSize: '4rem',
fontWeight: 600,
color: '#8DDFCB'
},
button: {
textTransform: 'uppercase'
},
},
components: {
MuiCard: {
styleOverrides: {
root: {
border: "2px solid",
borderColor: "#82A0D8",
}
}
},
MuiButton: {
styleOverrides: {
root: {
border: "2px solid",
borderColor: "#82A0D8",
}
}
},
}
});