shadcn.io is not affiliated with official shadcn/ui
Annual Discount Billing Block for Svelte
What yearly billing really saves on one account: the headline 20% beside the effective percent, worked out from the next twelve months in four lines you can tick, and a Monthly / Yearly projected total.
Installation
Overview
Show the discount a customer will actually get, not the one on the pricing page, with this yearly billing section for Svelte with Ark UI. A hairline frame with a plus mark on each corner holds three bands. Two figure cells set the headline discount, 20%, beside the effective one on this account. Under them a table lays out the next 12 months in four lines (base plan, seats, usage and add-ons) with a Checkbox per line for "Discount applies"; usage is never discounted, so its box is fixed off. Ticking a line re-derives the effective percent, the saving and the yearly total. A Segment Group switches the projected total for next year between Monthly and Yearly, and the only Shine Button, "Switch to yearly, save $98.40", sits in a foot with a status line. Built with Checkbox, Segment Group and Guides. For note, design and dev tools that sell a yearly plan.
FAQ
How do I fill it from my billing provider?
LINES at the top of the file holds one entry per line of the next twelve months in cents: its name, a note, year (what it costs over the term at today's set-up) and covered, whether the discount can apply to it. HEADLINE is the percent your yearly plan advertises. The effective percent, the saving and the yearly column are derived from them, so a different plan needs no other change.
Why is the effective discount lower than 20%?
Because a yearly discount only touches the lines it covers. Here usage is billed at the monthly rate whatever the cycle, so 20% of $492 is $98.40, which is 17% of the $588 the account is expected to pay. The table shows each line both ways so the gap is visible, and unticking a line shows what the discount would be without it.
Why can't I tick usage?
Usage is the one line the discount does not cover, so its checkbox is disabled and a hidden sentence tells screen readers "Usage is not discounted." It is also an estimate: it is shown at this month's rate, and the real figure moves with use.
What does the button do?
It only answers in the status line: "Scheduled in this demo only." Nothing is saved or charged. In your app, send the ticked lines to your billing provider in schedule, change the plan at the renewal and show the provider's answer in the same status line. The button is aria-disabled rather than disabled when nothing is ticked, so it stays focusable and says why.