Tailwind CSSクラスのTypescriptタイプ 質問する

Tailwind CSSクラスのTypescriptタイプ 質問する

Tailwind CSS クラスの TypeScript タイプはどこかに存在しますか?

いくつかの tailwind クラスをプロパティとして React コンポーネントに渡そうとしており、適切に入力したいと考えています。

ベストアンサー1

また、どこにも型定義が見つからなかったので、回避策としてこれを実行しました。私の目標は、tailwind からインテリセンスを取得できるようにすることでしたが、これでうまくいきました...

/* This returns the interface object of all props/attributes on a jsx div element */
React.ComponentProps<'div'>

/* Then this would get the types on the className attribute */
React.ComponentProps<'div'>['className']

アプリケーション例...

interface Props {
  className?: React.ComponentProps<'div'>['className'];
}

おすすめ記事