DevToolBoxFREE
BlogAdvertise

Tailwind CSS チートシート:完全クラスリファレンスガイド

15分by DevToolBox

Tailwind CSS はユーティリティファーストの CSS フレームワークで、マークアップ内で直接デザインを構築できます。カスタム CSS を書く代わりに、事前構築されたユーティリティクラスを適用します。この完全な Tailwind CSS チートシートは、すべての主要カテゴリのクラスとその CSS 出力をカバーしています。

なぜ Tailwind CSS?なぜチートシート?

Tailwind CSS には何百ものユーティリティクラスがあります。命名規則は直感的ですが、クイックリファレンスがあれば時間を節約し生産性を向上させます。

スペーシング:パディングとマージン

Tailwind は一貫したスペーシングスケールを使用します。p- または m- の後の数字は rem 値にマッピングされます(0.25rem を掛ける)。負のマージンは -m- プレフィックスを使用します。

ClassCSS OutputValue
p-0padding: 0px0px
p-1padding: 0.25rem4px
p-2padding: 0.5rem8px
p-3padding: 0.75rem12px
p-4padding: 1rem16px
p-5padding: 1.25rem20px
p-6padding: 1.5rem24px
p-8padding: 2rem32px
p-10padding: 2.5rem40px
p-12padding: 3rem48px
p-16padding: 4rem64px
p-20padding: 5rem80px
p-24padding: 6rem96px
p-32padding: 8rem128px
p-40padding: 10rem160px
p-48padding: 12rem192px
p-64padding: 16rem256px
p-96padding: 24rem384px

Directional Padding & Margin

PrefixCSS PropertyDescription
p-*paddingAll sides
px-*padding-left + padding-rightHorizontal
py-*padding-top + padding-bottomVertical
pt-*padding-topTop
pr-*padding-rightRight
pb-*padding-bottomBottom
pl-*padding-leftLeft
m-*marginAll sides
mx-*margin-left + margin-rightHorizontal
my-*margin-top + margin-bottomVertical
-m-4margin: -1remNegative margin
m-automargin: autoAuto margin
<!-- Spacing examples -->
<div class="p-4">padding 1rem all sides</div>
<div class="px-6 py-3">horizontal 1.5rem, vertical 0.75rem</div>
<div class="mt-8 mb-4">top margin 2rem, bottom margin 1rem</div>
<div class="mx-auto max-w-lg">centered container</div>
<div class="-mt-4">negative top margin (overlap)</div>
<div class="space-x-4">children spaced 1rem horizontally</div>
<div class="space-y-2">children spaced 0.5rem vertically</div>

タイポグラフィ

フォントサイズ、太さ、行の高さ、文字間隔、テキスト配置、テキストカラーのユーティリティ。

フォントサイズ

ClassCSS OutputSize
text-xsfont-size: 0.75rem; line-height: 1rem12px
text-smfont-size: 0.875rem; line-height: 1.25rem14px
text-basefont-size: 1rem; line-height: 1.5rem16px
text-lgfont-size: 1.125rem; line-height: 1.75rem18px
text-xlfont-size: 1.25rem; line-height: 1.75rem20px
text-2xlfont-size: 1.5rem; line-height: 2rem24px
text-3xlfont-size: 1.875rem; line-height: 2.25rem30px
text-4xlfont-size: 2.25rem; line-height: 2.5rem36px
text-5xlfont-size: 3rem; line-height: 148px
text-6xlfont-size: 3.75rem; line-height: 160px
text-7xlfont-size: 4.5rem; line-height: 172px
text-8xlfont-size: 6rem; line-height: 196px
text-9xlfont-size: 8rem; line-height: 1128px

フォントウェイト

ClassCSS Output
font-thinfont-weight: 100
font-extralightfont-weight: 200
font-lightfont-weight: 300
font-normalfont-weight: 400
font-mediumfont-weight: 500
font-semiboldfont-weight: 600
font-boldfont-weight: 700
font-extraboldfont-weight: 800
font-blackfont-weight: 900

行の高さ

ClassCSS Output
leading-noneline-height: 1
leading-tightline-height: 1.25
leading-snugline-height: 1.375
leading-normalline-height: 1.5
leading-relaxedline-height: 1.625
leading-looseline-height: 2
leading-3line-height: 0.75rem
leading-6line-height: 1.5rem
leading-8line-height: 2rem
leading-10line-height: 2.5rem

文字間隔

ClassCSS Output
tracking-tighterletter-spacing: -0.05em
tracking-tightletter-spacing: -0.025em
tracking-normalletter-spacing: 0em
tracking-wideletter-spacing: 0.025em
tracking-widerletter-spacing: 0.05em
tracking-widestletter-spacing: 0.1em

テキスト配置

ClassCSS Output
text-lefttext-align: left
text-centertext-align: center
text-righttext-align: right
text-justifytext-align: justify
text-starttext-align: start
text-endtext-align: end

テキストカラー

<!-- Text color examples -->
<p class="text-black">text-black → color: #000</p>
<p class="text-white">text-white → color: #fff</p>
<p class="text-gray-500">text-gray-500 → color: #6b7280</p>
<p class="text-red-600">text-red-600 → color: #dc2626</p>
<p class="text-blue-500">text-blue-500 → color: #3b82f6</p>
<p class="text-green-700">text-green-700 → color: #15803d</p>
<p class="text-transparent">text-transparent → color: transparent</p>
<p class="text-current">text-current → color: currentColor</p>

カラー

Tailwind は 50(最も明るい)から 950(最も暗い)の数値カラースケールを使用します。プレフィックス:bg- は背景、text- はテキスト、border- はボーダー。

Shadebg-blue-*Hex ValueUsage
50bg-blue-50#eff6ffLightest background
100bg-blue-100#dbeafeLight background
200bg-blue-200#bfdbfeHover states, light borders
300bg-blue-300#93c5fdActive states
400bg-blue-400#60a5faIcons, secondary elements
500bg-blue-500#3b82f6Primary brand color
600bg-blue-600#2563ebPrimary buttons, links
700bg-blue-700#1d4ed8Hover on primary
800bg-blue-800#1e40afDark accents
900bg-blue-900#1e3a8aDarkest accent
950bg-blue-950#172554Near-black backgrounds

Color Prefixes

PrefixCSS PropertyExample
bg-*background-colorbg-red-500
text-*colortext-blue-600
border-*border-colorborder-gray-300
ring-*box-shadow (ring)ring-indigo-500
divide-*border-color (dividers)divide-gray-200
placeholder-*placeholder colorplaceholder-gray-400
from-*gradient startfrom-purple-500
via-*gradient middlevia-pink-500
to-*gradient endto-red-500
<!-- Available color palettes -->
slate, gray, zinc, neutral, stone    <!-- Grays -->
red, orange, amber, yellow           <!-- Warm -->
lime, green, emerald, teal           <!-- Green -->
cyan, sky, blue, indigo              <!-- Blue -->
violet, purple, fuchsia, pink, rose  <!-- Purple/Pink -->

<!-- Gradient example -->
<div class="bg-gradient-to-r from-blue-500 via-purple-500 to-pink-500">
  Gradient background
</div>

Flexbox

柔軟なレイアウトを構築するための包括的な flexbox ユーティリティ。

ClassCSS Output
flexdisplay: flex
inline-flexdisplay: inline-flex
flex-rowflex-direction: row
flex-row-reverseflex-direction: row-reverse
flex-colflex-direction: column
flex-col-reverseflex-direction: column-reverse
flex-wrapflex-wrap: wrap
flex-wrap-reverseflex-wrap: wrap-reverse
flex-nowrapflex-wrap: nowrap
flex-1flex: 1 1 0%
flex-autoflex: 1 1 auto
flex-initialflex: 0 1 auto
flex-noneflex: none

Justify & Align

ClassCSS Output
justify-startjustify-content: flex-start
justify-endjustify-content: flex-end
justify-centerjustify-content: center
justify-betweenjustify-content: space-between
justify-aroundjustify-content: space-around
justify-evenlyjustify-content: space-evenly
items-startalign-items: flex-start
items-endalign-items: flex-end
items-centeralign-items: center
items-baselinealign-items: baseline
items-stretchalign-items: stretch

Gap

ClassCSS Output
gap-0gap: 0px
gap-1gap: 0.25rem (4px)
gap-2gap: 0.5rem (8px)
gap-4gap: 1rem (16px)
gap-6gap: 1.5rem (24px)
gap-8gap: 2rem (32px)
gap-x-4column-gap: 1rem
gap-y-4row-gap: 1rem
<!-- Flexbox layout examples -->
<!-- Centered content -->
<div class="flex items-center justify-center h-screen">
  <div>Perfectly centered</div>
</div>

<!-- Navbar: logo left, links right -->
<nav class="flex justify-between items-center p-4">
  <div class="text-xl font-bold">Logo</div>
  <div class="flex gap-4">
    <a href="#">Home</a>
    <a href="#">About</a>
    <a href="#">Contact</a>
  </div>
</nav>

<!-- Responsive cards -->
<div class="flex flex-wrap gap-4">
  <div class="flex-1 min-w-[300px]">Card 1</div>
  <div class="flex-1 min-w-[300px]">Card 2</div>
  <div class="flex-1 min-w-[300px]">Card 3</div>
</div>

Grid

2次元レイアウトを作成するための CSS Grid ユーティリティ。

ClassCSS Output
griddisplay: grid
grid-cols-1grid-template-columns: repeat(1, minmax(0, 1fr))
grid-cols-2grid-template-columns: repeat(2, minmax(0, 1fr))
grid-cols-3grid-template-columns: repeat(3, minmax(0, 1fr))
grid-cols-4grid-template-columns: repeat(4, minmax(0, 1fr))
grid-cols-6grid-template-columns: repeat(6, minmax(0, 1fr))
grid-cols-12grid-template-columns: repeat(12, minmax(0, 1fr))
grid-cols-nonegrid-template-columns: none
grid-rows-1grid-template-rows: repeat(1, minmax(0, 1fr))
grid-rows-3grid-template-rows: repeat(3, minmax(0, 1fr))
grid-rows-6grid-template-rows: repeat(6, minmax(0, 1fr))

Column & Row Span

ClassCSS Output
col-span-1grid-column: span 1 / span 1
col-span-2grid-column: span 2 / span 2
col-span-3grid-column: span 3 / span 3
col-span-4grid-column: span 4 / span 4
col-span-6grid-column: span 6 / span 6
col-span-fullgrid-column: 1 / -1
row-span-1grid-row: span 1 / span 1
row-span-2grid-row: span 2 / span 2
row-span-3grid-row: span 3 / span 3
row-span-fullgrid-row: 1 / -1
auto-cols-autogrid-auto-columns: auto
auto-cols-frgrid-auto-columns: minmax(0, 1fr)
auto-rows-autogrid-auto-rows: auto
auto-rows-frgrid-auto-rows: minmax(0, 1fr)
<!-- Grid layout examples -->
<!-- 3-column grid -->
<div class="grid grid-cols-3 gap-4">
  <div>1</div>  <div>2</div>  <div>3</div>
  <div>4</div>  <div>5</div>  <div>6</div>
</div>

<!-- Responsive grid: 1 col mobile, 2 tablet, 3 desktop -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
  <div>Card 1</div>
  <div>Card 2</div>
  <div>Card 3</div>
</div>

<!-- Dashboard layout with spanning -->
<div class="grid grid-cols-4 gap-4">
  <div class="col-span-4">Header (full width)</div>
  <div class="col-span-1">Sidebar</div>
  <div class="col-span-3">Main content</div>
  <div class="col-span-2">Half width</div>
  <div class="col-span-2">Half width</div>
</div>

レイアウト:幅、高さ、コンテナ

要素の寸法とレイアウトコンテナを制御するユーティリティ。

ClassCSS Output
w-0width: 0px
w-1width: 0.25rem (4px)
w-4width: 1rem (16px)
w-8width: 2rem (32px)
w-16width: 4rem (64px)
w-32width: 8rem (128px)
w-64width: 16rem (256px)
w-1/2width: 50%
w-1/3width: 33.333%
w-2/3width: 66.667%
w-1/4width: 25%
w-3/4width: 75%
w-fullwidth: 100%
w-screenwidth: 100vw
w-autowidth: auto
w-fitwidth: fit-content
w-minwidth: min-content
w-maxwidth: max-content

Height & Max/Min

ClassCSS Output
h-0height: 0px
h-4height: 1rem (16px)
h-16height: 4rem (64px)
h-64height: 16rem (256px)
h-fullheight: 100%
h-screenheight: 100vh
h-autoheight: auto
min-h-0min-height: 0px
min-h-fullmin-height: 100%
min-h-screenmin-height: 100vh
max-w-smmax-width: 24rem (384px)
max-w-mdmax-width: 28rem (448px)
max-w-lgmax-width: 32rem (512px)
max-w-xlmax-width: 36rem (576px)
max-w-2xlmax-width: 42rem (672px)
max-w-4xlmax-width: 56rem (896px)
max-w-6xlmax-width: 72rem (1152px)
max-w-7xlmax-width: 80rem (1280px)
max-w-fullmax-width: 100%
max-w-nonemax-width: none
containerwidth: 100% (responsive max-width)
<!-- Layout examples -->
<div class="container mx-auto px-4">
  Centered responsive container
</div>

<div class="max-w-2xl mx-auto">
  Max-width 672px, centered
</div>

<div class="w-full h-screen">
  Full width, full viewport height
</div>

<div class="min-h-screen flex flex-col">
  <main class="flex-1">Content</main>
  <footer>Footer always at bottom</footer>
</div>

ボーダーと角丸

ボーダー幅、スタイル、角丸、リングエフェクトのユーティリティ。

ClassCSS Output
borderborder-width: 1px
border-0border-width: 0px
border-2border-width: 2px
border-4border-width: 4px
border-8border-width: 8px
border-tborder-top-width: 1px
border-r-2border-right-width: 2px
border-b-4border-bottom-width: 4px
border-lborder-left-width: 1px
border-solidborder-style: solid
border-dashedborder-style: dashed
border-dottedborder-style: dotted
border-noneborder-style: none

Border Radius

ClassCSS Output
rounded-noneborder-radius: 0px
rounded-smborder-radius: 0.125rem (2px)
roundedborder-radius: 0.25rem (4px)
rounded-mdborder-radius: 0.375rem (6px)
rounded-lgborder-radius: 0.5rem (8px)
rounded-xlborder-radius: 0.75rem (12px)
rounded-2xlborder-radius: 1rem (16px)
rounded-3xlborder-radius: 1.5rem (24px)
rounded-fullborder-radius: 9999px
rounded-t-lgborder-top-left/right-radius: 0.5rem
rounded-b-lgborder-bottom-left/right-radius: 0.5rem

Ring (Outline)

ClassCSS Output
ring-0box-shadow: 0 0 0 0px ...
ring-1box-shadow: 0 0 0 1px ...
ring-2box-shadow: 0 0 0 2px ...
ring-4box-shadow: 0 0 0 4px ...
ringbox-shadow: 0 0 0 3px ...
ring-insetbox-shadow: inset ...
ring-blue-500ring color: #3b82f6
ring-offset-2ring offset: 2px
ring-offset-whitering offset color: #fff

シャドウとエフェクト

ボックスシャドウ、不透明度、ブラーエフェクトのユーティリティ。

ClassCSS Output
shadow-smbox-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05)
shadowbox-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)
shadow-mdbox-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1)
shadow-lgbox-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1)
shadow-xlbox-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1)
shadow-2xlbox-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25)
shadow-innerbox-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05)
shadow-nonebox-shadow: 0 0 #0000

Opacity & Blur

ClassCSS Output
opacity-0opacity: 0
opacity-25opacity: 0.25
opacity-50opacity: 0.5
opacity-75opacity: 0.75
opacity-100opacity: 1
blur-nonefilter: blur(0)
blur-smfilter: blur(4px)
blurfilter: blur(8px)
blur-mdfilter: blur(12px)
blur-lgfilter: blur(16px)
blur-xlfilter: blur(24px)
blur-2xlfilter: blur(40px)
blur-3xlfilter: blur(64px)
backdrop-blur-smbackdrop-filter: blur(4px)
backdrop-blurbackdrop-filter: blur(8px)
backdrop-blur-mdbackdrop-filter: blur(12px)
backdrop-blur-lgbackdrop-filter: blur(16px)
backdrop-blur-xlbackdrop-filter: blur(24px)

トランジションとアニメーション

CSS トランジションとキーフレームアニメーションのユーティリティ。

ClassCSS Output
transition-nonetransition-property: none
transition-alltransition-property: all
transitiontransition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter
transition-colorstransition-property: color, background-color, border-color, text-decoration-color, fill, stroke
transition-opacitytransition-property: opacity
transition-shadowtransition-property: box-shadow
transition-transformtransition-property: transform

Duration & Easing

ClassCSS Output
duration-75transition-duration: 75ms
duration-100transition-duration: 100ms
duration-150transition-duration: 150ms
duration-200transition-duration: 200ms
duration-300transition-duration: 300ms
duration-500transition-duration: 500ms
duration-700transition-duration: 700ms
duration-1000transition-duration: 1000ms
ease-lineartransition-timing-function: linear
ease-intransition-timing-function: cubic-bezier(0.4, 0, 1, 1)
ease-outtransition-timing-function: cubic-bezier(0, 0, 0.2, 1)
ease-in-outtransition-timing-function: cubic-bezier(0.4, 0, 0.2, 1)

Animations

ClassDescription
animate-noneNo animation
animate-spinContinuous rotation (loading spinners)
animate-pingScale + fade out (notification dot)
animate-pulseGentle fade in/out (skeleton loaders)
animate-bounceBouncing motion (scroll indicator)
<!-- Transition examples -->
<button class="bg-blue-500 hover:bg-blue-700 transition-colors duration-200">
  Smooth color change on hover
</button>

<div class="hover:scale-105 transition-transform duration-300 ease-out">
  Scale up on hover
</div>

<div class="hover:shadow-xl transition-shadow duration-300">
  Shadow appears on hover
</div>

<!-- Animation examples -->
<svg class="animate-spin h-5 w-5">...</svg>  <!-- Loading spinner -->
<span class="animate-ping absolute">...</span> <!-- Notification dot -->
<div class="animate-pulse bg-gray-300 h-4 rounded">...</div> <!-- Skeleton -->

レスポンシブプレフィックス

Tailwind はモバイルファーストのレスポンシブデザインを使用します。任意のユーティリティにブレークポイントプレフィックスを付けて適用します。

PrefixMin WidthCSS Media Query
(none)0pxNo media query (applies to all)
sm:640px@media (min-width: 640px) { ... }
md:768px@media (min-width: 768px) { ... }
lg:1024px@media (min-width: 1024px) { ... }
xl:1280px@media (min-width: 1280px) { ... }
2xl:1536px@media (min-width: 1536px) { ... }
<!-- Mobile-first responsive design -->

<!-- Stack on mobile, side-by-side on tablet+ -->
<div class="flex flex-col md:flex-row gap-4">
  <div class="w-full md:w-1/3">Sidebar</div>
  <div class="w-full md:w-2/3">Main</div>
</div>

<!-- Responsive text size -->
<h1 class="text-2xl sm:text-3xl md:text-4xl lg:text-5xl">
  Responsive Heading
</h1>

<!-- Responsive grid columns -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
  <div>Card</div>
  <div>Card</div>
  <div>Card</div>
  <div>Card</div>
</div>

<!-- Hide/show at breakpoints -->
<div class="hidden md:block">Visible on md and above</div>
<div class="block md:hidden">Visible only below md</div>

<!-- Responsive padding -->
<div class="p-4 sm:p-6 md:p-8 lg:p-12">
  Padding grows with screen size
</div>

ステートバリアント

ステートバリアントプレフィックスを使用して条件付きでスタイルを適用します。

VariantCSS Selector / ConditionExample
hover::hoverhover:bg-blue-700
focus::focusfocus:outline-none focus:ring-2
focus-within::focus-withinfocus-within:border-blue-500
focus-visible::focus-visiblefocus-visible:ring-2
active::activeactive:bg-blue-800
disabled::disableddisabled:opacity-50
visited::visitedvisited:text-purple-600
first::first-childfirst:mt-0
last::last-childlast:mb-0
odd::nth-child(odd)odd:bg-gray-100
even::nth-child(even)even:bg-gray-50
group-hover:.group:hover &group-hover:text-white
peer-focus:.peer:focus ~ &peer-focus:text-blue-500
dark:prefers-color-scheme: darkdark:bg-gray-900
placeholder:::placeholderplaceholder:text-gray-400
before:::beforebefore:content-[""]
after:::afterafter:content-[""]
<!-- State variant examples -->

<!-- Button with multiple states -->
<button class="bg-blue-500 hover:bg-blue-700 active:bg-blue-800
               focus:outline-none focus:ring-2 focus:ring-blue-300
               disabled:opacity-50 disabled:cursor-not-allowed
               transition-colors duration-200">
  Click me
</button>

<!-- Group hover: parent hover affects child -->
<div class="group p-4 hover:bg-blue-50 rounded-lg">
  <h3 class="group-hover:text-blue-600">Title</h3>
  <p class="group-hover:text-blue-400">Description</p>
</div>

<!-- Dark mode -->
<div class="bg-white dark:bg-gray-900 text-black dark:text-white">
  Adapts to light/dark mode
</div>

<!-- Peer: input state affects sibling -->
<input class="peer" type="text" placeholder="Email" />
<p class="invisible peer-invalid:visible text-red-500">
  Invalid email address
</p>

ヒントと高度な使い方

組み込みユーティリティでは不十分な場合のパワーユーザー機能。

任意の値

角括弧を使用してカスタム値を指定:

<!-- Arbitrary values with square brackets -->
<div class="w-[120px]">width: 120px</div>
<div class="h-[calc(100vh-80px)]">height: calc(100vh - 80px)</div>
<div class="bg-[#1a2b3c]">background: #1a2b3c</div>
<div class="text-[22px]">font-size: 22px</div>
<div class="grid-cols-[200px_1fr_200px]">custom grid template</div>
<div class="p-[clamp(1rem,3vw,3rem)]">responsive clamp padding</div>
<div class="text-[color:var(--brand)]">CSS variable color</div>
<div class="top-[var(--header-h)]">CSS variable position</div>

Important 修飾子

任意のユーティリティの前に ! を付けて !important を追加:

<!-- Important modifier with ! prefix -->
<div class="!p-4">padding: 1rem !important</div>
<div class="!mt-0">margin-top: 0 !important</div>
<div class="!text-red-500">color: #ef4444 !important</div>

<!-- Useful for overriding third-party styles -->
<div class="external-widget !bg-transparent !border-none">
  Override library styles
</div>

@apply ディレクティブ

繰り返しのユーティリティパターンをカスタム CSS クラスに抽出:

/* In your CSS file — use @apply to extract components */
.btn {
  @apply px-4 py-2 rounded-lg font-semibold transition-colors duration-200;
}

.btn-primary {
  @apply btn bg-blue-500 text-white hover:bg-blue-700;
}

.btn-secondary {
  @apply btn bg-gray-200 text-gray-800 hover:bg-gray-300;
}

.input {
  @apply w-full px-3 py-2 border border-gray-300 rounded-md
         focus:outline-none focus:ring-2 focus:ring-blue-500
         focus:border-transparent;
}

.card {
  @apply bg-white dark:bg-gray-800 rounded-xl shadow-md p-6
         hover:shadow-lg transition-shadow duration-300;
}

/* Note: Tailwind recommends using utilities directly in HTML
   and only extracting with @apply for truly repeated patterns. */

よくある質問

Tailwind CSS と通常の CSS の違いは何ですか?

Tailwind CSS はユーティリティファーストのフレームワークで、HTML に直接適用する事前構築された CSS クラスを提供します。カスタムスタイルシートを書く通常の CSS とは異なり、p-4、text-lg、bg-blue-500 などのクラス名を使用して要素をスタイリングします。

Tailwind CSS のスペーシングスケールはどう機能しますか?

各単位は 0.25rem(4px)です。p-1 は 0.25rem、p-4 は 1rem(16px)です。スケールは 0 から 96(24rem/384px)まであり、p-[13px] のような任意の値も使用できます。

レスポンシブブレークポイントはどう機能しますか?

モバイルファーストアプローチです。プレフィックスなしのユーティリティは全画面サイズに適用。md:flex のようなプレフィックス付きはそのブレークポイント以上で適用されます。デフォルト:sm(640px)、md(768px)、lg(1024px)、xl(1280px)、2xl(1536px)。

カスタムカラーを使用できますか?

はい。tailwind.config.js の theme.extend.colors で拡張するか、bg-[#1a2b3c] のような任意の値を直接使用できます。

@apply ディレクティブとは何ですか?

@apply は繰り返しのユーティリティパターンをカスタム CSS クラスに抽出できます。多くのボタンで同じクラスの組み合わせを使う場合に便利ですが、控えめに使用してください。

ダークモードに対応するには?

dark: バリアントを使用します。bg-white dark:bg-gray-900 のように任意のユーティリティに dark: プレフィックスを付けます。tailwind.config.js で "media" または "class" 戦略を設定します。

𝕏 Twitterin LinkedIn
この記事は役に立ちましたか?

Stay Updated

Get weekly dev tips and new tool announcements.

No spam. Unsubscribe anytime.

Partner Picks

Sponsor this article

Place your product next to this developer topic with tracked clicks.

Ask about article sponsorship

This site uses cookies for analytics and to display ads. By continuing to browse, you agree. Privacy Policy