#3.6 Themes

SilverAsh·2023년 10월 16일
0

React

목록 보기
3/16
post-thumbnail
//styled.d.ts
import "styled-components";

// and extend them!
declare module "styled-components" {
  export interface DefaultTheme {
    textColor: string;
    bgColor: string;
    btnColor: string;
  }
}

//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",
};

// 적용 결과
import styled from "styled-components";

const Container = styled.div`
background-color: ${props => props.theme.bgColor};`
const H1 = styled.h1`
color: ${props => props.theme.textColor}`

function Applied() {
    return <Container>
        <H1>protected</H1>

    </Container>
}
profile
Frontend developer이자

0개의 댓글