Colors in CometChatTheme allow you to maintain a consistent visual identity across your application by providing predefined colors for various UI elements, such as text, buttons, backgrounds, alerts, and more. These color definitions seamlessly adapt to both light and dark themes, ensuring an optimal user experience across different modes.The color resources are divided into the following categories:
Primary Colors: Define the main theme of the application.
Neutral Colors: Used for backgrounds, borders, and secondary UI elements.
Alert Colors: Highlight states like success, warning, error, or information.
Text Colors: Used for typography.
Icon Colors: Define icon appearances.
Button Colors: Customize button backgrounds, icons, and text.
CometChat provides separate color definitions for light mode and dark mode, enabling automatic theme adaptation.
CometChat provides predefined color sets for both light and dark modes, ensuring optimal visual contrast and accessibility across your application.These colors can be accessed through the theme value, which is obtained using the useTheme() hook.Example: Colors
Copy
Ask AI
import { ColorValue } from "react-native";const primaryColor = "#6852D6";const extendedPrimaryColors = { extendedPrimary50: "<generated based on primaryColor>", extendedPrimary100: "<generated based on primaryColor>", //generated based on};const neutralColors = { neutral50: "#FFFFFF", neutral100: "#FAFAFA", //other colors};const alertColors = { info: "#0B7BEA", warning: "#FFAB00", //other colors};const staticColors = { staticBlack: "#141414", staticWhite: "#FFFFFF",};export const defaultColorLight = { primary: primaryColor, ...extendedPrimaryColors, ...neutralColors, ...alertColors, ...staticColors, background1: neutralColors.neutral50, background2: neutralColors.neutral100, background3: neutralColors.neutral200, background4: neutralColors.neutral300, //other derived colors};type EachColorValue<T extends typeof defaultColorLight> = { [P in keyof T]: ColorValue;};//color typeexport type Color = EachColorValue<typeof defaultColorLight>;
Extended colors 50-100 are generated based on the following blend percentages.
For more details on how other colors are generated Click Here.
Extended primary colors, as well as background, text, button, and other UI colors, are automatically derived from the provided primary and neutral colors. However, any colors explicitly overridden in the theme via CometChatThemeProvider will take precedence over the generated values.
You can override the default colors to align them with your application’s branding.
Colors must be supplied as hex values.
Example: Changing the primary and textPrimary colors.
Copy
Ask AI
return ( <SafeAreaView style={{ flex: 1 }}> <CometChatThemeProvider theme={{ light: { color: { // The extended primary colors that are not explicitly defined will be auto-generated primary: "#b2b200", // Since textPrimary is explicitly defined, it won't be auto-generated textPrimary: "#7f7f00", }, }, }} > {/* Component */} </CometChatThemeProvider> </SafeAreaView>);
To know more about theme structure, visit the theme interface.