Profile Widget – React SDK

Install the Profile Widget (user profile viewer) as an NPM package for first-class React (and TypeScript) support.

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

You can also import from the dedicated sub-path:

import { LegionProfile } from '@legionhandtech/lht-react-widgets/profile';

Props Reference

Core Props

PropTypeDefaultDescription
baseUrlstringrequiredBase URL of your Legion instance
authTokenstringJWT token for authenticated profile viewing (sent via postMessage)
theme"light" | "dark""light"Preset theme
widthstring"400px"Widget width CSS value
heightstring"400px"Widget height CSS value
classNamestringCSS class on the wrapper div
styleReact.CSSPropertiesInline styles on the wrapper div
onLoad(detail) => voidFires when the widget iframe loads
onError(message: string) => voidFires when the widget iframe fails to load

Theming Props

Fine-grained CSS-variable theming. All props are optional strings.

PropCSS VariableDescription
profileBackgroundColorprofile-background-colorContainer background
profileTextColorprofile-text-colorPrimary text color
profileSecondaryTextColorprofile-secondary-text-colorSecondary text
profileBorderColorprofile-border-colorBorder color
profileBorderRadiusprofile-border-radiusContainer radius
profilePaddingprofile-paddingContainer padding
profileShadowprofile-shadowContainer shadow
profilePrimaryColorprofile-primary-colorPrimary accent
profilePrimaryHoverprofile-primary-hoverPrimary hover
profileAccentColorprofile-accent-colorAccent color
profileCardBgprofile-card-bgCard background
profileCardBorderprofile-card-borderCard border
profileCardRadiusprofile-card-radiusCard radius
profileCardShadowprofile-card-shadowCard shadow
profileCardPaddingprofile-card-paddingCard padding
profileAvatarSizeprofile-avatar-sizeAvatar size
profileAvatarRadiusprofile-avatar-radiusAvatar radius
profileAvatarBorderprofile-avatar-borderAvatar border
profileAvatarShadowprofile-avatar-shadowAvatar shadow
profileHeaderBgprofile-header-bgHeader background
profileHeaderHeightprofile-header-heightHeader height
profileBadgeBgprofile-badge-bgBadge background
profileBadgeColorprofile-badge-colorBadge text
profileBadgeRadiusprofile-badge-radiusBadge radius
profileStatBgprofile-stat-bgStat background
profileStatBorderprofile-stat-borderStat border
profileStatValueColorprofile-stat-value-colorStat value color
profileStatLabelColorprofile-stat-label-colorStat label color
profileTabActiveBgprofile-tab-active-bgActive tab bg
profileTabActiveColorprofile-tab-active-colorActive tab text
profileTabColorprofile-tab-colorTab text color
profileTabHoverBgprofile-tab-hover-bgTab hover bg
profileTabRadiusprofile-tab-radiusTab radius
profileButtonBgprofile-button-bgButton background
profileButtonHoverBgprofile-button-hover-bgButton hover bg
profileButtonColorprofile-button-colorButton text
profileButtonRadiusprofile-button-radiusButton radius
profileFontFamilyprofile-font-familyFont family
profileNameSizeprofile-name-sizeName font size
profileNameWeightprofile-name-weightName font weight
profileUsernameSizeprofile-username-sizeUsername size
profileBioSizeprofile-bio-sizeBio font size
profileStatSizeprofile-stat-sizeStat font size
profileLabelSizeprofile-label-sizeLabel font size
profileDividerColorprofile-divider-colorDivider color
profileTransitionDurationprofile-transition-durationTransition timing
profileHoverScaleprofile-hover-scaleHover scale factor

Imperative Ref

1import { useRef } from 'react'; 2import { LegionProfile } from '@legionhandtech/lht-react-widgets'; 3import type { LegionProfileHandle } from '@legionhandtech/lht-react-widgets'; 4 5function App() { 6 const ref = useRef<LegionProfileHandle>(null); 7 8 return ( 9 <> 10 <button onClick={() => ref.current?.refresh()}>Reload</button> 11 <LegionProfile ref={ref} baseUrl="https://your-legion-domain.com" /> 12 </> 13 ); 14}

Web Component

import '@legionhandtech/lht-react-widgets/profile-web-component';
1<legion-profile 2 api-url="https://your-legion-domain.com" 3 auth-token="your-jwt-token" 4 theme="light" 5 width="400" 6 height="400"> 7</legion-profile>

Authentication

The Profile widget uses postMessage to securely deliver the JWT auth token to the iframe after it loads. The token is never included in the URL. Pass the authToken prop and the component handles the rest.

Documentation | Legion Hand Technologies