Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TailwindCSSでの開発体験をあげてくれるツールを紹介します

Avatar for Shunya Hayashi Shunya Hayashi
September 20, 2022
55

 TailwindCSSでの開発体験をあげてくれるツールを紹介します

2022年9月の社内LTで使用した資料

Avatar for Shunya Hayashi

Shunya Hayashi

September 20, 2022

Transcript

  1. CSSの場合 スタイルシート p.bg { background-color:white; text-align:center; } HTML <p class="bg">

    文字</p> TailwindCSSの場合 HTML <p class="bg-white text-center"> 文字</p> smartstart勉強会 5
  2. prettier-plugin-tailwindcss Github: https://github.com/tailwindlabs/prettier-plugin-tailwindcss 2022 年の 1 月に Tailwind 公式がリリースした Prettier

    のプラグイン。 class に渡された文字列から TailwindCSS クラスを含む属性を探して、推奨されるクラスの順 序に従ってそれらを自動的に並べ替えてくれる。 Before: <button className="bg-blue-600 text-xs font-medium inline-block px-6 py-2.5 leading-tight rounded"> After: <button className="inline-block rounded bg-blue-600 px-6 py-2.5 text-xs font-medium leading-tight"> smartstart勉強会 10
  3. eslint-plugin-tailwindcss Github: https://github.com/francoismassart/eslint-plugin-tailwindcss ESLintのTailwind用のプラグイン。 デフォルトの設定では以下のようにclassのコンフリクト、tailwindにサポートされていない クラスの使用、冗長な記述などを指摘してくれる。 Githubの公式リポジトリに各ルールが記載されているのでそちらを参照しよう。 <button className="block inline-block

    unknownclass px-8 py-8 "> Warning: Classnames 'px-8, py-8' could be replaced by the 'p-8' shorthand! tailwindcss/enforces-shorthand Warning: Classname 'unknownclass' is not a Tailwind CSS class! tailwindcss/no-custom-classname Error: Classnames block, inline-block are conflicting! tailwindcss/no-contradicting-classname smartstart勉強会 11