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.
npm install @legionhandtech/lht-react-widgetsReact 17+ is a peer dependency. If your project already has React installed you're good to go.
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';| Prop | Type | Default | Description |
|---|---|---|---|
baseUrl | string | required | Base URL of your Legion deployment |
title | string | "Community" | Community title |
showSearch | boolean | true | Show search bar |
showStats | boolean | true | Show stats section |
showOnline | boolean | true | Show online count |
communityUrl | string | — | Community URL prefix |
theme | "light" | "dark" | "light" | Theme preset |
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 18 theming props are optional. Here are the most commonly used ones:
| Prop | CSS Variable | Example |
|---|---|---|
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.
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}| Method | Description |
|---|---|
refresh() | Reloads the widget iframe |
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>1import type {
2 CommunityHeaderWidgetProps,
3 CommunityHeaderThemingProps,
4 LegionCommunityHeaderHandle,
5} from '@legionhandtech/lht-react-widgets';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/>1<LegionCommunityHeader
2 baseUrl="https://your-legion-domain.com"
3 onError={(message) => console.error(message)}
4/>