Install the Community Groups Widget as an NPM package for first-class React (and TypeScript) support. Displays trending community groups with avatars, member counts, and configurable layouts.
npm install @legionhandtech/lht-react-widgetsReact 17+ is a peer dependency. If your project already has React installed you're good to go.
1import { LegionCommunityGroups } from '@legionhandtech/lht-react-widgets';
2
3function App() {
4 return (
5 <LegionCommunityGroups
6 baseUrl="https://your-legion-domain.com"
7 count={6}
8 layout="grid"
9 theme="light"
10 />
11 );
12}You can also import from the dedicated sub-path:
import { LegionCommunityGroups } from '@legionhandtech/lht-react-widgets/community-groups';| Prop | Type | Default | Description |
|---|---|---|---|
baseUrl | string | required | Base URL of your Legion deployment |
count | number | 6 | Number of groups to display (1–20) |
layout | "grid" | "list" | "grid" | Layout mode |
theme | "light" | "dark" | "light" | Theme preset |
showViewAll | boolean | true | Show "View all" link |
communityUrl | string | "/community" | Community URL prefix |
viewAllUrl | string | "{communityUrl}/groups" | URL for "View all" link |
sortBy | "trending" | "popular" | "recent" | "trending" | Sort order |
width | string | "100%" | Widget width (CSS value) |
height | string | "auto" | Widget height (CSS value) |
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 19 theming props are optional. Here are the most commonly used ones:
| Prop | CSS Variable | Example |
|---|---|---|
groupsPrimaryColor | --groups-primary-color | "#228be6" |
groupsBackgroundColor | --groups-background-color | "#ffffff" |
groupsTextColor | --groups-text-color | "#1a1b1e" |
groupsCardBg | --groups-card-bg | "#ffffff" |
groupsCardRadius | --groups-card-radius | "8px" |
groupsAvatarSize | --groups-avatar-size | "48px" |
groupsFontFamily | --groups-font-family | "Inter, sans-serif" |
groupsGridGap | --groups-grid-gap | "16px" |
See the TypeScript CommunityGroupsThemingProps interface for the complete list.
1import { useRef } from 'react';
2import { LegionCommunityGroups, LegionCommunityGroupsHandle } from '@legionhandtech/lht-react-widgets';
3
4function App() {
5 const widgetRef = useRef<LegionCommunityGroupsHandle>(null);
6
7 return (
8 <>
9 <button onClick={() => widgetRef.current?.refresh()}>
10 Refresh Groups
11 </button>
12 <LegionCommunityGroups
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/community-groups-web-component';1<legion-community-groups
2 api-url="https://your-legion-domain.com"
3 count="6"
4 layout="grid"
5 theme="light">
6</legion-community-groups>1import type {
2 CommunityGroupsWidgetProps,
3 CommunityGroupsThemingProps,
4 LegionCommunityGroupsHandle,
5} from '@legionhandtech/lht-react-widgets';1<LegionCommunityGroups
2 baseUrl="https://your-legion-domain.com"
3 onLoad={(detail) => {
4 console.log(detail.widget); // "community-groups"
5 console.log(detail.count); // 6
6 console.log(detail.theme); // "light" | "dark"
7 }}
8/>1<LegionCommunityGroups
2 baseUrl="https://your-legion-domain.com"
3 onError={(message) => console.error(message)}
4/>