Install the Campaigns Carousel Widget as an NPM package for first-class React (and TypeScript) support. Features gradient-styled campaign cards with configurable display limits and expiration badges.
npm install @legionhandtech/lht-react-widgetsReact 17+ is a peer dependency. If your project already has React installed you're good to go.
1import { LegionCampaignsCarousel } from '@legionhandtech/lht-react-widgets';
2
3function App() {
4 return (
5 <LegionCampaignsCarousel
6 baseUrl="https://your-legion-domain.com"
7 maxCampaigns={5}
8 theme="light"
9 />
10 );
11}You can also import from the dedicated sub-path:
import { LegionCampaignsCarousel } from '@legionhandtech/lht-react-widgets/campaigns-carousel';| Prop | Type | Default | Description |
|---|---|---|---|
baseUrl | string | required | Base URL of your Legion deployment |
apiKey | string | — | API key for authorization |
maxCampaigns | number | 5 | Maximum campaigns to show |
showExpiration | boolean | true | Whether to show expiration dates |
theme | "light" | "dark" | "light" | Theme preset |
width | string | "100%" | Widget width (CSS value) |
height | number | 280 | Widget height in pixels |
className | string | — | CSS class applied to the outer container |
style | React.CSSProperties | — | Inline styles merged into the container |
onLoad | (detail) => void | — | Called when the widget iframe finishes loading |
onError | (message: string) => void | — | Called if the widget iframe fails to load |
All 8 theming props are optional. Unlike other widgets, the carousel uses camelCase parameters.
| Prop | Query Param | Example |
|---|---|---|
panelStart | panelStart | "#1a1b5e" |
panelMid | panelMid | "#2d2f8e" |
panelEnd | panelEnd | "#4a4dc4" |
panelShadow | panelShadow | "0 4px 12px rgba(0,0,0,0.3)" |
titleSize | titleSize | "1.5rem" |
descriptionSize | descriptionSize | "0.9rem" |
titleShadow | titleShadow | "0 2px 4px rgba(0,0,0,0.5)" |
descriptionShadow | descriptionShadow | "0 1px 2px rgba(0,0,0,0.3)" |
See the TypeScript CampaignsCarouselThemingProps interface for the complete list.
1import { useRef } from 'react';
2import { LegionCampaignsCarousel, LegionCampaignsCarouselHandle } from '@legionhandtech/lht-react-widgets';
3
4function App() {
5 const widgetRef = useRef<LegionCampaignsCarouselHandle>(null);
6
7 return (
8 <>
9 <button onClick={() => widgetRef.current?.refresh()}>
10 Refresh Campaigns
11 </button>
12 <LegionCampaignsCarousel
13 ref={widgetRef}
14 baseUrl="https://your-legion-domain.com"
15 />
16 </>
17 );
18}| Method | Description |
|---|---|
refresh() | Reloads the widget iframe |
import '@legionhandtech/lht-react-widgets/campaigns-carousel-web-component';1<legion-campaigns-carousel
2 api-url="https://your-legion-domain.com"
3 max-campaigns="5"
4 theme="light">
5</legion-campaigns-carousel>1import type {
2 CampaignsCarouselWidgetProps,
3 CampaignsCarouselThemingProps,
4 LegionCampaignsCarouselHandle,
5} from '@legionhandtech/lht-react-widgets';1<LegionCampaignsCarousel
2 baseUrl="https://your-legion-domain.com"
3 onLoad={(detail) => {
4 console.log(detail.widget); // "campaigns-carousel"
5 console.log(detail.maxCampaigns); // 5
6 console.log(detail.theme); // "light" | "dark"
7 }}
8/>1<LegionCampaignsCarousel
2 baseUrl="https://your-legion-domain.com"
3 onError={(message) => console.error(message)}
4/>