0
1

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.

【Tailwind】ボタンのデザインを調整したい(ホバー、クリック時)

Posted at

はじめに

Tailwindでボタンのデザイン(ホバーやクリック時)を調整したい人向けの記事です。

前提

shadcn-cibuttonを追加していること。
※ していない方はこちらから↓↓↓

やり方

button.tsxvariant内にボタンのcssを書く。

例えば、以下のようなデザインを作りたいとする。

・初期状態:グリーン
・ホバー時:濃いグリーン
・クリック時:下の部分も濃いグリーンに変わる

※ 参考
ボタン(説明).gif

このようなデザインの場合は、variantに以下のように書けば良い。

button.tsx
任意の名前:
          "bg-green-500 text-destructive-foreground border-b-4 border-green-600 hover:bg-green-700 active:border-b-0",

そして、ボタンコンポーネントを読み込む際にvariantを指定すれば良い。
マージンなど調整したい場合は、calssNameで指定可能。

page.tsx
<Button size="lg" variant="任意の名前" className="mt-5">
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?