0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【TailwindCSS】tailwind.config.jsでカスタムスタイルを作成する方法【VSCode】

Last updated at Posted at 2023-08-11

はじめに

VSCodeでCSSファイルに以下のようにカスタムスタイルを作成しても補完されません。

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer utilities {
  .pb-safe {
    padding-bottom: env(safe-area-inset-bottom)
  }
}

補完されるようにする方法

補完されるようにするにはCSSファイルではなく、プラグインシステムを使用してカスタムスタイルをプロジェクトに追加します。

tailwind.config.js
/** @type {import('tailwindcss').Config} */

const plugin = require('tailwindcss/plugin')

module.exports = {
  // ...
  plugins: [
    plugin(function ({ addUtilities }) {
      addUtilities({
        '.pb-safe': {
          'padding-bottom': 'env(safe-area-inset-bottom)',
        },
      })
    }),
  ],
}

以下のように入力時に補完されるようになります。

スクリーンショット 2023-07-01 0.00.34.png

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?