Skip to main content

LMInput

LMInput renders the input section for the currently opened chatroom. It contains logic for sending message and attachments.

CSS Classnames

ClassnameDescription
disabled-stateInput field in disabled state
lm-channel-icon send lm-cursor-pointerSend button with pointer cursor
lm-post-conversationContainer for post conversation
lm-channel-icon lm-cursor-pointerChannel icon with pointer cursor
lm-giffy-iconGiphy icon button
dm-request-respond-bottom-sheetBottom sheet for DM request response
dm-request-respond-messageMessage container for DM request response
dm-request-respond-action-buttonsContainer for DM request action buttons
dm-request-accept-action-button dm-request-action-buttonAccept button for DM request
dm-request-reject-action-button dm-request-action-buttonReject button for DM request
lm-channel-footer-wrapperWrapper for channel footer
og-tag-wrapperContainer for OpenGraph tag
og-tag-containerContainer for OpenGraph tag content
og-tag-iconIcon for OpenGraph tag
og-tag-dataContainer for OpenGraph data
og-tag-data-headerHeader for OpenGraph data
og-tag-data-descriptionDescription text for OpenGraph data
og-tag-data-urlURL text for OpenGraph data
remove-og-tag-buttonButton to remove OpenGraph tag
lm-giphy-containerContainer for Giphy content
lm-channel-footerFooter section of the channel

Example

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

.og-tag-data-description {
font-size: 18px;
color: "red";
}

Advanced Customisations

Hooks Used

Contexts Used

You can customise different component used under LMInput, infact you can provide your own customisation of each of the components. Internally we use contexts such as InputContext, UserProviderContext and many to get the input states and other vitals informations which you might need to display the information. You can take a look at the reference file below to know more. Also you can checkout the Hooks and Contexts sections to know the information returned by them.

Below is an example for customising TextArea of the LMInput. It is fairly a 2 simple step process

  • First you create your own custom component using the hooks and contexts made available by LikeMinds. The will be responsible for fetching data, you might want to process. For example you can get function for updating textArea's state using the context LMInputContext.

  • Then you just have to pass it as a prop to LMClientOverlayProvider.

Customising Text Area

  • Step 1: First create your own CustomInputTextArea.
import {
LMInputContext
} from "@likeminds.community/likeminds-chat-reactjs";

// Custom Component for LMChatTextArea
const CustomInputTextArea = () => {
const {
inputWrapperRef,
inputBoxRef,
onTextInputKeydownHandler,
onTextInputKeyUpHandler,
updateInputText,
fetchMoreTags,
matchedTagMembersList,
getTaggingMembers,
clearTaggingList,
} = useContext(InputContext);
return (
//Your Custom View. You can use the information fethed from above to render your views
);
};
  • Step 2: Pass your Custom View to LMClientOverlayProvider
import {
LMClientOverlayProvider,
LMChannel,
initiateLMClient,
LMChatTheme,
LMInputContext
} from "@likeminds.community/likeminds-chat-reactjs";

// Custom Component for InputTextArea
const CustomInputTextArea = () => {
const {
inputWrapperRef,
inputBoxRef,
onTextInputKeydownHandler,
onTextInputKeyUpHandler,
updateInputText,
fetchMoreTags,
matchedTagMembersList,
getTaggingMembers,
clearTaggingList,
} = useContext(InputContext);
return (
// Your Custom Code
);
};

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

Customising Input Emoji Selector

import {
LMClientOverlayProvider,
LMChannel,
initiateLMClient,
LMChatTheme,
} from "@likeminds.community/likeminds-chat-reactjs";

// Custom Component for InputEmojiSelector
const CustomInputEmojiSelector = () => {
return (
// Your Custom Code
);
};

const App = () => {
const lmChatClient = initiateLMClient();
return (
<LMClientOverlayProvider
client={lmChatClient}
userDetails={userDetails}
lmChatTheme={LMChatTheme.COMMUNITY_CHAT}
customComponents={{
input: {
chatroomInputEmojiSelector: <CustomInputEmojiSelector />,
}

}}
>
<LMChannel />
</LMClientOverlayProvider>
);
};
export default App;

You can also provide custom component for other different input elements. Check out the full list of customisations available from here. Use different props available under input to customise that particular input view.

Reference

For reference checkout this file