Skip to main content
Version: Next

Theme

Applying theme

To use themes, you need to wrap the root component with provider.

import { KitraProvider } from '@tra-tech/react-native-kitra';
import App from './src/App';

export default function Main() {
return (
<KitraProvider>
<App />
</KitraProvider>
);
}

Accessing and updating theme

To access the current theme, use the useTheme hook. This hook returns the current theme object and a updateTheme function to update the theme.

The theme object is a key-value pair of colors that define the current theme of the app. The updateTheme function is used to update the current theme by merging in new colors. You can customize these values to create your own theme.

import { useTheme } from '@tra-tech/react-native-kitra';

const MyCustomTheme= {
dark:{
system:{
primary: "#00A5EE"
},
custom: {
someColor: "#FF0000"
}
},
light:{
system:{
primary:'#195CEF
},
custom: {
someColor: "#00FF00"
}
}
}

export function App() {
const {theme,updateTheme}= useTheme();

useEffect(() => {
updateTheme(MyCustomTheme)
}, []);

return (
<View>
<MyCustomComponent style={{backgroundColor:theme?.someColor}}>
<MyOtherCustomComponent style={{backgroundColor:theme.primary}}>
</View>
);
}



Colors

System

Light

Primary

#195CEF

Primary 5

#F6F9FF

Primary 15

#E6EEFF

Primary 30

#CFDDFF

Disabled

#A8B8DA

Disabled Dark

#BEC5D4

Disabled Light Dark

#C9D5EF

Disabled Light

#DDE4F3

Background

#FFFFFF

Filled

#FFFFFF

Dark

Primary

#3B79FF

Primary 5

#21273E

Primary 15

#323A5E

Primary 30

#A9B6D7

Disabled

#252F54

Disabled Dark

#445284

Disabled Light Dark

#1B1E2B

Disabled Light

#252F54

Background

#171922

Filled

#171922

Status

Light

Focused

#124CCA

Secondary

#FC6736

Secondary Light

#FFF0EB

Tertiary

#FCE836

Error

#FF0000

Error Light

#FFE6E6

Success

#00CE5E

Success Light

#E6FBEF

Warning

#E2D029

Warning Light

#FFFAD0

Dark

Focused

#124CCA

Secondary

#FC6736

Secondary Light

#452926

Tertiary

#EED815

Error

#FF0000

Error Light

#42171D

Success

#01BA55

Success Light

#123D2E

Warning

#E2D029

Warning Light

#403E23

Neutral

Light

Black

#1F1F1F

Light Black

#404040

Grey

#9A9A9A

Default

#DDDDDD

Disabled Text

#DFE1E6

Light Grey

#EFF0F3

Dark White

#FDFCFF

White

#FFFFFF

Dark

Black

#FFFFFF

Light Black

#ECECEC

Grey

#9F9F9F

Default

#4C526E

Disabled Text

#848EA2

Light Grey

#2A303D

Dark White

#848EA2

White

#1F1F1F

Button

Light

Disabled

#A8B8DA

Disabled Text

#DFE1E6

Text

#FFFFFF

Dark

Disabled

#2D375D

Disabled Text

#6D738A

Text

#FFFFFF

Input

Light

Default

#DDDDDD

Light Default

#EFF0F3

fill

#FFFFFF

Dark

Default

#757575

Light Default

#2B2F3E

fill

#171922

Component theme system

All components provided by Kitra use the colors available in the theme by default. A component changes the colors it uses depending on the situation it is in.

For example, when the button component switches to the pressed state, all applied colors can be changed for that button. This can be done for all component types at once by editing the theme file, or if a single component is to be customized, it can be used by overriding the colors to the theme prop of the component.

This example shows how to change the colors of the button component by status for only one button.

import { Button, useTheme } from '@tra-tech/react-native-kitra';

const App = () => {
const { theme: { colors: { neutral, status } } } = useTheme();

return (
<Button theme={{
default: { background: status.error },
pressed: { background: status.errorLight, label: neutral.black },
}}
/>
);
};

or if you want to change the theme of all button components

import { Button, useTheme } from '@tra-tech/react-native-kitra';
import { useEffect } from 'react';

const appTheme = {
dark: {
components: {
button: {
default: { background: status.error },
pressed: { background: status.errorLight, label: neutral.black },
},
},
},
};

const App = () => {
const { updateTheme } = useTheme();

useEffect(() => {
updateTheme(appTheme);
}, []);

return (
<Button />
);
};


Below are the default values used by the components and their states. These fields can be customized by changing them as in the example above

Accordion List

FieldsDefaultActive
Backgroundneutral.lightGreysystem.primary5
Labelneutral.lightBlacksystem.primary
Item Backgroundsystem.filledsystem.filled
Collapse Icon Backgroundsystem.primary5system.primary15
Collapse Iconneutral.lightBlacksystem.primary
Item Labelneutral.greyneutral.grey

Activity Indicator

FieldsDefault
Backgroundsystem.primary15
Labelsystem.primary

Avatar

FieldsDefault
Backgroundsystem.primary15
Labelsystem.primary

Avatar Group

FieldsDefault
Backgroundsystem.primary15
Labelsystem.primary
More Backgroundstatus.secondary
More Labelbutton.text

Badge

FieldsDefault
Backgroundsystem.primary
Labelbutton.text
Bordersystem.filled

Button

FieldsDefaultPressedDisabled
Backgroundsystem.primarystatus.focusedbutton.disabled
Labelbutton.textbutton.textneutral.disabledText

Checkbox

FieldsDefaultFilledDisabled
Backgroundsystem.backgroundsystem.primaryneutral.default
Bordersystem.primarysystem.primaryneutral.default
Iconbutton.textbutton.textneutral.darkWhite

Chip

FieldDefaultActiveDisabled
Backgroundsystem.backgroundsystem.primarysystem.background
Bordersystem.primarysystem.primarysystem.disabledDark
Labelsystem.primarybutton.textsystem.disabledDark

Divider

FieldsDefault
Backgroundsystem.primary
FieldDefaultActiveSelected
Backgroundsystem.filledsystem.filledsystem.filled
Borderneutral.defaultstatus.focusedneutral.default
Collapse Backgroundsystem.backgroundsystem.backgroundsystem.background
Labelneutral.lightBlackstatus.focusedsystem.primary
Collapse Iconneutral.lightBlacksystem.primarysystem.primary
Item Backgroundsystem.backgroundsystem.backgroundsystem.primary5
Item Labelneutral.lightBlackneutral.lightBlacksystem.primary

Multiple Select Dropdown

FieldDefaultActiveSelected
Backgroundsystem.backgroundsystem.backgroundsystem.background
Borderneutral.defaultstatus.focusedneutral.default
Labelneutral.lightBlackstatus.focusedsystem.primary
Collapse Iconneutral.lightBlacksystem.primarysystem.primary
Item Backgroundsystem.backgroundsystem.backgroundsystem.primary5
Item Labelneutral.lightBlackneutral.lightBlackneutral.lightBlack
Select All Labelsystem.primarysystem.primarysystem.primary
Complete Backgroundsystem.primarysystem.primarysystem.primary
Complete Labelbutton.textbutton.textbutton.text
Check Iconbutton.textbutton.textbutton.text
Check Backgroundsystem.primarysystem.filledsystem.primary
Check Bordersystem.primarysystem.primarysystem.primary
FieldDefaultActive
Iconneutral.greysystem.primary
Item Labelneutral.lightBlackneutral.lightBlack
Item Backgroundsystem.filledsystem.filled
Dividersystem.primary5system.primary5

Pager View

FieldDefaultActive
Header Backgroundsystem.primary5system.primary
Header Labelsystem.primarybutton.text

Progress Bar

FieldDefault
Progresssystem.primary
Barsystem.primary15

Radio Button

FieldDefaultActive
Backgroundneutral.lightGreybutton.text
Dotsystem.primarysystem.primary
Bordersystem.disabledLightDarksystem.primary

Switch

FieldDefaultActive
Tracksystem.disabledLightsystem.primary
Thumbbutton.textbutton.text

Speed Dial

FieldDefault
Backgroundsystem.primary
Iconbutton.text

Text Input

FieldDefaultFocusedErrorDisabled
Backgroundinput.fillinput.fillinput.fillinput.lightDefault
Borderinput.defaultstatus.focusedstatus.errorinput.lightDefault
Labelneutral.lightBlackneutral.lightBlackneutral.lightBlackneutral.grey
Valueneutral.blackneutral.blackneutral.blackneutral.black
Bottom Labelneutral.lightBlackneutral.lightBlackstatus.errorneutral.grey
Count Labelneutral.lightBlackneutral.lightBlackneutral.lightBlackneutral.grey

Toggle Button

FieldDefaultActive
Backgroundsystem.primary5system.primary
Labelsystem.primarybutton.text
Bordersystem.primarysystem.primary