당근먹는하니
귀엽고 행복해
당근먹는하니
전체 방문자
오늘
어제
  • 분류 전체보기 (274)
    • 다람쥐🐿 (26)
    • C++ 공부빵야 (7)
    • 공부👻 (5)
    • 프론트엔드✏️ (228)
      • 코드캠프 (120)
      • 팀 프로젝트✨ (31)
      • 개인공부 (67)
    • 프론트엔드 - 바닐라js (7)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • graphql
  • javascrpit
  • 팀프로젝트
  • 팀플
  • CSS
  • 코딩
  • react
  • 코딩 부트캠프
  • HTML
  • javascript
  • 배포
  • 부트캠프
  • 알고리즘
  • algorithm
  • typescript
  • 자바스크립트
  • ssg
  • JS
  • 프론트엔드
  • 팀 프로젝트
  • emotion
  • 리액트
  • 배열
  • next.js
  • 코드캠프
  • 회고
  • React-hook-form
  • 공통 컴포넌트
  • 프로그래머스
  • refreshtoken

최근 댓글

최근 글

티스토리

250x250
반응형
hELLO · Designed By 정상우.
당근먹는하니

귀엽고 행복해

[tailwind&emotion]
프론트엔드✏️/개인공부

[tailwind&emotion]

2023. 1. 11. 18:45
728x90
반응형

 

 오늘은 리액트 쿼리 강의 마저 듣고 유튜브 프로젝트 api 받아보기, 회의, 테일윈드 알아보는 것만 했다. 

더보기

tailwind에 대한 생각은 뭔가... 내가 커스텀하기 어려울 것 같고 세세하게 정할 수 없을 것 같아서 꺼려졌는데 엘리쌤이 추천하기도 하고 검색해보니까 그런 애는 아닌 것 같아서(?ㅎ) 쓰게 됨! 아직 쓴 건 아니지만. 

 

yarn add @emotion/react @emotion/styled @emotion/css @emotion/server
yarn add -D twin.macro tailwindcss postcss@latest autoprefixer@latest @emotion/babel-plugin babel-plugin-macros
yarn add -D tailwindcss postcss autoprefixer
npx tailwindcss init

마구잡이로 설치하다보니 두 개 다 해서... 그냥 둘 다 가져왔다. 

 

emotion, tailwind, twin.macro 설치 

 

// package.json

...
  "babelMacros": {
    "twin": {
      "preset": "emotion"
    }
  }
// root의 babel.plugin.js

module.exports = {
  tailwind: {
    plugins: ["@emotion/babel-plugin", "babel-plugin-macros"],
    config: "./src/tailwind.config.js",
    format: "auto",
  },
};
// root의 postcss.config.js

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};
// root의 tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./src/**/*.{html,js,jsx,ts,tsx}"],
  theme: {
    extend: {
      spacing: {
        1: "1px",
        2: "2px",
      },
    },
  },
  plugins: [],
};

 

 

 

쓰는 곳
// index.js

import React from "react";
import Header from "./header/Header";
import tw from "twin.macro";

const Container = tw.p`bg-blue-600 w-full`;

export default function Layout({ children }) {
  return (
    <Container>
      <Header />
      왜안돼 됨도미도미됨됨돔ㄷ미ㅗ돔ㅁ 됨됨됨됨됨
      <div className=" bg-gray-700">{children}</div>
    </Container>
  );
}

 

+ 확장 프로그램

https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss

 

Tailwind CSS IntelliSense - Visual Studio Marketplace

Extension for Visual Studio Code - Intelligent Tailwind CSS tooling for VS Code

marketplace.visualstudio.com

난 XHR 오류 어쩌구가 뜨기 때문에 여기서 다운로드 받아서 VSIX로 설치했다. 

 

설정에서 file.associations 검색

 

설정에서 editor.quickSuggestions 검색

 

off였던 strings를 바꿔줌

 

근데 이렇게 해도 자동완성 잘 안된다... 왜? 

 

 

 

 

테일윈드는 프레임워크별로 가이드도 있다! 나중에 Next.js로 할 때 참고하면 될듯

 


프리티어랑 같이 쓰면 자동 정렬도 되나봄

yarn add -D prettier prettier-plugin-tailwindcss

플러그인을 깔아야한다! 

 

Note that plugin autoloading is not supported when using certain package managers, such as pnpm or Yarn PnP. In this case you may need to add the plugin to your Prettier config explicitly:

 

내가 쓰는게 Yarn PnP인가..?그렇다면 괜히 yarn으로 깔았는데요.

 

// prettier.config.js
module.exports = {
  plugins: [require('prettier-plugin-tailwindcss')],
}

이렇게까지 해주니 자동 정렬 된다~

 

 

 

 

https://fe-developers.kakaoent.com/2022/221013-tailwind-and-design-system/

 

FE개발그룹에서는 Tailwind CSS를 왜 도입했고, 어떻게 사용했을까?

카카오엔터테인먼트 FE 기술블로그

fe-developers.kakaoent.com

 

https://tailwindcss.com/docs/installation

 

Installation - Tailwind CSS

The simplest and fastest way to get up and running with Tailwind CSS from scratch is with the Tailwind CLI tool.

tailwindcss.com

 

https://itchallenger.tistory.com/569

 

Styled-component와 Tailwind 함께 사용하기 with Twin Macro

원문 보러가기 Tailwind는 맞춤형 디자인을 빠르게 구축하기 위한 유틸리티 퍼스트 CSS 프레임워크입니다. 단독으로 React 앱의 스타일 설정에 사용할 수도 있지만, Styled Components와도 잘 사용할 수

itchallenger.tistory.com

 

728x90
반응형
저작자표시 비영리 동일조건 (새창열림)

'프론트엔드✏️ > 개인공부' 카테고리의 다른 글

[youtube] tailwind, react-router, popular list, search  (0) 2023.01.12
[youtube] 1/11, 유튜브 클론 코딩  (0) 2023.01.11
[Todo] 회고?ㅎ 아무튼 끝  (0) 2023.01.10
[Todo] css, htmlFor, 다크모드 하고 싶은데  (0) 2023.01.09
[Todo] All, Doing, Done 클릭한 것만 보이게하기  (0) 2023.01.08
    '프론트엔드✏️/개인공부' 카테고리의 다른 글
    • [youtube] tailwind, react-router, popular list, search
    • [youtube] 1/11, 유튜브 클론 코딩
    • [Todo] 회고?ㅎ 아무튼 끝
    • [Todo] css, htmlFor, 다크모드 하고 싶은데
    당근먹는하니
    당근먹는하니

    티스토리툴바