Style injection for PubNub Chat Components for React Native

USED BY THE OLD IA, PLEASE DISREGARD

Built-in themes can be customized by injecting styles that should override the defaults used to style different parts of each component. This document provides the full list of available subcomponents along with their default styling.

For example, to remove the default padding around MessageInput, you can simply pass your own values to the style property:

1<MessageInput style={{ messageInputWrapper: { paddingHorizontal: 0, paddingVertical: 0 }}} />

Message list​

Styling​

1{
2 messageList: {
3 backgroundColor: colors.messageListBackground,
4 },
5 messageListScroller: {
6 backgroundColor: colors.messageListBackground,
7 flexGrow: 1,
8 },
9 message: {
10 flexDirection: "row",
11 paddingHorizontal: 16,
12 paddingVertical: 8,
13 },
14 messageOwn: {},
15 messagePressed: {
show all 105 lines

Colors​

1const lightTheme = {
2 messagePressedBackground: "#e9eef4",
3 messageListBackground: "#f0f3f7",
4 messageColor: "#585858",
5 unreadBackground: "#999999",
6 unreadColor: "#ffffff",
7 reactionBorder: "#ced6e0",
8 reactionActiveBackground: "rgba(239, 58, 67, 0.2)",
9};
10
11const darkTheme = {
12 messagePressedBackground: "#28293d",
13 messageListBackground: "#1c1c28",
14 messageColor: "rgba(228, 228, 235, 0.8)",
15 unreadBackground: "#999999",
show all 19 lines

Message input​

Styling​

1{
2 messageInputWrapper: {
3 backgroundColor: colors.wrapperBackground,
4 paddingHorizontal: 16,
5 paddingVertical: 10,
6 flexDirection: "row",
7 alignItems: "center",
8 },
9 messageInput: {
10 backgroundColor: colors.inputBackground,
11 borderRadius: 20,
12 color: colors.inputColor,
13 paddingHorizontal: 14,
14 paddingTop: 8,
15 paddingBottom: 10,
show all 33 lines

Colors​

1const lightTheme = {
2 wrapperBackground: "#f0f3f7",
3 inputBackground: "#e4e9f0",
4 inputColor: "#585858",
5 inputPlaceholder: "#999999",
6};
7
8const darkTheme = {
9 wrapperBackground: "#1c1c28",
10 inputBackground: "#2a2a39",
11 inputColor: "rgba(228, 228, 235, 0.8)",
12 inputPlaceholder: "#555770",
13};

Member list​

Styling​

1{
2 memberListWrapper: {
3 flex: 1,
4 },
5 memberList: {
6 backgroundColor: colors.memberListBackground,
7 },
8 member: {
9 alignItems: "center",
10 backgroundColor: colors.memberBackground,
11 flexDirection: "row",
12 paddingHorizontal: 16,
13 paddingVertical: 12,
14 },
15 memberPressed: {},
show all 57 lines

Colors​

1const lightTheme = {
2 memberListBackground: "#ffffff",
3 memberBackground: "transparent",
4 memberNameColor: "#585858",
5 memberDescriptionColor: "#9b9b9b",
6 memberPresenceColor: "#01bd4c",
7};
8
9const darkTheme = {
10 memberListBackground: "#2a2a39",
11 memberBackground: "transparent",
12 memberNameColor: "#dcddde",
13 memberDescriptionColor: "#929292",
14 memberPresenceColor: "#01bd4c",
15};

Channel list​

Styling​

1{
2 channelListWrapper: {
3 flex: 1,
4 },
5 channelList: {
6 backgroundColor: colors.channelListBackground,
7 },
8 channel: {
9 alignItems: "center",
10 backgroundColor: colors.channelBackground,
11 flexDirection: "row",
12 paddingHorizontal: 16,
13 paddingVertical: 12,
14 },
15 channelActive: {
show all 41 lines

Colors​

1const lightTheme = {
2 channelListBackground: "#ffffff",
3 channelBackground: "transparent",
4 channelActiveBackground: "#f0f3f7",
5 channelPressedBackground: "#e4e9f0",
6 channelNameColor: "#585858",
7 channelDescriptionColor: "#9b9b9b",
8};
9
10const darkTheme = {
11 channelListBackground: "#2a2a39",
12 channelBackground: "transparent",
13 channelActiveBackground: "#1c1c28",
14 channelPressedBackground: "#232333",
15 channelNameColor: "#dcddde",
show all 17 lines

Typing indicator​

Styling​

1{
2 typingIndicator: {
3 backgroundColor: colors.textBackground,
4 color: colors.textColor,
5 fontSize: 12,
6 paddingHorizontal: 16,
7 paddingVertical: 5,
8 },
9}

Colors​

1const lightTheme = {
2 textBackground: "#f0f3f7",
3 textColor: "#585858",
4};
5
6const darkTheme = {
7 textBackground: "#1c1c28",
8 textColor: "rgba(228, 228, 235, 0.8)",
9};

Examples​

Customize messages sent by current user​

Differentiating the looks of messages, depending on who sent them, is a common use case across some types of chat apps.

PubNub Chat Components for React Native do not come with a separate default styling for messages that were sent by the current chat user. To change the appearance of such messages, apply style injection using sub-components dedicated to that purpose.

Here is an example of how to align your messages to the right side of the chat window:

1<MessageList
2 style={{
3 messageOwn: { flexDirection: "row-reverse" },
4 messageOwnTitle: { flexDirection: "row-reverse" },
5 messageOwnMain: { alignItems: "flex-end" },
6 messageOwnAvatar: { marginRight: 0, marginLeft: 16 },
7 }}
8/>

Was this page useful?

Last updated on