Skip to main content

Theme

The @shopify/restyle library provides us with complete theme customization functions.

Spacing spacing

namedescriptionvalue
x01x0
x11x4
x22 times8
x33 times12
x44 times16
x55 times20
x66 times24
x77 times28
x88 times32
x99 times36
x1010 times40

Rounded corners

namedescriptionvalue
x01x0
x11x4
x22 times8
x33 times12
x44 times16
x55 times20
x66 times24
x77 times28
x88 times32
x99 times36
x1010 times40

Media query breakpoint

namedescriptionvalue
phonemobile phone0
tablettablet768
largeTabletLarge Tablet1024

Common colors

namedescriptionvalue
transparenttransparenttransparent
whitewhite#FFFFFF #FFFFFF
blackblack#000000 #000000
func50Function color 0#FBF5F5 #FBF5F5
func100Function color 1#FFF7E3 #FFF7E3
func200Function color 2#FFD21D #FFD21D
func300Functional color 3#52C41A #52C41A
func400Functional color 4#1890FF #1890FF
func500Functional color 5#F86E21 #F86E21
func600Functional color 6#F4333C #F4333C
func700Preserve functional colorstransparent
func800Preserve functional colorstransparent
func900Preserve functional colorstransparent

We set func700/func800/func900 as reserved functional colors to facilitate developers to expand

Light mode color (inherit universal color)

namedescriptionvalue
primary50Main color#E5F1FF #E5F1FF
primary100Primary color#3AA3FF #3AA3FF
primary200Primary color#005DFF #005DFF
primary300Primary colorrgba(0, 93, 255, 0.7)rgba(0, 93, 255, 0.7)
primary400Primary colorrgba(0, 93, 255, 0.4) rgba(0, 93, 255, 0.7)
primary500Keep primary colortransparent
primary600Keep primary colortransparent
primary700Keep primary colortransparent
primary800Keep primary colortransparent
primary900Keep primary colortransparent
gray50Neutral colors#F5F5F5
gray100Neutral colors#E5E5E5
gray200Neutral colors#CCCCCC
gray300Neutral colors#999999
gray400Neutral colors#666666
gray500Neutral colors#333333
gray600Neutral colorrgba(0, 0, 0, 0.4)
gray700Neutral colorrgba(0, 0, 0, 0.04)
gray800Keep neutral colorstransparent
gray900Keep neutral colorstransparent
backgroundBackground colorSame as gray50
maskMaskSame as gray600
borderBorderSame as gray200
iconIconSame as gray300
disabledDisabledSame as gray200
texttextsame as gray500
text_activeCurrent textSame as white

We set primary600/primary700/primary800/primary900 as reserved main colors, gray800 /gray900 as reserved neutral colors to facilitate developers to expand

Dark mode color (inherit universal color)

namedescriptionvalue
primary50Primary colorrgba(0, 93, 255, 0.3)
primary100Primary color#3AA3FF
primary200Primary color#005DFF
primary300Primary colorrgba(0, 93, 255, 0.7)
primary400Primary colorrgba(0, 93, 255, 0.4)
primary500Keep primary colortransparent
primary600Keep primary colortransparent
primary700Keep primary colortransparent
primary800Keep primary colortransparent
primary900Keep primary colortransparent
gray50Neutral colors#131C22
gray100Neutral colorrgba(255, 255, 255, 0.15)
gray200Neutral colorrgba(255, 255, 255, 0.25)
gray300Neutral colorrgba(255, 255, 255, 0.4)
gray400Neutral colorrgba(255, 255, 255, 0.6)
gray500Neutral colorrgba(255, 255, 255, 0.8)
gray600Neutral colorrgba(0, 0, 0, 0.4)
gray700Neutral colorrgba(0, 0, 0, 0.04)
gray800Keep neutral colorstransparent
gray900Keep neutral colorstransparent
backgroundBackground colorSame as gray50
maskMaskSame as gray600
borderBorderSame as gray400
iconIconSame as gray300
disabledDisabledSame as gray300
texttextsame as gray500
text_activeCurrent textSame as white

TextVariant

NameFont size (fontSize)Font weight (fontWeight)Line height (lineHeight)
h024bold39
h11850025
h21650022
h31450019
h4
h5
h6
h7
h8
h9
p01622
p11419
p21216
p31014
p4
p5
p6
p7
p8
p9
d02428
d11821
d21214
d3
d4
d5
d6
d7
d8
d9

We set h4/h5/h6/h7/h8/h9/p4/p5/p6/p7/p8/ p9/d3/d4/d5/d6/d7/d8/d9 are reserved font styles to facilitate developers to expand

How to override application themes

It is very simple to overwrite the application theme. You only need to do the following:

1. Define your own theme color file in the application:

import { theme, Theme } from '@td-design/react-native';

export const lightTheme: Theme = {
...theme.lightTheme,
colors: {
...theme.lightTheme.colors,
//Copy the color that needs to be overwritten
},
};

export const darkTheme: Theme = {
...theme.darkTheme,
colors: {
...theme.darkTheme.colors,
//Copy the color that needs to be overwritten
},
};

2. Inject the custom theme into ThemeProvider in app.tsx:

//Other imports
import { ThemeProvider } from '@td-design/react-native';
import { lightTheme, darkTheme } from './theme';

export default () => {
//other code

return <ThemeProvider theme={lightTheme}>{/**Other Provider */}</ThemeProvider>;
};

3. Achieve switching between light mode and dark mode

//Other imports
import { ThemeProvider } from '@td-design/react-native';
import { lightTheme, darkTheme } from './theme';

export default () => {
const [dark, setDark] = useState(false);
//other code

return (
<ThemeProvider theme={dark ? darkTheme : lightTheme}>
{/**Pass the setDark method to the application through context or other global variables and call it where needed. */}
{/**Other Providers */}
</ThemeProvider>
);
};