Community Groups Widget – React SDK

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.

Installation

npm install @legionhandtech/lht-react-widgets

React 17+ is a peer dependency. If your project already has React installed you're good to go.

Quick Start

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';

Props Reference

Core Props

PropTypeDefaultDescription
baseUrlstringrequiredBase URL of your Legion deployment
countnumber6Number of groups to display (1–20)
layout"grid" | "list""grid"Layout mode
theme"light" | "dark""light"Theme preset
showViewAllbooleantrueShow "View all" link
communityUrlstring"/community"Community URL prefix
viewAllUrlstring"{communityUrl}/groups"URL for "View all" link
sortBy"trending" | "popular" | "recent""trending"Sort order
widthstring"100%"Widget width (CSS value)
heightstring"auto"Widget height (CSS value)
classNamestringCSS class applied to the outer container
styleReact.CSSPropertiesInline styles merged into the container
onLoad(detail) => voidCalled when the widget iframe finishes loading
onError(message: string) => voidCalled if the widget iframe fails to load

Theming Props (selection)

All 19 theming props are optional. Here are the most commonly used ones:

PropCSS VariableExample
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.

Imperative Ref API

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}
MethodDescription
refresh()Reloads the widget iframe

Web Component (from NPM)

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>

TypeScript

1import type { 2 CommunityGroupsWidgetProps, 3 CommunityGroupsThemingProps, 4 LegionCommunityGroupsHandle, 5} from '@legionhandtech/lht-react-widgets';

Callbacks

onLoad

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/>

onError

1<LegionCommunityGroups 2 baseUrl="https://your-legion-domain.com" 3 onError={(message) => console.error(message)} 4/>
Documentation | Legion Hand Technologies