프로그래밍/Weekly I Learned

2023.10.18+ 타입스크립트 스타일컴포넌트 다크모드

타코코딩 2023. 10. 29. 01:57

다크모드 ts

styled.d.ts
// import original module declarations
import "styled-components";
// and extend them!
declare module "styled-components" {
export interface DefaultTheme {
textColor: string;
bgColor: string;
btnColor: string;
}
}

 

https://styled-components.com/docs/api#typescript

 

styled-components: API Reference

API Reference of styled-components

styled-components.com

 

theme ts

import { DefaultTheme } from "styled-components";
export const lightTheme: DefaultTheme = {
bgColor: "white",
textColor: "black",
btnColor: "tomato",
};
export const darkTheme: DefaultTheme = {
bgColor: "black",
textColor: "white",
btnColor: "teal",
};

 

index ts

<ThemeProvider theme={darkTheme}>

 

'프로그래밍 > Weekly I Learned' 카테고리의 다른 글

2023.10.31+ counter,totalcounter react  (0) 2023.11.02
2023.10.30+ react란?  (0) 2023.10.30
2023.10.27 + cookie  (0) 2023.10.27
2023.10.25+ env패턴  (0) 2023.10.25
2023.10.23+ node.js mysql 연동  (0) 2023.10.23