shadcn.io is not affiliated with official shadcn/ui
Budget Cap Meter Contact Block for React
A grant application split by a hairline: four budget lines that add up against a $50,000 cap in a framed panel with a bar, a project length, a summary with a word count and a form that checks itself.
Installation
Overview
A grant application section for React with Base UI, split by a hairline that meets the page's top rule with a + mark. At the end, the form: four budget lines (staff, equipment, travel, overhead) in number inputs with a dollar sign that add up as you type, a project length in months with steppers, a summary with a live count of words, and an organisation and an email. At the start, behind a framed figure, a panel that sets the total against the call's cap of $50,000: a bar that fills, what remains under the cap or how far over it the total is (with an icon), each line's share and amount, and what one month costs. On a phone the form comes first with a one-line total under the lines, and the panel follows. Submitting checks every field, shows each problem under its field and moves focus to the first one; a valid request turns the form into a confirmation while the panel stays as a record of what was sent. It's built from Number Input, Progress, Textarea, Field, Input, Frame, Guides and Shine Button, with your theme's tokens for every colour. For foundations, public funds and any application that asks for a budget.
FAQ
What happens when the total goes over the cap?
The bar stops at full, the panel's line under the figure turns into "$4,200 over the cap" with an icon, and submitting shows "Bring the total to $50,000 or less: it is $4,200 over." under the budget lines and moves focus to the first line. Nothing stops you typing past the cap, so a visitor can see by how much they are over. The cap is CAP at the top of the file.
How are the shares worked out?
Each line's share of the total is rounded down, then the leftover points go to the lines with the biggest remainders (the largest-remainder method), so the four shares always add up to exactly 100%. The monthly figure is the total divided by the project length, rounded to a dollar.
How do the number inputs behave?
Each budget line takes digits and shows them with thousands separators once you leave the field. The project length takes 1 to 36 months, by typing or with the minus and plus buttons. When a budget line loses focus, one hidden status line says where the total stands ("Total $38,500 of $50,000: $11,500 remaining under the cap"); nothing is announced while you type.
How does the form check what's typed?
The form has noValidate, so the browser's own bubbles stay away and the block shows its own messages. On submit, problems checks that the total is above zero and under the cap, the length is 1 to 36 months, the summary has 15 to 120 words, and the organisation and the email (with an @ and a domain) are filled. Each problem appears under its field with an icon and focus moves to the first one. Leaving a filled field checks it, and editing a field that shows an error re-checks it as you type.
Where does the form send its data?
Nowhere yet. The submit handler waits 800 milliseconds as a stand-in for a request, then shows the confirmation. Replace that timer in submit with your own call: details holds the lines, the length, the summary, the organisation and the email. The confirmation repeats the total, the length and the organisation and says a program officer will write to the address given; it promises nothing else. The call and its cap are made up, and the panel says so.
How does it fit on a phone?
Below lg the split stacks: the header, the form, then the panel. The four lines go two across down to 360 pixels and one per row below, and a one-line total sits under them, so the sum is in view while you type. The framed panel with the bar, the shares and the monthly cost follows the button.
Related
- Pro
Budget Range Slider Contact
Quotes and estimatesA roofing quote request as a card in a card: three kinds of job, a two-thumb budget slider that says in words what the range covers, and a short form that checks itself.
- Pro
Loan Payment Slider Contact
Finance and propertyA personal-loan request for a lender: an amount slider with a tick at each $5,000 and a term to pick, a panel that works the monthly payment out as you move, and a form that checks itself.
- Pro
Document Checklist Contact
Finance and propertyA tax-return checklist as a card in a card: three ways of filing, eight documents with a tag that says which are needed, a bar of the needed ones ready and a switch to send the rest later.
- Pro
Guest Count Ruler Contact
Events and datesAn event-catering request for a caterer: a guest-count slider drawn as a ruler beside the cost per head and the total, then a three-course menu, dietary needs and a short form on ruled bands.
- Pro
Spend by Project Billing
Plan and usageSpend management for a usage-billed product: this period's spend per project, a budget bar with a tick at the alert threshold, the trend against last period, inline budget editing and the account's hard cap.
- Pro
Spend Cap Pricing
CalculatorsSpend controls as a selling point: a circular gauge of spend against a monthly cap set with a slider, email alerts at 50, 80 and 100% of the cap, and the choice of pausing jobs or keeping them running when the cap is reached.