Community Header Widget – React SDK

Install the Community Header Widget as an NPM package for first-class React (and TypeScript) support. Displays community stats, search bar, and online member indicator.

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 { LegionCommunityHeader } from '@legionhandtech/lht-react-widgets'; 2 3function App() { 4 return ( 5 <LegionCommunityHeader 6 baseUrl="https://your-legion-domain.com" 7 title="My Community" 8 theme="light" 9 /> 10 ); 11}

You can also import from the dedicated sub-path:

import { LegionCommunityHeader } from '@legionhandtech/lht-react-widgets/community-header';

Props Reference

Core Props

PropTypeDefaultDescription
baseUrlstringrequiredBase URL of your Legion deployment
titlestring"Community"Community title
showSearchbooleantrueShow search bar
showStatsbooleantrueShow stats section
showOnlinebooleantrueShow online count
communityUrlstringCommunity URL prefix
theme"light" | "dark""light"Theme preset
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 18 theming props are optional. Here are the most commonly used ones:

PropCSS VariableExample
headerPrimaryColor--header-primary-color"#228be6"
headerBackgroundColor--header-background-color"#ffffff"
headerTextColor--header-text-color"#1a1b1e"
headerSearchBg--header-search-bg"#f1f3f5"
headerSearchRadius--header-search-radius"8px"
headerStatBg--header-stat-bg"#f8f9fa"
headerFontFamily--header-font-family"Inter, sans-serif"
headerTitleSize--header-title-size"1.5rem"

See the TypeScript CommunityHeaderThemingProps interface for the complete list.

Imperative Ref API

1import { useRef } from 'react'; 2import { LegionCommunityHeader, LegionCommunityHeaderHandle } from '@legionhandtech/lht-react-widgets'; 3 4function App() { 5 const widgetRef = useRef<LegionCommunityHeaderHandle>(null); 6 7 return ( 8 <> 9 <button onClick={() => widgetRef.current?.refresh()}> 10 Refresh Header 11 </button> 12 <LegionCommunityHeader 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-header-web-component';
1<legion-community-header 2 api-url="https://your-legion-domain.com" 3 title="My Community" 4 theme="light"> 5</legion-community-header>

TypeScript

1import type { 2 CommunityHeaderWidgetProps, 3 CommunityHeaderThemingProps, 4 LegionCommunityHeaderHandle, 5} from '@legionhandtech/lht-react-widgets';

Callbacks

onLoad

1<LegionCommunityHeader 2 baseUrl="https://your-legion-domain.com" 3 onLoad={(detail) => { 4 console.log(detail.widget); // "community-header" 5 console.log(detail.theme); // "light" | "dark" 6 }} 7/>

onError

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