shadcn.io is not affiliated with official shadcn/ui
Amount Presets Donation Contact Block for React
A donation card in card: amount presets in a 2x2 grid beside a custom amount, a monthly switch, an impact line that rolls with the amount, a card-fee box and a total the button repeats.
Installation
Overview
A donation section for React with Base UI for a food bank. A centred header opens on a muted frame with + marks on its corners, and one raised panel inside it in two halves behind a hairline. At the start: four amount presets (a 2x2 grid on a phone, one row from sm), a custom amount in a "$" field, a "Give every month" switch, and an impact panel whose number of meals rolls as the amount changes ("200 meals and a week of groceries for 2 families"). At the end: name, email for the receipt, an unticked "Cover the card fee" box, a short list that adds the gift and the fee into a total, and the Shine Button that repeats the total ("Give $51.50 monthly"). The form is a real one: it checks the amount, name and email on submit, shows each problem under its field, marks the control invalid and moves focus to the first one, then turns into a thank-you in the same space, so the frame never changes height. It's built from Toggle Group, Number Input, Switch, Checkbox, Field, Input, Sliding Number, Frame, Guides, Shine Button and Button, with CSS transitions for the entrances and your theme's tokens for every colour; a chosen preset, the switch and the box fill with the foreground colour so the button stays the one primary. For food banks, schools and any small charity that takes gifts of a few set sizes.
FAQ
How do I change the presets and what a dollar does?
Edit PRESETS for the four amounts, MEALS_PER_DOLLAR for the meals in the big number, and FAMILY_WEEK for the gift that stocks one family's groceries for a week. MIN_GIFT and MAX_GIFT bound the custom field, and FEE_RATE is the card fee a donor can cover. The food bank, its eleven pantries and the rates are invented: use your own figures or drop the claims.
How do the presets and the custom amount work together?
They are one value. A preset writes its amount into the custom field, and typing in the field lights a preset only when the number matches one, so there is never a second, hidden state to disagree with what you see. The field keeps the amount between the minimum and the maximum when you leave it.
Do the amounts and the total read correctly in right-to-left layouts?
Yes. Every price is a single left-to-right span ($50.00), the custom field keeps its "$" in front of the digits, and the sentence under the meal count is isolated with bdi.
Does it take a payment?
No. The submit handler waits 800 milliseconds, then shows the thank-you, which says a payment link will be emailed and nothing is charged until it is used. Replace the timer in submit with a call to your payment provider (it has the amount, the monthly flag and whether the fee is covered). Never collect card numbers in this form yourself.
Why is the card-fee box unticked?
A box that is already ticked adds money without the donor choosing it. Here it starts off, shows the exact fee in its hint, and the list under it says "Greenhaven pays" while it is off.
What does a screen reader get from the controls?
The presets are a named group of single-choice buttons that report which one is chosen, and arrow keys move between them. The switch and the box are named by their visible text, and the custom field is a named, required number field. Each error is attached to its control and the first invalid one takes focus on submit. A status line reads the gift ("$50.00 a month: 200 meals and a week of groceries for 2 families") a moment after the visitor changes it, and the confirmation is a status region that takes focus when it appears.
Related
- Pro
Campaign Planner Fundraiser Contact
Join and giveA fundraising planner as a split: a goal, a length and four channels on one side, a live projection with a bar on the other, and a form that sends the plan to a coach.
- Pro
Intent Router Nonprofit Contact
Join and giveAn "I want to" router for a charity: four radio tiles (donate, volunteer, partner, fundraise), and one form whose first fields change with the choice while the panel keeps its height.
- Pro
Priced Add-ons Sponsorship Contact
Partners and creatorsA sponsorship builder: four priced add-ons with the reach each adds, a live total that rolls, the campaign goal and a form that confirms in place.
- Pro
Credit Top Up Billing
Payment and invoicesA credit wallet: the balance and what it will be after the top-up, amount chips with a custom amount, auto-recharge with a threshold and amount, a pay button with a live total and the recent top-ups.
- Pro
Card in Card Contact
Contact formsA card-in-card contact section for a bookkeeping service: the details of the desk you pick beside a raised form with a live message counter.
- Pro
Minimal Contact Form
Contact formsThe calmest contact form, for a mail client: a centred heading and three fields on the page column with inline validation, a message counter and a one-line thank-you.