Tailwind CSS v4 チートシート(検索対応)

検索できるTailwind CSS v4チートシートです。クラス名や普通の言葉を入力すると、v4が生成する正確なCSSが表示されます。var(--spacing)の倍数からOKLCHのカラートークンまで対応し、@themeトークン、ブレークポイント、コンテナクエリ、動くflexとgridのボックス、全カラーパレット、ダークモード、v3からv4への名称変更も扱います。

このシートはTailwind CSS v4を対象としています(執筆時点の2026年10月の最新リリースはv4.3)。各クラスについて、v4が実際に書き出すCSSを示しています。v4では値の作り方が変わったため、これが重要です。余白は1つの--spacing変数の倍数になり、色はOKLCHで定義された--color-*変数になり、角丸、影、文字などのサイズは名前付きのテーマ変数から取得されます。ボックスに入力すると絞り込めます。クラス名、出力されるCSS、そして「center」「gradient」「sticky」のような普通の単語でも検索できます。

全243件を表示中

クラスv4で出力されるCSS
レイアウトと表示
blockdisplay: block;
inline-blockdisplay: inline-block;
inlinedisplay: inline;
flexdisplay: flex;
inline-flexdisplay: inline-flex;
griddisplay: grid;
inline-griddisplay: inline-grid;
contentsdisplay: contents;
hiddendisplay: none;
containerwidth: 100%; plus max-width: var(--breakpoint-sm) at sm, and so on for each breakpoint
box-borderbox-sizing: border-box;
box-contentbox-sizing: content-box;
staticposition: static;
relativeposition: relative;
absoluteposition: absolute;
fixedposition: fixed;
stickyposition: sticky;
inset-0inset: calc(var(--spacing) * 0);
inset-x-0inset-inline: calc(var(--spacing) * 0);
top-4top: calc(var(--spacing) * 4); /* 1rem */
-top-2top: calc(var(--spacing) * -2);
left-1/2left: calc(1/2 * 100%);
z-10z-index: 10;
z-50z-index: 50;
isolateisolation: isolate;
overflow-hiddenoverflow: hidden;
overflow-autooverflow: auto;
overflow-x-autooverflow-x: auto;
aspect-videoaspect-ratio: var(--aspect-video); /* 16 / 9 */
aspect-squareaspect-ratio: 1 / 1;
object-coverobject-fit: cover;
object-containobject-fit: contain;
visiblevisibility: visible;
invisiblevisibility: hidden;
sr-onlyposition: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border-width: 0;
フレックスボックス
flex-rowflex-direction: row;
flex-colflex-direction: column;
flex-row-reverseflex-direction: row-reverse;
flex-wrapflex-wrap: wrap;
flex-nowrapflex-wrap: nowrap;
flex-1flex: 1;
flex-autoflex: auto;
flex-initialflex: 0 auto;
flex-noneflex: none;
growflex-grow: 1;
grow-0flex-grow: 0;
shrink-0flex-shrink: 0;
basis-64flex-basis: calc(var(--spacing) * 64);
basis-1/3flex-basis: calc(1/3 * 100%);
order-2order: 2;
order-firstorder: -9999;
order-lastorder: 9999;
配置と間隔
justify-startjustify-content: flex-start;
justify-centerjustify-content: center;
justify-endjustify-content: flex-end;
justify-betweenjustify-content: space-between;
justify-aroundjustify-content: space-around;
justify-evenlyjustify-content: space-evenly;
items-startalign-items: flex-start;
items-centeralign-items: center;
items-endalign-items: flex-end;
items-baselinealign-items: baseline;
items-stretchalign-items: stretch;
self-centeralign-self: center;
self-endalign-self: flex-end;
content-centeralign-content: center;
place-items-centerplace-items: center;
place-content-centerplace-content: center;
justify-items-centerjustify-items: center;
gap-4gap: calc(var(--spacing) * 4); /* 1rem */
gap-x-6column-gap: calc(var(--spacing) * 6);
gap-y-2row-gap: calc(var(--spacing) * 2);
グリッド
grid-cols-3grid-template-columns: repeat(3, minmax(0, 1fr));
grid-cols-12grid-template-columns: repeat(12, minmax(0, 1fr));
grid-cols-[200px_1fr]grid-template-columns: 200px 1fr;
grid-cols-subgridgrid-template-columns: subgrid;
grid-rows-3grid-template-rows: repeat(3, minmax(0, 1fr));
col-span-2grid-column: span 2 / span 2;
col-span-fullgrid-column: 1 / -1;
col-start-2grid-column-start: 2;
row-span-2grid-row: span 2 / span 2;
grid-flow-colgrid-auto-flow: column;
grid-flow-densegrid-auto-flow: dense;
auto-rows-frgrid-auto-rows: minmax(0, 1fr);
auto-cols-maxgrid-auto-columns: max-content;
余白
p-4padding: calc(var(--spacing) * 4); /* 1rem */
p-pxpadding: 1px;
p-[13px]padding: 13px;
p-(--card-pad)padding: var(--card-pad);
px-6padding-inline: calc(var(--spacing) * 6);
py-2padding-block: calc(var(--spacing) * 2);
pt-8padding-top: calc(var(--spacing) * 8);
ps-4padding-inline-start: calc(var(--spacing) * 4);
m-0margin: calc(var(--spacing) * 0);
mx-automargin-inline: auto;
mt-6margin-top: calc(var(--spacing) * 6);
-mt-2margin-top: calc(var(--spacing) * -2);
ms-automargin-inline-start: auto;
space-y-4margin-block-end: calc(var(--spacing) * 4) on every child except the last (selector: > :not(:last-child))
space-x-2margin-inline-end: calc(var(--spacing) * 2) on every child except the last
サイズ
w-64width: calc(var(--spacing) * 64); /* 16rem */
w-fullwidth: 100%;
w-1/2width: calc(1/2 * 100%);
w-screenwidth: 100vw;
w-fitwidth: fit-content;
w-autowidth: auto;
size-10width: calc(var(--spacing) * 10); height: calc(var(--spacing) * 10);
h-12height: calc(var(--spacing) * 12);
h-dvhheight: 100dvh;
h-screenheight: 100vh;
min-h-screenmin-height: 100vh;
min-w-0min-width: calc(var(--spacing) * 0);
max-w-mdmax-width: var(--container-md); /* 28rem */
max-w-7xlmax-width: var(--container-7xl); /* 80rem */
max-w-prosemax-width: 65ch;
max-w-screen-lgmax-width: var(--breakpoint-lg);
タイポグラフィ
text-xsfont-size: var(--text-xs); /* 0.75rem */ line-height: var(--tw-leading, var(--text-xs--line-height));
text-smfont-size: var(--text-sm); /* 0.875rem */ line-height: var(--tw-leading, var(--text-sm--line-height));
text-basefont-size: var(--text-base); /* 1rem */ line-height: var(--tw-leading, var(--text-base--line-height));
text-xlfont-size: var(--text-xl); /* 1.25rem */ line-height: var(--tw-leading, var(--text-xl--line-height));
text-4xlfont-size: var(--text-4xl); /* 2.25rem */ line-height: var(--tw-leading, var(--text-4xl--line-height));
text-sm/6font-size: var(--text-sm); line-height: calc(var(--spacing) * 6);
font-sansfont-family: var(--font-sans);
font-monofont-family: var(--font-mono);
font-mediumfont-weight: var(--font-weight-medium); /* 500 */
font-semiboldfont-weight: var(--font-weight-semibold); /* 600 */
font-boldfont-weight: var(--font-weight-bold); /* 700 */
leading-tightline-height: var(--leading-tight); /* 1.25 */
leading-6line-height: calc(var(--spacing) * 6);
tracking-tightletter-spacing: var(--tracking-tight); /* -0.025em */
tracking-wideletter-spacing: var(--tracking-wide);
text-lefttext-align: left;
text-centertext-align: center;
text-righttext-align: right;
uppercasetext-transform: uppercase;
capitalizetext-transform: capitalize;
italicfont-style: italic;
underlinetext-decoration-line: underline;
no-underlinetext-decoration-line: none;
underline-offset-4text-underline-offset: 4px;
decoration-2text-decoration-thickness: 2px;
truncateoverflow: hidden; text-overflow: ellipsis; white-space: nowrap;
line-clamp-3overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
text-balancetext-wrap: balance;
text-prettytext-wrap: pretty;
whitespace-nowrapwhite-space: nowrap;
wrap-break-wordoverflow-wrap: break-word; /* added in v4.1 */
tabular-numsfont-variant-numeric: tabular-nums;
antialiased-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
色と背景
text-blue-600color: var(--color-blue-600); /* oklch(54.6% 0.245 262.881) */
bg-whitebackground-color: var(--color-white); /* #fff */
bg-slate-900background-color: var(--color-slate-900);
bg-black/50background-color: color-mix(in oklab, var(--color-black) 50%, transparent);
bg-[#4f98fb]background-color: #4f98fb;
bg-(--brand)background-color: var(--brand);
text-currentcolor: currentColor;
bg-transparentbackground-color: transparent;
border-gray-200border-color: var(--color-gray-200);
fill-currentfill: currentColor;
accent-blue-600accent-color: var(--color-blue-600);
caret-pink-500caret-color: var(--color-pink-500);
bg-linear-to-rbackground-image: linear-gradient(to right in oklab, var(--tw-gradient-stops)); /* simplified */
from-blue-500--tw-gradient-from: var(--color-blue-500); /* first stop */
to-violet-500--tw-gradient-to: var(--color-violet-500);
bg-radialbackground-image: radial-gradient(...stops); /* new in v4 */
bg-coverbackground-size: cover;
bg-centerbackground-position: center;
bg-no-repeatbackground-repeat: no-repeat;
bg-clip-textbackground-clip: text;
ボーダー、角丸、リング、アウトライン
borderborder-style: var(--tw-border-style); border-width: 1px; /* color is currentColor in v4 */
border-2border-style: var(--tw-border-style); border-width: 2px;
border-tborder-top-style: var(--tw-border-style); border-top-width: 1px;
border-dashed--tw-border-style: dashed; border-style: dashed;
rounded-xsborder-radius: var(--radius-xs); /* 0.125rem */
rounded-smborder-radius: var(--radius-sm); /* 0.25rem */
rounded-mdborder-radius: var(--radius-md); /* 0.375rem */
rounded-lgborder-radius: var(--radius-lg); /* 0.5rem */
rounded-2xlborder-radius: var(--radius-2xl); /* 1rem */
rounded-fullborder-radius: calc(infinity * 1px);
rounded-t-lgborder-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg);
divide-yborder-bottom-width: 1px on every child except the last (selector: > :not(:last-child))
ring-1box-shadow: 0 0 0 1px currentColor; /* simplified; v4 default ring width is 1px */
ring-3box-shadow: 0 0 0 3px currentColor; /* the old v3 ring */
ring-blue-500--tw-ring-color: var(--color-blue-500);
ring-offset-2--tw-ring-offset-width: 2px;
outlineoutline-style: var(--tw-outline-style); outline-width: 1px;
outline-2outline-style: var(--tw-outline-style); outline-width: 2px;
outline-offset-2outline-offset: 2px;
outline-hiddenoutline: 2px solid transparent; outline-offset: 2px; /* still visible in forced colors */
outline-none--tw-outline-style: none; outline-style: none;
エフェクトとフィルター
shadow-2xsbox-shadow: 0 1px rgb(0 0 0 / 0.05);
shadow-xsbox-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
shadow-smbox-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), 0 2px 4px -2px rgb(0 0 0 / 0.1);
shadow-lgbox-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
shadow-2xlbox-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
shadow-nonebox-shadow: 0 0 #0000;
inset-shadow-smbox-shadow: inset 0 2px 4px rgb(0 0 0 / 0.05); /* new in v4 */
opacity-50opacity: 50%;
mix-blend-multiplymix-blend-mode: multiply;
blur-smfilter: blur(var(--blur-sm)); /* 8px */
blur-xsfilter: blur(var(--blur-xs)); /* 4px */
backdrop-blur-mdbackdrop-filter: blur(var(--blur-md)); /* 12px, frosted glass */
grayscalefilter: grayscale(100%);
トランジション、アニメーション、変形
transitiontransition-property: color, background-color, border-color, outline-color, opacity, box-shadow, transform, translate, scale, rotate, filter and more; transition-duration: 150ms;
transition-colorstransition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke and gradient stops; 150ms
duration-200transition-duration: 200ms;
ease-outtransition-timing-function: var(--ease-out); /* cubic-bezier(0, 0, 0.2, 1) */
animate-spinanimation: var(--animate-spin); /* spin 1s linear infinite */
animate-pulseanimation: var(--animate-pulse);
motion-reduce:animate-none@media (prefers-reduced-motion: reduce) { animation: none; }
scale-95--tw-scale-x: 95%; --tw-scale-y: 95%; scale: var(--tw-scale-x) var(--tw-scale-y);
rotate-45rotate: 45deg;
translate-x-4--tw-translate-x: calc(var(--spacing) * 4); translate: var(--tw-translate-x) var(--tw-translate-y);
-translate-y-1/2--tw-translate-y: calc(calc(1/2 * 100%) * -1); translate: var(--tw-translate-x) var(--tw-translate-y);
インタラクション
cursor-pointercursor: pointer; /* v4 buttons default to cursor: default */
cursor-not-allowedcursor: not-allowed;
pointer-events-nonepointer-events: none;
select-noneuser-select: none;
appearance-noneappearance: none;
scroll-smoothscroll-behavior: smooth;
snap-xscroll-snap-type: x var(--tw-scroll-snap-strictness);
snap-startscroll-snap-align: start;
scroll-mt-20scroll-margin-top: calc(var(--spacing) * 20);
resize-yresize: vertical;
touch-manipulationtouch-action: manipulation;
状態とメディアのバリアント
hover:bg-blue-700@media (hover: hover) { &:hover { background-color: var(--color-blue-700); } }
focus-visible:outline-2&:focus-visible { outline-width: 2px; ... }
active:scale-95&:active { scale: 95%; }
disabled:opacity-50&:disabled { opacity: 50%; }
aria-disabled:opacity-50&[aria-disabled="true"] { opacity: 50%; }
group-hover:underline.group:hover & { text-decoration-line: underline; } (inside @media (hover: hover))
peer-checked:bg-blue-600.peer:checked ~ & { background-color: var(--color-blue-600); }
md:flex@media (width >= 48rem) { display: flex; }
max-md:hidden@media (width < 48rem) { display: none; }
@md:flex-row@container (width >= 28rem) { flex-direction: row; }
dark:bg-slate-900@media (prefers-color-scheme: dark) { background-color: var(--color-slate-900); }
print:hidden@media print { display: none; }
motion-safe:animate-spin@media (prefers-reduced-motion: no-preference) { ... }
*:p-2:where(& > *) { padding: calc(var(--spacing) * 2); }
not-last:mb-2&:not(:last-child) { margin-bottom: ... }
supports-[display:grid]:grid@supports (display: grid) { display: grid; }
bg-red-500!background-color: var(--color-red-500) !important;

表の読み方:初期値の--spacingは0.25remなので、calc(var(--spacing) * 4)は1remです。@themeでこの変数1つを変えれば、数値スケールを使うパディング、マージン、間隔、幅、高さがすべて一緒に変わります。生成されるCSSが長い場合(グラデーション、リング、トランジション)は、表では簡略版を示し、その旨を記載しています。

v4がクラスを値に変える仕組み

v4でユーティリティに値を与える方法は4つあり、どれを使っているかが分かれば、たいていの戸惑いは説明がつきます。

w-1/2のような分数はcalc(1/2 * 100%)になり、bg-black/50のような不透明度の接尾辞は透明色とのcolor-mix()になるため、どの色形式でも機能します。

@themeトークン(tailwind.config.jsに代わるv4の仕組み)

v4ではデザインシステムをCSSで設定します。@theme内で宣言した変数は、:root上のCSSカスタムプロパティになると同時に、ユーティリティクラスの元にもなります。変数の接頭辞によって、どのユーティリティに使われるかが決まります。

@import "tailwindcss";

@theme {
  --font-display: "Satoshi", sans-serif;   /* font-display */
  --color-brand-500: oklch(65% 0.17 255);  /* bg-brand-500, text-brand-500 ... */
  --breakpoint-3xl: 120rem;                /* 3xl: variant */
  --spacing: 0.25rem;                      /* p-4 = 1rem */
  --radius-card: 0.875rem;                 /* rounded-card */
}
名前空間使われる先例
--color-*すべての色ユーティリティ(bg、text、border、fill、ring、影の色など)bg-red-500
--spacingパディング、マージン、間隔、幅、高さ、inset、translatepx-4
--font-*フォントファミリーfont-sans
--text-*フォントサイズ(任意で--text-*--line-heightも)text-xl
--font-weight-*フォントの太さfont-bold
--tracking-* / --leading-*字間/行の高さtracking-wide
--breakpoint-*レスポンシブのバリアントsm:*
--container-*コンテナクエリのバリアントとmax-w-*@sm:*, max-w-md
--radius-*角丸rounded-sm
--shadow-*, --inset-shadow-*, --drop-shadow-*影shadow-md
--blur-*ぼかしと背景のぼかしblur-md
--ease-* / --animate-*タイミング関数/アニメーションease-out, animate-spin
--perspective-* / --aspect-*3Dの遠近感/アスペクト比perspective-near, aspect-video

既定の名前空間を丸ごと外すには、まず--color-*: initial;のようにinitialを設定し、そのあと自分の色だけを宣言します。JavaScriptの設定がまだある場合、v4は@config "./tailwind.config.js";で読み込めますが、corePlugins、safelist、separatorの各オプションはサポートされません。

ブレークポイント

ブレークポイントはモバイルファーストです。接頭辞のないクラスはすべての幅に適用され、md:flexは48rem以上で適用されます。v4は範囲構文width >= ...で出力します。

接頭辞最小幅CSSそれ未満(max-*)
sm:40rem (640px)@media (width >= 40rem)max-sm: = @media (width < 40rem)
md:48rem (768px)@media (width >= 48rem)max-md:
lg:64rem (1024px)@media (width >= 64rem)max-lg:
xl:80rem (1280px)@media (width >= 80rem)max-xl:
2xl:96rem (1536px)@media (width >= 96rem)max-2xl:

重ねると範囲を指定できます。md:max-xl:flexは48rem以上80rem未満でのみ適用されます。一度きりのブレークポイントにはmin-[900px]:gridやmax-[600px]:hiddenを使います。ブレークポイントの追加や変更は@theme内の--breakpoint-*で行い、正しく並ぶようすべてremで統一しましょう。

コンテナクエリ

コンテナクエリはv4に組み込まれています(v3ではプラグインが必要でした)。親要素に@containerを付け、子要素を@sm:、@md:などでスタイル指定します。ウィンドウではなく親要素の幅に反応するため、サイドバーにも広いメイン列にも置くカードにぴったりです。

<div class="@container">
  <article class="flex flex-col @md:flex-row gap-4">
    <img class="w-full @md:w-48 rounded-lg" src="..." alt="">
    <div>...</div>
  </article>
</div>
バリアントコンテナ幅バリアントコンテナ幅
@3xs16rem (256px)@2xl42rem (672px)
@2xs18rem (288px)@3xl48rem (768px)
@xs20rem (320px)@4xl56rem (896px)
@sm24rem (384px)@5xl64rem (1024px)
@md28rem (448px)@6xl72rem (1152px)
@lg32rem (512px)@7xl80rem (1280px)
@xl36rem (576px)

それぞれ@container (width >= ...)にコンパイルされます。「それ未満」には@max-md:を使い、範囲には@sm:@max-md:のように重ね、@container/sidebarでコンテナに名前を付けて@md/sidebar:で指定し、@min-[475px]:のような任意のサイズも使えます。コンテナのサイズはブレークポイントと同じ数値ではない点に注意してください。@mdは28remですが、md:は48remです。

flexとgridのクイックリファレンス

下でレイアウトを選ぶと、ボックスが動きます。クリックに合わせてクラス文字列が更新されるので、そのままマークアップにコピーできます。

最もよく使うパターン:

flex items-center justify-between:ナビバーの行
flex items-center justify-center(またはgrid place-items-center):1つの要素を中央に配置
col-span-2と組み合わせたgrid grid-cols-3 gap-2
固定する要素にshrink-0、残りを埋める要素にflex-1
目的クラス
ブレークポイントなしのレスポンシブなカードグリッドgrid grid-cols-[repeat(auto-fill,minmax(16rem,1fr))] gap-6
サイドバーとコンテンツgrid md:grid-cols-[16rem_1fr] gap-8
短いページで下端に固定するフッターラッパーにflex min-h-dvh flex-col、mainにflex-1
flexの行の中で省略表示されるテキストflexの子要素にmin-w-0、テキストにtruncate
モバイルでは縦積み、デスクトップでは横並びflex flex-col md:flex-row gap-4
最後の要素を右端に寄せるその要素にms-auto(またはml-auto)

既定のカラーパレット(OKLCH)、クリックでコピー

v4は既定のパレットをOKLCHで定義しており、広色域の画面ではより鮮やかな色を表示できます。下の各色見本は、Tailwind自身のテーマファイルにある正確な値で塗られています。クリックすると、そのoklch()値をコピーできます。濃淡は50から950まであります。*印の付いたパレット(mauve、olive、mist、taupe)はv4.2.0で追加されたため、それより前のv4リリースにはありません。黒と白は#000と#fffです。

全26件を表示中
50100200300400500600700800900950
red
orange
amber
yellow
lime
green
emerald
teal
cyan
sky
blue
indigo
violet
purple
fuchsia
pink
rose
slate
gray
zinc
neutral
stone
mauve*
olive*
mist*
taupe*

bg-sky-500、text-sky-500/80のように使うか、自分のCSSではvar(--color-sky-500)として使います。組み合わせが読みやすいか確かめるにはカラーコントラストチェッカーを、同じ形式で独自のスケールを作るにはTailwindカラーパレットジェネレーターをお試しください。

v4のダークモード

初期設定では、dark:は@media (prefers-color-scheme: dark)を通じてOSの設定に従います。代わりにクラスや属性で切り替えたい場合(手動トグルなど)は、CSSで@custom-variantを使ってバリアントを上書きします。darkModeという設定キーはもうありません。

/* Class strategy: <html class="dark"> */
@custom-variant dark (&:where(.dark, .dark *));

/* Or a data attribute: <html data-theme="dark"> */
@custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *));
<div class="bg-white text-slate-900 dark:bg-slate-900 dark:text-slate-100">...</div>

手動トグルの場合は、ページが描画される前にクラスを設定します(<head>内に、保存された選択を読み取る小さなインラインスクリプトを置きます)。こうすれば、訪問者に違うテーマが一瞬表示されることはありません。3つ目の方法はdark:クラスをまったく使わないことです。@themeで--color-surfaceのような意味的なトークンを定義し、.darkの下で値を入れ替えれば、bg-surfaceのような1つのクラスが両方のテーマで機能します。

v3からv4へ:名前が変わったクラスと挙動が変わったクラス

以下は公式のアップグレードガイドに基づいています。古い名前もまだ存在し、何も警告せずに異なる(小さい)結果を出すため、名称変更が特に重要です。

v3v4理由
shadow-smshadow-xsすべてのサイズに名前が付くよう、スケールが1段階下にずれた
shadowshadow-sm同じずれ
drop-shadow-sm / drop-shadowdrop-shadow-xs / drop-shadow-sm同じずれ
blur-sm / blurblur-xs / blur-sm同じずれ(backdrop-blur-*も)
rounded-smrounded-xs同じずれ
roundedrounded-sm同じずれ
outline-noneoutline-hiddenv4のoutline-noneは本当にoutline-style: noneを設定するようになった
ring(3px、blue-500)ring-3と色を指定単独のringはcurrentColorの1pxになった
outline outline-2outline-2幅のユーティリティ自体がsolidスタイルを設定するようになった
bg-opacity-50(text-、border-、ring-、divide-、placeholder-opacityも)bg-black/50削除。スラッシュ修飾子を使う
flex-shrink-0 / flex-growshrink-0 / growエイリアスを削除
overflow-ellipsistext-ellipsisエイリアスを削除
decoration-slice / decoration-clonebox-decoration-slice / box-decoration-cloneエイリアスを削除
bg-[--brand]bg-(--brand)CSS変数の新しい短縮形
!bg-red-500bg-red-500!重要度指定は末尾に付ける(旧形式は非推奨)
first:*:pt-0*:first:pt-0重ねたバリアントは左から右へ読むようになった
tw-flex(接頭辞)tw:flex接頭辞はバリアントのような形になり、先頭に付く

名前は変わらず挙動だけが変わったもので、アップグレード時につまずきやすい点:

公式のnpx @tailwindcss/upgradeツールが、ほとんどの名称変更を自動で処理します。きれいなブランチで実行して差分を確認しましょう。どのshadowクラスを同じ見た目のままにしたかったのかは、ツールには分からないためです。

このシートを印刷する

このページには印刷用スタイルがあります。検索ボックスとボタンは非表示になり、表は小さい文字に縮み、カラーグリッドは色見本をまとめて保ちます。多くのブラウザーでは、印刷ダイアログで「背景のグラフィック」をオンにしないと色見本が空白で印刷されます。先に表を絞り込むと表示中の行だけが印刷されるので、自分が使うユーティリティだけの1枚のシートをすばやく作れます。

同じprint:バリアントは自分のプロジェクトでも使えます。ナビゲーションにprint:hidden、薄い文字にprint:text-black、カードにprint:break-inside-avoidを付ければ、印刷したページが読みやすくなります。

よくある質問

Tailwind v4ではtailwind.config.jsはどこにありますか?

v4はCSSで設定します。@import "tailwindcss"でTailwindを読み込み、--color-brand-500や--breakpoint-3xlのようなデザイントークンを@themeブロック内で宣言します。JavaScriptの設定も@configディレクティブで読み込めますが、corePlugins、safelist、separatorの各オプションはサポートされません。

Tailwind v4の既定のブレークポイントは?

smは40rem(640px)、mdは48rem(768px)、lgは64rem(1024px)、xlは80rem(1280px)、2xlは96rem(1536px)です。モバイルファーストなので、md:flexは48rem以上で適用されます。ブレークポイント未満のスタイルにはmax-md:を使い、範囲を指定するにはmd:max-xl:のように重ねます。

v4にアップグレードしたら影や角丸が小さく見えるのはなぜ?

影、角丸、ぼかしのスケールが1段階下にずれたためです。v3のshadow-smはv4のshadow-xs、v3のshadowはv4のshadow-sm、v3のrounded-smはv4のrounded-xs、v3のroundedはv4のrounded-smに当たります。古い名前もコンパイルできるのでエラーにはならず、1段階小さいサイズが出力されるだけです。

v4でダークモードをシステム設定ではなくクラスで切り替えるには?

CSSに@custom-variant dark (&:where(.dark, .dark *));を追加します。すると、祖先要素にdarkクラスがあるときにdark:ユーティリティが適用されます。data属性を使いたい場合は、セレクターに[data-theme=dark]を使います。

Tailwind v4でコンテナクエリにプラグインは必要ですか?

いいえ。コンテナクエリは組み込まれています。親要素に@containerを付け、子要素に@sm:、@md:、@max-md:などのバリアントを使います。コンテナのサイズは@3xs(16rem)から始まり、ページのブレークポイントとは異なります。たとえば@mdは28remです。

Tailwind v4でp-4は何にコンパイルされますか?

padding: calc(var(--spacing) * 4)です。初期値の--spacingが0.25remなので1rem(既定のフォントサイズで16px)になります。余白スケールでは設定なしで任意の整数が使え、--spacingを変えればすべてが一度に拡縮されます。

表示

アイテムの配置

方向

折り返し

主軸

列数

交差軸

間隔

コピーしました

クラスをコピー

このチートシートを印刷

無料で始める · クレジットカード不要

関連: ガイド|Webマーケティングと集客を学ぶ

製品

ご利用いただける方

機能

リソース

会社情報

サイトマップを見る