Skip to main content

LMHeader

LMHeader renders a header component of the currently opened chatroom. It is internally used under LMChatroom and displays details of current chatroom and chatroom menu options. It accepts the following props.

Props

PropertyTypeDescriptionOptional
chatroomMenuCustomActionsChatroomMenuCustomActionsCustom actions for the chatroom menu.✔️

CSS Classnames

ClassnameDescription
lm-channel-headerContainer or element for lm channel header
lm-header-leftContainer or element for lm header left
back-icon header-back-iconContainer or element for back icon header back icon
lm-channel-imgContainer or element for lm channel img
lm-channel-descContainer or element for lm channel desc
lm-channel-titleContainer or element for lm channel title
lm-channel-participantsContainer or element for lm channel participants
lm-header-rightContainer or element for lm header right
lm-channel-iconContainer or element for lm channel icon
lm-chatroom-menu-itemContainer or element for lm chatroom menu item

Example

To customise the component with their classnames, Open your base css file and override the styles using the classname

.lm-channel-title {
font-size: 18px;
color: "red";
}

Advanced Customisation

In a scenario where you would like to change the behaviour or other view related customisation, you can do so by passing you own custom view for LMHeader. This will offer you the flexibility to customise the behaviour or other logic according to your needs. You can use the below hooks and contexts to customise the component.

Hooks Used

Contexts Used

Below is an example of how you can create your Custom View for LMHeader

  • Step 1: Create your own custom view using the hooks and contexts made available by LikeMinds.
import {
LMClientOverlayProvider,
LMChannel,
initiateLMClient,
LMChatTheme,
LMChatroomContext,
UserProviderContext,
useChatroomMenuOptions
} from "@likeminds.community/likeminds-chat-reactjs";

// Custom Component for HeaderE
const CustomHeader = ({
chatroomMenuCustomActions,
}) => {
const { chatroomDetails } = useContext(LMChatroomContext);
const { currentUser } = useContext(UserProviderContext);
const { onMute, onLeaveChatroom, onViewParticipants, onBlock, onUnBlock } =
useChatroomMenuOptions(chatroomMenuCustomActions);

return (
// Your Custom Code for rendering the header
);
};

  • Step 2: Pass your Custom View to LMClientOverlayProvider
import {
LMClientOverlayProvider,
LMChannel,
initiateLMClient,
LMChatTheme,
LMChatroomContext,
UserProviderContext,
useChatroomMenuOptions
} from "@likeminds.community/likeminds-chat-reactjs";

const App = () => {
const lmChatClient = initiateLMClient();
return (
<LMClientOverlayProvider
client={lmChatClient}
userDetails={userDetails}
lmChatTheme={LMChatTheme.COMMUNITY_CHAT}
customComponents={{
chatroomHeader: <CustomHeader />,
}}
>
<LMChannel />
</LMClientOverlayProvider>
);
};
export default App;

Reference

For reference checkout this file