Search documentation v0.9.0

Fund Raising Card

Collect donations from users for campaigns

Source ↗️ Report Issue ↗️

Use the FundRaisingCard component to highlight fundraising campaigns and encourage donations or support using call to actions. Use them to promote charity or crowdfunding campaigns or to display donation metrics. The can help increase user engagement and improve transparency.

125 of 300 patrons
42%
Fund Raising Card
Use the FundRaisingCard component to collect donations from users for a campaign.
213 of 300 donators
71%
Themed Fund Raising Card
Use the FundRaisingCard component to collect donations from users for a campaign.
Unlock code
How to use the FundRaisingCard component in Astro
<FundRaisingCard
progress={125}
goal={300}
title="Fund Raising Card"
additionalLabel="patrons"
progressBar={{ label: true }}
buttons={[{ text: 'Donate' }]}
img={{
src: '/img/featured.png',
alt: 'Featured image alt',
height: 175,
width: 300
}}
>
<span class="muted">
Use the <code>FundRaisingCard</code> component to collect donations from users for a campaign.
</span>
</FundRaisingCard>

The FundRaisingCard component has three mandatory props:

The progress bar is automatically created using the progress and goal props. The rest of the props from the above example are optional:

Inside the component, you can pass any other element to build the body of the card.

Cards

The FundRaisingCard component extends the Card component, meaning you can further customize its appearance with any valid CardProps value. Here are some other examples with different styles using card configurations:

125 of 300 patrons
42%
Secondary Fund Raising Card
Use the FundRaisingCard component to collect donations from users for a campaign.
213 of 300 donators
71%
Compact Fund Raising Card
Use the FundRaisingCard component to collect donations from users for a campaign.
Unlock code
How to customize the card
<FundRaisingCard
...
secondary={true}
buttons={[{
text: 'Donate'
}, {
text: 'Share',
theme: 'outline'
}]}
>...</FundRaisingCard>
Unlock code
How to customize the card
<FundRaisingCard
...
compact={true}
progressBar={{
label: true,
color: 'var(--w-color-success)'
}}
>...</FundRaisingCard>

Labels

To customize the label, you can use the progressLabel prop on the card which supports placeholders for the progress and goal props using the {0} and {1} syntax respectively. Take the following as an example:

$125 reached of $300
42%
Custom label with placeholders
This fund raising card has a custom label customized through the progressLabel prop.
We need 175 supporters to maintain this site.
42%
Remaining calculated
This fund raising card has a custom label customized through the progressLabel prop.
Unlock code
How to customize the progress label
<FundRaisingCard
progress={125}
goal={300}
title="Fund Raising Card"
progressBar={{ label: true }}
progressLabel="<b>${0} reached</b> of ${1}"
secondary={true}
>...</FundRaisingCard>
Unlock code
How to customize the progress label
---
const progress = 125
const goal = 300
---
<FundRaisingCard
progress={progress}
goal={goal}
title="Fund Raising Card"
progressBar={{ label: true }}
progressLabel={`We need <b>${goal - progress}</b> supporters to maintain this site.`}
secondary={true}
>...</FundRaisingCard>

Progress

The progressbar itself can also be customized using the progressBar prop. Read the documentation of the Progress component to see all available options for this prop.

125 of 300
Default progress bar
125 of 300
Small, striped progress bar
Unlock code
How to customize the progress bar
<FundRaisingCard
progress={125}
goal={300}
title="Small, striped progress bar"
progressBar={{
striped: true,
square: true,
size: null,
stripeLight: '#B2F78D',
stripeDark: '#70C542',
background: 'var(--w-color-primary-60)'
}}
/>

API

Unlock code
Component API reference
type FundRaisingCardProps = {
img?: {
src: string
alt: string
width: number
height: number
lazy?: boolean
}
progress: number
goal: number
progressLabel?: string
additionalLabel?: string
progressBar?: Omit<ProgressProps, 'value'>
title: string
buttons?: ({
text: string
icon?: string
} & ButtonProps)[]
className?: string
} & CardProps
Please see the documentation of the Card component for the CardProps type, and consult the documentation of the Button and Progress components for the ButtonProps and ProgressProps types.
PropPurpose
img Specifies a image for the card.
img.url Sets the path for the image.
img.alt Sets an alternate text for the image.
img.width Sets the width of the image.
img.height Sets the height of the image.
img.lazy Set to true to lazy load the image.
progress Sets the progress of the fund raising.
goal Sets the goal of the fund raising.
progressLabel Sets a custom text for the progress label. You can use the {0} and {1} placeholders.
additionalLabel Sets additional labels above the progress bar.
title Sets the title of the fund raising card.
buttons Sets CTA buttons at the bottom of the card.
buttons.text Sets the label for the CTA.
buttons.icon Sets an icon for the CTA. You can pass SVG strings, or an icon type for Astro components.
className Pass additional CSS classes for the card.