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-headerChannel header container
lm-header-leftLeft section of header
back-icon header-back-iconBack button styling
lm-channel-imgChannel image styling
lm-channel-descChannel description text
lm-channel-titleChannel title text
lm-channel-participantsParticipants list container
lm-header-rightRight section of header
lm-channel-iconChannel icon styling
lm-chatroom-menu-itemChatroom menu item styling

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