Data displayPricingPlan
Searchastronomic.dev# PricingPlan
For one plan in a Pricing section: its name, price, features and action, on a card. The pricing recipes use it for you.
Static: no JavaScript.
## Usage
```astro
import PricingPlan from "@astronomic/ui-pro/components/PricingPlan.astro";
```
## Examples
### In a Pricing list
Two plans in a Pricing list: one highlighted, with a badge and a description, one with only a price, one feature and an action. The pricing recipes build their plans from it, so you only need it for your own layout.
```astro
---
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
import Pricing from "@astronomic/ui-pro/components/Pricing.astro";
import PricingPlan from "@astronomic/ui-pro/components/PricingPlan.astro";
const heading = "Plans";
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-6xl">
<Pricing heading={heading} listClass="gap-cards @3xl/pricing:grid-cols-2">
<li class="grid min-w-0">
<PricingPlan
name="Studio"
price="$12,000"
period="one time"
description="A highlighted plan: the accent edge, the badge and the primary button."
features={["Brand refresh and style guide", "Up to fifteen pages", "Editor training for your team"]}
action={{ label: "Choose Studio", href: "#studio" }}
highlighted
badge="Popular"
headingTag={tag}
/>
</li>
<li class="grid min-w-0">
<PricingPlan name="Only the essentials" price="Free" features={["A name, a price, one feature and an action"]} action={{ label: "Start free", href: "#free" }} headingTag={tag} />
</li>
</Pricing>
</div>
```
### Not on sale yet
A plan you cannot sell yet: action.disabled renders a disabled button, never a link, and action.note says why under it. A live plan beside it shows a note under its link too.
```astro
---
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
import Pricing from "@astronomic/ui-pro/components/Pricing.astro";
import PricingPlan from "@astronomic/ui-pro/components/PricingPlan.astro";
const heading = "Plans";
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-6xl">
<Pricing heading={heading} listClass="gap-cards @3xl/pricing:grid-cols-2">
<li class="grid min-w-0">
<PricingPlan
name="Studio"
price="$12,000"
period="one time"
features={["Brand refresh and style guide", "Up to fifteen pages"]}
action={{ label: "Choose Studio", href: "#studio", note: "One-time payment" }}
headingTag={tag}
/>
</li>
<li class="grid min-w-0">
<PricingPlan
name="Studio Plus"
price="$18,000"
period="one time"
features={["Everything in Studio", "Up to thirty pages", "Editor training for your team"]}
action={{ label: "Choose Studio Plus", disabled: true, note: "Coming soon" }}
highlighted
badge="New"
headingTag={tag}
/>
</li>
</Pricing>
</div>
```
## Props
### PricingPlan
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `name` | `string` | None | Required. The plan name, in the heading role in display type. |
| `price` | `string` | None | Required. The price as shown, such as "$49" or "Free", in the price role in display type, sized to its line and to the list's widest price (priceEms), so any currency or wording fits. A price with spaces wraps between its words, never inside a number. |
| `period` | `string` | None | After the price, such as "per month" or "one time", in the small role, muted. |
| `regularPrice` | `string` | None | The usual price during a sale, as shown, such as "$199": after the price, struck through, in the body role, muted, in a <del>. Set it only while the sale runs, and say how long the sale lasts (in period, for example). |
| `regularPriceLabel` | `string` | `"Regular price"` | The words a screen reader hears before the struck price (hidden on screen), so it is never heard as the price. |
| `priceNote` | `string` | None | A short note beside the price, such as "Save $50", in a Badge at the end of the price line. The name ListingCard uses for its note beside the price. |
| `description` | `string` | None | A short line under the price, in the body role, muted. |
| `features` | `string[]` | None | Required. What the plan includes: a list, each with a check in the accent, under a hairline. |
| `action` | `PricingPlanAction` | None | Required. The button: { label, href?, variant?, disabled?, note? }. Without variant it is primary when highlighted, else secondary. disabled renders a disabled <button>, never a link, for a plan you cannot sell yet: the plan drops the href and passes disabled to the kit Button, so it behaves as Button does. href is required unless disabled (a type error otherwise). note is a short line under the button that says why, such as "Coming soon", and describes it to a screen reader. |
| `highlighted` | `boolean` | `false` | The plan to point at: an accent edge and a primary button. Give it a badge too, so it is not marked by color alone. |
| `badge` | `string` | None | A short word beside the name, such as "Popular". A Badge. |
| `headingTag` | `"h2" \| "h3" \| "h4" \| "h5"` | None | Required. The plan name element. Pass childHeadingTag({ heading, headingTag }) from lib/heading.ts, one level under the section heading. |
| `priceEms` | `number` | `its own price's width` | For recipes. The widest price in the plan's list, in em (widestStatEms() in the kit's lib/stat.ts), so every price in the list takes the size at which the widest fits. |
| `summaryClass` | `string` | None | For recipes. Classes for the summary box (the name, badge, price and description). |
| `featuresClass` | `string` | None | For recipes. Classes for the feature list. |
| `actionClass` | `string` | None | For recipes. Classes for the box around the button. |
| `class` | `string` | None | More classes for the card, merged with cn(), so yours win on conflicts. Each plan is a named size container (pricing-plan), and its price line one of its own, so the price sizes to the room it has. The boxes sit a block apart, and the features take the free height, so in a row of cards the buttons line up. |
Any other attribute goes on the card (a <div>).
## Accessibility
- Renders one card (a <div>): put it in an <li> in a Pricing list, or alone with the shell's list={false}.
- The plan name is the heading level you pass. Use childHeadingTag so it sits one level under the section heading.
- The features are a list (<ul role="list">); the check icons are hidden from a screen reader.
- The highlighted plan is marked by its badge text, not by color alone.
- Give the action a label that names the plan, like "Choose Studio", so the link makes sense out of context.
- A struck regular price is a <del> that starts with regularPriceLabel for a screen reader only, so it hears "Regular price $199", not a second price. The strike is not the only cue: the sale price comes first and the note says the saving.
- A disabled action is a real disabled <button>, so it cannot be followed or pressed. Its note is linked to it with aria-describedby, so a screen reader hears why.
PricingPlan
ProFor one plan in a Pricing section: its name, price, features and action, on a card. The pricing recipes use it for you.
- File
- PricingPlan.astro
- Group
- Data display
- Kind
- Static: no JavaScript
- Examples
- 2
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
In a Pricing list
Two plans in a Pricing list: one highlighted, with a badge and a description, one with only a price, one feature and an action. The pricing recipes build their plans from it, so you only need it for your own layout.
Plans
Studio
Popular$12,000one time
A highlighted plan: the accent edge, the badge and the primary button.
- Brand refresh and style guide
- Up to fifteen pages
- Editor training for your team
examples/pricingplan/main.astro
---
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
import Pricing from "@astronomic/ui-pro/components/Pricing.astro";
import PricingPlan from "@astronomic/ui-pro/components/PricingPlan.astro";
const heading = "Plans";
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-6xl">
<Pricing heading={heading} listClass="gap-cards @3xl/pricing:grid-cols-2">
<li class="grid min-w-0">
<PricingPlan
name="Studio"
price="$12,000"
period="one time"
description="A highlighted plan: the accent edge, the badge and the primary button."
features={["Brand refresh and style guide", "Up to fifteen pages", "Editor training for your team"]}
action={{ label: "Choose Studio", href: "#studio" }}
highlighted
badge="Popular"
headingTag={tag}
/>
</li>
<li class="grid min-w-0">
<PricingPlan name="Only the essentials" price="Free" features={["A name, a price, one feature and an action"]} action={{ label: "Start free", href: "#free" }} headingTag={tag} />
</li>
</Pricing>
</div>Not on sale yet
A plan you cannot sell yet: action.disabled renders a disabled button, never a link, and action.note says why under it. A live plan beside it shows a note under its link too.
Plans
Studio Plus
New$18,000one time
- Everything in Studio
- Up to thirty pages
- Editor training for your team
Coming soon
examples/pricingplan/soon.astro
---
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
import Pricing from "@astronomic/ui-pro/components/Pricing.astro";
import PricingPlan from "@astronomic/ui-pro/components/PricingPlan.astro";
const heading = "Plans";
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-6xl">
<Pricing heading={heading} listClass="gap-cards @3xl/pricing:grid-cols-2">
<li class="grid min-w-0">
<PricingPlan
name="Studio"
price="$12,000"
period="one time"
features={["Brand refresh and style guide", "Up to fifteen pages"]}
action={{ label: "Choose Studio", href: "#studio", note: "One-time payment" }}
headingTag={tag}
/>
</li>
<li class="grid min-w-0">
<PricingPlan
name="Studio Plus"
price="$18,000"
period="one time"
features={["Everything in Studio", "Up to thirty pages", "Editor training for your team"]}
action={{ label: "Choose Studio Plus", disabled: true, note: "Coming soon" }}
highlighted
badge="New"
headingTag={tag}
/>
</li>
</Pricing>
</div>