Cost Badge

What a run costs your user, shown where they commit to it, and whether their balance covers it.

8 credits

In use

Beside submit in every studio, priced from the exact request about to be sent. It turns red over the balance.

Lumen
CreateEditVideo
240 credits

Your image will appear here

Your image will appear here

Your image will appear here

Your image will appear here

16 credits

Installation

pnpm dlx shadcn@latest add https://mgp.paukraft.com/r/cost-badge.json

CostBadge

Costs are yours, not BFL's: work them out from the run's settings, e.g. times the image count or the resolution's megapixels. A submission's response carries BFL's own cost in its credits, for your margins.

PropTypeDefault
costnumber

What the run costs your user, in your unit.

—
balancenumber

What they can spend. Over it, the badge turns destructive, sets data-unaffordable and tells screen readers.

—
format(cost: number) => ReactNode

Labels the cost: "8 credits", "$0.40", …

formatCredits
variant"default" | "inline"

default is a tag tinted by the color it sits on, e.g. beside a submit button; inline is plain text, for "Upscale 8 credits" inside a button.

"default"
unaffordableLabelstring

Read after the cost when over balance.

"more than your balance"
childrenReactNode

Before the cost, e.g. a coin icon.

—

Helpers

PropTypeDefault
formatCredits(cost: number) => string

The default label: 1 credit, 4 credits. The Model Picker uses it too.

—
canAfford(cost: number, balance?: number) => boolean

Whether cost fits in balance, e.g. to disable the action beside the badge.

—