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?

【React】react-datepickerのポップアップにクラスを指定したい

Posted at

概要

react-datepickerのポップアップに対してz-indexを指定する場合、React DatePicker calendar showing behind table headの記事にある通り、規定のクラス名を指定してスタイルを上書くという実装は対応として挙げられます。
とはいえ、私の開発してる環境ではtailwindを使用してるので、可能であればクラス名を指定してスタイルを適用させたいです。しかしclassNameに指定してもスタイルが効かなかったので、どうすればよいかというメモ書きです。

前提

  • 使用したreact-datepickerのバージョンは8.0.0です。

対応

datepicker (component)のドキュメントに記載がある、popperClassNameを使用します。
tailwindを使用して、z-indexを指定する場合の実装は以下の通りとなります、規定のz-index設定に負けてしまわないうようimportantを付与しています。

<DatePicker
  selected={value}
  onChange={(date) => setValue(date)}
  dateFormat="yyyy/MM/dd"
  popperPlacement="bottom-start"
  popperClassName="!z-20" // ここにtailwindのクラス名を指定
/>
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?