Promotional Card
Highlight announcements and offers
npm run add PromotionalCardUse the PromotionalCard component to highlight announcements and offers in a visually compelling way. They can increase visibility and improve engagement. Use them to announce product launches, events, or new features, or to highlight discounts, limited-time deals, or seasonal campaigns.

---const promotionalCardProps = { img: { src: '/img/featured.png', alt: 'Featured image', height: 150, width: 500 }, badge: { text: 'New components', theme: 'success', rounded: true, small: true }, buttons: [{ text: 'See changes ->', theme: 'secondary' }], meta: 'v1.2.0 • 2024 March 12', title: 'New Release', secondary: true}---
<PromotionalCard {...promotionalCardProps}> <span class="muted">Introducing new components for our library!</span></PromotionalCard>The PromotionalCard component accepts a number of different props, including:
img: Defines a featured image for the component. You can use thesrc,alt,width, andheightattributes to set the attributes of your image. You can also set thelazyproperty totrueto lazy load the image.badge: Defines a badge above the title. For this object, you can use the props of aBadgecomponent, along with atextproperty to set the text of the badge, and aniconproperty to assign an icon for the badge. Theiconprop can take the value of an SVG string, or use one of the icon types defined here.buttons: Defines a list of buttons. You can use the props of aButtoncomponent, along with atextandiconproperty in a similar way to thebadgeprop.meta: Defines additional text shown next to the badge.title: Defines the title of the promotional card.secondary: ThePromotionalCardcomponent extends theCardcomponent, meaning you can use anyCardprop on yourPromotionalCardto customize its appearance. Thesecondaryprop is specific to theCardcomponent.
Using images, badges, meta details, and buttons are optional, meaning you can use this component in various configurations:
Promotional Popup
You can combine the PromotionalCard component with a transparent Modal component to create promotional popups. To achieve this, simply pass your PromotionalCard inside a Modal component in the following way:
---import { Button, Modal } from 'webcoreui/astro'---
<Button className="popup-trigger">Show Promotional Popup</Button>
<Modal className="popup" transparent={true} showCloseIcon={false}> <PromotionalCard {...props}>...</PromotionalCard></Modal>
<script> import { modal } from 'webcoreui'
modal({ trigger: '.popup-trigger', modal: '.popup' })</script>You can also assign the modal instance to a variable and call modal.open to trigger the modal programmatically via JavaScript. You can read more about how to work with the Modal component in its documentation.
API
type PromotionalCardProps = { img?: { src: string alt: string width: number height: number lazy?: boolean } badge?: ({ text: string icon?: string } & BadgeProps) meta?: string title: string buttons?: ({ text: string icon?: string } & ButtonProps)[] className?: string} & CardPropsYou can find more details about the different prop types on the following pages:
| Prop | Purpose |
|---|---|
img | Sets a thumbnail image for the card. |
img.src | 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 enable lazy loading for the image. |
badge | Sets a badge above the title. |
badge.text | Sets the text for the badge. |
badge.icon | Sets an icon for the badge. You can pass SVG strings, or an icon type for Astro components. |
meta | Sets additional text next to the badge. |
title | Sets the title of the card. |
buttons | Sets CTA buttons at the bottom of the card. |
buttons.text | Sets the label for the CTAs. |
buttons.icon | Sets an icon for the CTAs. You can pass SVG strings, or an icon type for Astro components. |
className | Pass additional CSS classes for the PromotionalCard component. |