CSS variables for PubNub Chat Components for React
Migrate to Chat SDK
PubNub will stop supporting Chat Components on January 1, 2025 but you are welcome to contribute. Learn how to migrate to the Chat SDK here.
Built-in themes can be customized by changing the values of CSS variables that are internally used to style different parts of each component. This document provides the full list of available variables along with their default values.
For example, to remove the default padding around MessageInput
, you can simply redefine the varaible in your CSS file:
:root {
--msg-input__padding: 0;
}
In cases where the variable value is redefined by a particular theme in use, a higher CSS specification needs to be applied. For example, to change the background of Message List in the dark mode, you must use a component class name instead of the :root
element:
.pn-msg-list {
--msg-list__background: rgb(40 41 49);
}
Chat
PubNub Chat Components for React provide a list of global color variables for light and dark themes.
rgba color function
When hexToRGB is used on a color, the variable can only be used with the rgba
color function inside of the actual CSS. To goal of this is to introduce alpha channels on some of the colors.
--chat--light__background--1: #f0f3f7;
--chat--light__background--2: #ffffff;
--chat--light__background--3: #eaeef3;
--chat--light__background--4: #01bd4c;
--chat--light__background--5-rgb: #{hexToRGB(#ef3a43)};
--chat--light__background--6: #{rgba(#1c1c1c, 0.8)};
--chat--light__color--1: #585858;
--chat--light__color--2: #999999;
--chat--light__color--2-rgb: #{hexToRGB(#999999)};
--chat--light__color--3: #eeeeee;
--chat--light__border--1: #ced6e0;
--chat--light__border--2: #bcc6d1;
--chat--light__hover--1: #de2440;
--chat--light__hover--2: #e4e9f0;
--chat--light__hover--3: #e9eef4;
show all 33 linesMessage List
Light
--msg-list__background: var(--chat--light__background--1);
--msg-list__padding: 0;
--msg-list__unread__background: var(--chat--light__color--2);
--msg-list__unread__borderRadius: 20px;
--msg-list__unread__color: var(--chat--light__background--2);
--msg-list__unread__fontSize: 13px;
--msg-list__unread__fontWeight: 400;
--msg-list__unread__padding: 8px 16px;
--msg-list__unread__offset: 50px;
--msg-list__spinner__color: var(--chat--light__color--2);
--msg--hover__background: var(--chat--light__hover--3);
--msg__alignItems: flex-start;
--msg__flexDirection: row;
--msg__height: auto;
--msg__padding: 10px 16px;
show all 79 linesDark
--msg-list__background: var(--chat--dark__background--1);
--msg-list__unread__background: var(--chat--dark__color--2);
--msg-list__unread__color: var(--chat--dark__background--2);
--msg-list__spinner__color: var(--chat--dark__color--2);
--msg--hover__background: var(--chat--dark__border--1);
--msg__actions--hover__color: var(--chat--dark__hover--1);
--msg__actions--hover__border: 1px solid var(--chat--dark__background--1);
--msg__actions--hover__background: var(--chat--dark__background--1);
--msg__actions__background: var(--chat--dark__background--1);
--msg__actions__border: 1px solid var(--chat--dark__background--1);
--msg__actions__color: var(--chat--dark__color--2);
--msg__author__color: var(--chat--dark__color--1);
--msg__bubble__color: var(--chat--dark__color--1);
--msg__link-description__color: var(--chat--dark__color--2);
--msg__link-title__color: var(--chat--dark__color--1);
show all 23 lines