Title: テーマサポート
Author: Akira Tachibana
Published: 2020年7月24日
Last modified: 2026年8月13日

---

# テーマサポート

## この投稿内

 * [オプトイン機能](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%AA%E3%83%97%E3%83%88%E3%82%A4%E3%83%B3%E6%A9%9F%E8%83%BD)
 * [デフォルトのブロックスタイル](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%AE%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB)
    - [拡張したブロックスタイル](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E6%8B%A1%E5%BC%B5%E3%81%97%E3%81%9F%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB)
    - [幅広の配置](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E5%B9%85%E5%BA%83%E3%81%AE%E9%85%8D%E7%BD%AE)
    - [幅広の配置とフロート](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E5%B9%85%E5%BA%83%E3%81%AE%E9%85%8D%E7%BD%AE%E3%81%A8%E3%83%95%E3%83%AD%E3%83%BC%E3%83%88)
    - [ブロックカラーパレット](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%82%AB%E3%83%A9%E3%83%BC%E3%83%91%E3%83%AC%E3%83%83%E3%83%88)
    - [ブロックグラデーションのプリセット](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%82%B0%E3%83%A9%E3%83%87%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E3%83%97%E3%83%AA%E3%82%BB%E3%83%83%E3%83%88)
    - [ブロックフォントサイズ](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%83%95%E3%82%A9%E3%83%B3%E3%83%88%E3%82%B5%E3%82%A4%E3%82%BA)
    - [カスタムフォントサイズの無効化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%83%95%E3%82%A9%E3%83%B3%E3%83%88%E3%82%B5%E3%82%A4%E3%82%BA%E3%81%AE%E7%84%A1%E5%8A%B9%E5%8C%96)
    - [ブロックカラーパレットでのカスタム色の無効化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%82%AB%E3%83%A9%E3%83%BC%E3%83%91%E3%83%AC%E3%83%83%E3%83%88%E3%81%A7%E3%81%AE%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E8%89%B2%E3%81%AE%E7%84%A1%E5%8A%B9%E5%8C%96)
    - [カスタムグラデーションの無効化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%82%B0%E3%83%A9%E3%83%87%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E7%84%A1%E5%8A%B9%E5%8C%96)
    - [ベースレイアウトスタイルの無効化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%99%E3%83%BC%E3%82%B9%E3%83%AC%E3%82%A4%E3%82%A2%E3%82%A6%E3%83%88%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB%E3%81%AE%E7%84%A1%E5%8A%B9%E5%8C%96)
    - [カスタムの行の高さのサポート](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%81%AE%E8%A1%8C%E3%81%AE%E9%AB%98%E3%81%95%E3%81%AE%E3%82%B5%E3%83%9D%E3%83%BC%E3%83%88)
    - [カスタムユニットのサポート](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%83%A6%E3%83%8B%E3%83%83%E3%83%88%E3%81%AE%E3%82%B5%E3%83%9D%E3%83%BC%E3%83%88)
    - [デフォルトのブロックパターンの無効化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%AE%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3%E3%81%AE%E7%84%A1%E5%8A%B9%E5%8C%96)
 * [エディタースタイル](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%A8%E3%83%87%E3%82%A3%E3%82%BF%E3%83%BC%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB)
    - [エディタースタイルのエンキュー](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%A8%E3%83%87%E3%82%A3%E3%82%BF%E3%83%BC%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB%E3%81%AE%E3%82%A8%E3%83%B3%E3%82%AD%E3%83%A5%E3%83%BC)
    - [基本の色](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E5%9F%BA%E6%9C%AC%E3%81%AE%E8%89%B2)
    - [エディターの幅の変更](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%A8%E3%83%87%E3%82%A3%E3%82%BF%E3%83%BC%E3%81%AE%E5%B9%85%E3%81%AE%E5%A4%89%E6%9B%B4)
 * [埋め込みコンテンツのレスポンシブ化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E5%9F%8B%E3%82%81%E8%BE%BC%E3%81%BF%E3%82%B3%E3%83%B3%E3%83%86%E3%83%B3%E3%83%84%E3%81%AE%E3%83%AC%E3%82%B9%E3%83%9D%E3%83%B3%E3%82%B7%E3%83%96%E5%8C%96)
 * [スペースの制御](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%B9%E3%83%9A%E3%83%BC%E3%82%B9%E3%81%AE%E5%88%B6%E5%BE%A1)
 * [リンク色の制御](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%AA%E3%83%B3%E3%82%AF%E8%89%B2%E3%81%AE%E5%88%B6%E5%BE%A1)
 * [外観ツール](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E5%A4%96%E8%A6%B3%E3%83%84%E3%83%BC%E3%83%AB)
 * [枠線](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E6%9E%A0%E7%B7%9A)
 * [リンク色](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%AA%E3%83%B3%E3%82%AF%E8%89%B2)
 * [ブロックベースのテンプレートパーツ](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%83%99%E3%83%BC%E3%82%B9%E3%81%AE%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%83%91%E3%83%BC%E3%83%84)

新しいブロックにはすべてのテーマで有効な基本サポートや、オプトイン可能なオプション、
拡張やカスタマイズ可能な機能があります。

テーマを構築する際は、以下の新しいコンセプトを検討してください。

 * **エディターカラーパレット** – 色のデフォルトセットを提供します。ただしテーマ
   は独自の色を登録したり、オブションでユーザーに定義したパレットからのみ色を選択
   するよう強制できます。
 * **エディターテキストサイズパレット** – テキストサイズのデフォルトセットを提供
   します。ただしテーマは独自のテキストサイズを登録したり、オブションでユーザーに
   設定されたサイズからのみ選択するよう強制できます。
 * **レスポンシブな埋め込みコンテンツ** – テーマが埋め込みコンテンツをレスポンシブ
   化するにはオプトインしなければなりません。
 * **フロントエンドとエディターのスタイル** – ブロックのスタイルを最大限活かすに
   は、テーマ作者はコアのスタイルが適切であることを確認してオプトインするか、テーマ
   に合う独自のスタイルを記述します。
 * **ブロックツール** – テーマは「行の高さ」や「カスタムユニット」などいくつかの
   ブロックツールをオプトインできます。
 * **コアのブロックパターン** – テーマはデフォルトのブロックパターンをオプトアウト
   できます。

デフォルトでブロックはそのまま使える基本的なスタイルを提供します。また、以下で説明
するようなオプトインで有効化するスタイルも提供します。テーマはこれらのスタイルを
追加したり上書きできます。逆にテーマではまったくスタイルを提供せず、ブロックが提供
するスタイルに完全に依存することもできます。

いくつかの高度なブロック機能はテーマによるオプトインのサポートが必要です。これは
ブロックからのスタイルの提供が容易ではなく、正しく動作するにはテーマの構造の理解
が必要なためです。

これらの機能をオプトインするには以下の例のように、テーマの `functions.php` ファイル
で `add_theme_support` を呼び出します。

    ```notranslate
    function mytheme_setup_theme_supported_features() {
    	add_theme_support( 'editor-color-palette', array(
    		array(
    			'name'  => esc_attr__( 'strong magenta', 'themeLangDomain' ),
    			'slug'  => 'strong-magenta',
    			'color' => '#a156b4',
    		),
    		array(
    			'name'  => esc_attr__( 'light grayish magenta', 'themeLangDomain' ),
    			'slug'  => 'light-grayish-magenta',
    			'color' => '#d0a5db',
    		),
    		array(
    			'name'  => esc_attr__( 'very light gray', 'themeLangDomain' ),
    			'slug'  => 'very-light-gray',
    			'color' => '#eee',
    		),
    		array(
    			'name'  => esc_attr__( 'very dark gray', 'themeLangDomain' ),
    			'slug'  => 'very-dark-gray',
    			'color' => '#444',
    		),
    	) );
    }

    add_action( 'after_setup_theme', 'mytheme_setup_theme_supported_features' );
    ```

## 󠀁[オプトイン機能](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%AA%E3%83%97%E3%83%88%E3%82%A4%E3%83%B3%E6%A9%9F%E8%83%BD)󠁿

## 󠀁[デフォルトのブロックスタイル](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%AE%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB)󠁿

コアブロックにはデフォルトで構造化スタイルが含まれていて、エディター、フロントエンド
の両方で読み込まれます。このスタイルの例は「カラム」ブロックで利用されている CSS
です。このルールがなければブロックは、まったくカラムを含まない壊れたレイアウトに
なります。

### 󠀁[拡張したブロックスタイル](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E6%8B%A1%E5%BC%B5%E3%81%97%E3%81%9F%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB)󠁿

ブロックエディターでは、テーマがフロントエンドに拡張したスタイルをオプトインでき
ます。このスタイルの例は「引用」ブロックの左側のデフォルトのカラーバーです。クラシック
テーマでこの拡張スタイルを使用する場合はテーマサポートに `wp-block-styles` を追加
します。

    ```notranslate
    add_theme_support( 'wp-block-styles' );
    ```

[ブロックライブラリーテーマファイル](https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/theme.scss)
内で、含まれる CSS を参照できます。

ブロックテーマや `theme.json` ファイルを提供するテーマの場合、このテーマサポート
の使用は推奨されません。代わりに、グローバルスタイルのルールとブロックスタイルの
間でスタイルが衝突しないように、必要なブロックスタイルはテーマの `theme.json` ファイル
に追加してください。

### 󠀁[幅広の配置](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E5%B9%85%E5%BA%83%E3%81%AE%E9%85%8D%E7%BD%AE)󠁿

「画像」ブロックやいくつかのブロックには「幅広 (wide)」や「全幅 (full)」を定義する
機能があり、ブロックのラッパーに対応するクラス名を追加します (`alignwide` や `alignfull`)。
テーマは以下のようにオプトインします。

    ```notranslate
    add_theme_support( 'align-wide' );
    ```

この関数の詳細については [`add_theme_support()` の開発者ドキュメント](https://developer.wordpress.org/reference/functions/add_theme_support/)
を参照してください。

### 󠀁[幅広の配置とフロート](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E5%B9%85%E5%BA%83%E3%81%AE%E9%85%8D%E7%BD%AE%E3%81%A8%E3%83%95%E3%83%AD%E3%83%BC%E3%83%88)󠁿

幅広な画像、サイドバー、中央揃えのカラム、中央揃えのカラム内でフロートする要素等々、
レスポンシブなレイアウト作成は困難です。

ブロックエディターはフロートした画像に追加マークアップを付加してスタイリングを容易
にします。

キャプション付きの `Image` のマークアップを示します。

    ```notranslate
    <figure class="wp-block-image">
    	<img src="..." alt="" width="200px" />
    	<figcaption>Short image caption.</figcaption>
    </figure>
    ```

左にフロートする画像のマークアップを示します。

    ```notranslate
    <div class="wp-block-image">
    	<figure class="alignleft">
    		<img src="..." alt="" width="200px" />
    		<figcaption>Short image caption.</figcaption>
    	</figure>
    </div>
    ```

[codepen](https://codepen.io/joen/pen/zLWvrW) にマークアップを使用した例があります。
レスポンシブなレイアウトでサイドバー、幅広の画像、キャプション付きのフロートする
要素ががあります。

### 󠀁[ブロックカラーパレット](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%82%AB%E3%83%A9%E3%83%BC%E3%83%91%E3%83%AC%E3%83%83%E3%83%88)󠁿

異なるブロックはそれぞれで色をカスタマイズしている可能性があります。ブロックエディター
はデフォルトのパレットを提供しますが、テーマはこれを上書きして独自のパレットを提供
できます。

    ```notranslate
    add_theme_support( 'editor-color-palette', array(
    	array(
    		'name'  => esc_attr__( 'strong magenta', 'themeLangDomain' ),
    		'slug'  => 'strong-magenta',
    		'color' => '#a156b4',
    	),
    	array(
    		'name'  => esc_attr__( 'light grayish magenta', 'themeLangDomain' ),
    		'slug'  => 'light-grayish-magenta',
    		'color' => '#d0a5db',
    	),
    	array(
    		'name'  => esc_attr__( 'very light gray', 'themeLangDomain' ),
    		'slug'  => 'very-light-gray',
    		'color' => '#eee',
    	),
    	array(
    		'name'  => esc_attr__( 'very dark gray', 'themeLangDomain' ),
    		'slug'  => 'very-dark-gray',
    		'color' => '#444',
    	),
    ) );
    ```

`name` は上の例のようなラベルです。ツールチップに表示され、ユーザーに意味のある説明
を伝えます。スクリーンリーダーを使用するユーザーには特に重要で、説明が不十分であれ
ば色の認識が困難になります。`slug` は色の一意の識別子です。ブロックエディターのカラー
パレットで使われる CSS クラスの生成で使用されます。`color` は色を指定する16進コード
です。

Twenty Nineteen テーマのメインカラーやサブカラーのように動的に変わる色もあり、これらの
色はプログラム的に記述できません。その場合でも必要な際のデフォルト値として意味の
あるテキストを `name` に設定することを推奨します。

色はパレット上に順番に表示され、指定可能な数に制限はありません。

テーマにはコンテキストに応じて色に適用するクラスを作成する責任があります。コアブロック
は「color」コンテキスト、「background-color」コンテキスト、「border-color」コンテキスト
を使用します。コアブロックのすべてのコンテキストで正しく「strong magenta」を適用
するにはテーマはクラス自身を実装する必要があります。クラス名は、最初に「has-」、
続けてケバブケースを使用したクラス名、最後にコンテキスト名で作成します。

    ```notranslate
    .has-strong-magenta-color {
    	color: #a156b4;
    }

    .has-strong-magenta-background-color {
    	background-color: #a156b4;
    }

    .has-strong-magenta-border-color {
    	border-color: #a156b4;
    }
    ```

WordPress 5.9 以降、`theme.json` を持たないテーマが、コアで定義された色の値を上書き
するには、クラスを提供する代わりに、CSSカスタムプロパティで値を設定しなければなり
ません。CSSカスタムプロパティは、命名規則 `--wp--preset--color--<slug>` を使用し
ます。詳細については [devnote](https://make.wordpress.org/core/2022/01/08/updates-for-settings-styles-and-theme-json/)
を参照してください。例えば

    ```notranslate
    :root {
    	--wp--preset--color--cyan-bluish-gray: <new_value>;
    	--wp--preset--color--pale-pink: <new_value>;
    }
    ```

### 󠀁[ブロックグラデーションのプリセット](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%82%B0%E3%83%A9%E3%83%87%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E3%83%97%E3%83%AA%E3%82%BB%E3%83%83%E3%83%88)󠁿

異なるブロックはそれぞれ事前に定義されたグラデーションを選択している可能性があり
ます。ブロックエディターはデフォルトのグラデーションのプリセットを提供しますが、
テーマはこれを上書きし独自のグラデーションを提供できます。

    ```notranslate
    add_theme_support(
    	'editor-gradient-presets',
    	array(
    		array(
    			'name'     => esc_attr__( 'Vivid cyan blue to vivid purple', 'themeLangDomain' ),
    			'gradient' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
    			'slug'     => 'vivid-cyan-blue-to-vivid-purple'
    		),
    		array(
    			'name'     => esc_attr__( 'Vivid green cyan to vivid cyan blue', 'themeLangDomain' ),
    			'gradient' => 'linear-gradient(135deg,rgba(0,208,132,1) 0%,rgba(6,147,227,1) 100%)',
    			'slug'     =>  'vivid-green-cyan-to-vivid-cyan-blue',
    		),
    		array(
    			'name'     => esc_attr__( 'Light green cyan to vivid green cyan', 'themeLangDomain' ),
    			'gradient' => 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
    			'slug'     => 'light-green-cyan-to-vivid-green-cyan',
    		),
    		array(
    			'name'     => esc_attr__( 'Luminous vivid amber to luminous vivid orange', 'themeLangDomain' ),
    			'gradient' => 'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)',
    			'slug'     => 'luminous-vivid-amber-to-luminous-vivid-orange',
    		),
    		array(
    			'name'     => esc_attr__( 'Luminous vivid orange to vivid red', 'themeLangDomain' ),
    			'gradient' => 'linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%)',
    			'slug'     => 'luminous-vivid-orange-to-vivid-red',
    		),
    	)
    );
    ```

`name` は上の例のようなラベルです。ツールチップに表示され、ユーザーに意味のある説明
を伝えます。スクリーンリーダーを使用するユーザーには特に重要で、説明が不十分であれ
ばグラデーションの認識が困難になります。`gradient` はブロックの背景色に適用される
グラデーションの CSS 値です。有効なグラデーションタイプの詳細については [mozilla のドキュメント](https://developer.mozilla.org/ja/docs/Web/CSS/CSS_Images/Using_CSS_gradients)
を参照してください。`slug` はグラデーションの一意の識別子です。ブロックエディター
で使われる CSS クラスの生成で使用されます。

テーマにはグラデーションに適用するクラスを作成する責任があります。正しく「Vivid 
cyan blue to vivid purple」を適用するには、テーマは次のクラスを実装する必要があり
ます。

    ```notranslate
    .has-vivid-cyan-blue-to-vivid-purple-gradient-background {
    	background: linear-gradient(
    		135deg,
    		rgba( 6, 147, 227, 1 ) 0%,
    		rgb( 155, 81, 224 ) 100%
    	);
    }
    ```

WordPress 5.9 以降、`theme.json` を持たないテーマが、コアで定義されたグラデーション
の値を上書きするには、クラスを提供する代わりに、CSSカスタムプロパティで値を設定しな
ければなりません。CSSカスタムプロパティは、命名規則 `--wp--preset--gradient--<slug
>` を使用します。詳細については [devnote](https://make.wordpress.org/core/2022/01/08/updates-for-settings-styles-and-theme-json/)
を参照してください。例えば

    ```notranslate
    :root {
    	--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple: <new_value>;
    	--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan: <new_value>;
    }
    ```

### 󠀁[ブロックフォントサイズ](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%83%95%E3%82%A9%E3%83%B3%E3%83%88%E3%82%B5%E3%82%A4%E3%82%BA)󠁿

「段落」ブロックのように、ユーザーはブロックで使用するフォントのサイズを構成でき
ます。ブロックはでフォントサイズのデフォルトセットを提供しますが、テーマはこれを
上書きし独自のセットを提供できます。

    ```notranslate
    add_theme_support( 'editor-font-sizes', array(
    	array(
    		'name' => esc_attr__( 'Small', 'themeLangDomain' ),
    		'size' => 12,
    		'slug' => 'small'
    	),
    	array(
    		'name' => esc_attr__( 'Regular', 'themeLangDomain' ),
    		'size' => 16,
    		'slug' => 'regular'
    	),
    	array(
    		'name' => esc_attr__( 'Large', 'themeLangDomain' ),
    		'size' => 36,
    		'slug' => 'large'
    	),
    	array(
    		'name' => esc_attr__( 'Huge', 'themeLangDomain' ),
    		'size' => 50,
    		'slug' => 'huge'
    	)
    ) );
    ```

フォントサイズはテーマが提供した順番でフォントサイズピッカー上にレンダリングされ
ます。

テーマには正しいフォントサイズスタイルに適用するクラスを作成する責任があります。
クラス名は、最初に「has-」、続けてケバブケースを使用したフォントサイズ名、最後に`-
font-size` で作成します。

たとえば標準のフォントサイズであれば、テーマは次のクラスを提供します。

    ```notranslate
    .has-regular-font-size {
    	font-size: 16px;
    }
    ```

**注意:** スラッグ `default` と `custom` は予約済みのため、テーマでは使えません。

WordPress 5.9 以降、`theme.json` を持たないテーマが、コアで定義されたフォントサイズ
の値を上書きするには、クラスを提供する代わりに、CSSカスタムプロパティで値を設定しな
ければなりません。CSSカスタムプロパティは、命名規則 `--wp--preset--font-size--<slug
>` を使用します。詳細については [devnote](https://make.wordpress.org/core/2022/01/08/updates-for-settings-styles-and-theme-json/)
を参照してください。例えば

    ```notranslate
    :root {
    	--wp--preset--font-size--small: <new_value>;
    	--wp--preset--font-size--large: <new_value>;
    }
    ```

### 󠀁[カスタムフォントサイズの無効化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%83%95%E3%82%A9%E3%83%B3%E3%83%88%E3%82%B5%E3%82%A4%E3%82%BA%E3%81%AE%E7%84%A1%E5%8A%B9%E5%8C%96)󠁿

テーマはカスタムフォントサイズの設定を無効化できます。

    ```notranslate
    add_theme_support( 'disable-custom-font-sizes' );
    ```

無効化するとユーザーはブロックエディターで提供されるデフォルトのサイズ、またはテーマ
サポート設定 `editor-font-sizes` で提供されたサイズに制限されます。

### 󠀁[ブロックカラーパレットでのカスタム色の無効化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%82%AB%E3%83%A9%E3%83%BC%E3%83%91%E3%83%AC%E3%83%83%E3%83%88%E3%81%A7%E3%81%AE%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E8%89%B2%E3%81%AE%E7%84%A1%E5%8A%B9%E5%8C%96)󠁿

デフォルトでブロックのユーザーは、カラーパレットを使用してエディターやテーマのデフォルト
の色と異なるカスタム色を選択できます。

テーマはこの機能を無効化できます。

    ```notranslate
    add_theme_support( 'disable-custom-colors' );
    ```

無効化するとユーザーは、テーマが提供した `editor-color-palette`、またはテーマが提供
していなければエディターのデフォルト色からのみ色を選択できます。

### 󠀁[カスタムグラデーションの無効化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%82%B0%E3%83%A9%E3%83%87%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E7%84%A1%E5%8A%B9%E5%8C%96)󠁿

テーマはカスタムグラデーションの設定を無効化できます。

    ```notranslate
    add_theme_support( 'disable-custom-gradients' );
    ```

無効化するとユーザーは、ブロックエディターで提供されるデフォルトのグラデーション、
またはテーマサポート設定 `editor-gradient-presets` で提供されたグラデーションに制限
されます。

### 󠀁[ベースレイアウトスタイルの無効化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%99%E3%83%BC%E3%82%B9%E3%83%AC%E3%82%A4%E3%82%A2%E3%82%A6%E3%83%88%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB%E3%81%AE%E7%84%A1%E5%8A%B9%E5%8C%96)󠁿

_**注意:** WordPress 6.1以降_

テーマは、グループ、カラム、ボタン、ソーシャルアイコンなどのコアブロックにデフォルト
の構造スタイルを提供する、生成されたブロックレイアウトスタイルを拒否できます。次
のコードを使用して、テーマは独自の構造スタイルを提供することをコミットします。提供
せずに、この機能を使用すると、エディターとサイトのフロントエンドの両方でコアブロック
が正しく表示されません。

    ```notranslate
    add_theme_support( 'disable-layout-styles' );
    ```

`blockGap` スタイルやブロック間隔をカスタマイズしたいテーマは、[グローバル設定とスタイルに関する開発者向けドキュメント](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/global-settings-and-styles/#blockGap-%E3%81%A8%E3%81%AF%E4%BD%95%E3%81%8B%E3%80%81%E3%81%A9%E3%81%86%E4%BD%BF%E3%81%86%E3%81%AE%E3%81%8B-)
を参照してください。

### 󠀁[カスタムの行の高さのサポート](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%81%AE%E8%A1%8C%E3%81%AE%E9%AB%98%E3%81%95%E3%81%AE%E3%82%B5%E3%83%9D%E3%83%BC%E3%83%88)󠁿

「段落」や「見出し」などいくつかのブロックは行の高さのカスタマイズをサポートします。
テーマはこの機能のサポートを有効化できます。

    ```notranslate
    add_theme_support( 'custom-line-height' );
    ```

### 󠀁[カスタムユニットのサポート](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%83%A6%E3%83%8B%E3%83%83%E3%83%88%E3%81%AE%E3%82%B5%E3%83%9D%E3%83%BC%E3%83%88)󠁿

ユーザーはピクセルに加えて、サイズやパディングなどを定義する他の単位を使用できます。
利用可能な単位は px、em、rem、vh、vw です。テーマはこの機能のサポートを無効化でき
ます。

    ```notranslate
    add_theme_support( 'custom-units', array() );
    ```

テーマはまた利用可能なカスタムユニットを選択できます。

    ```notranslate
    add_theme_support( 'custom-units', 'rem', 'em' );
    ```

### 󠀁[デフォルトのブロックパターンの無効化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%AE%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3%E3%81%AE%E7%84%A1%E5%8A%B9%E5%8C%96)󠁿

WordPress には多くの組み込みブロックパターンが付属します。テーマは同梱のパターン
をオプトアウトし、独自のセットを提供できます。

    ```notranslate
    remove_theme_support( 'core-block-patterns' );
    ```

## 󠀁[エディタースタイル](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%A8%E3%83%87%E3%82%A3%E3%82%BF%E3%83%BC%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB)󠁿

ブロックエディターはテーマの [エディタースタイル](https://codex.wordpress.org/Editor_Style)
をサポートしますが、クラシックエディターとは少し異なって動作します。

クラシックエディターではエディタースタイルは WYSIWYG エディターの iframe に直接、
変更なしでロードされていました。しかしブロックエディターは iframe を使用しません。
このためブロックエディターではスタイルがエディターのコンテンツだけに適用されるよう、
エディタースタイルを選択的に書き換えるか、一部の CSS セレクターを調整して自動的に
変換します。またこの動作によりブロックエディターはエディタースタイルでブロックの
バリエーションをプレビューできます。

たとえばエディタースタイル内の `body { ... }` は `.editor-styles-wrapper { ... }`
に書き換えられます。ちなみにこのことはエディターのクラス名を直接 _指定すべきでない_
ことも意味しています。

この動作は少し変わっているため、テーマには add_editor_style に加えて追加のオプトイン
が必要です。

    ```notranslate
    add_theme_support( 'editor-styles' );
    ```

エディタースタイルの多くを変更する必要はありません。ほとんどのテーマは上のコード
を追加することでクラシックエディターでもブロックエディターでも同じ結果を得られます。

### 󠀁[エディタースタイルのエンキュー](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%A8%E3%83%87%E3%82%A3%E3%82%BF%E3%83%BC%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB%E3%81%AE%E3%82%A8%E3%83%B3%E3%82%AD%E3%83%A5%E3%83%BC)󠁿

エディター画面に CSS をエンキューしロードするには `add_editor_style` 関数を使用し
てください。クラシックエディターではこの関数のみでエディターにスタイルを追加でき
ました。新しいブロックエディターでは上で説明したようにまず `add_theme_support( '
editor-styles');` が必要です。

    ```notranslate
    add_editor_style( 'style-editor.css' );
    ```

`functions.php` ファイルに上の行を追加すると、エディター内にロードされるスタイル
シートのキューにスタイルシート `style-editor.css` が追加されます。

### 󠀁[基本の色](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E5%9F%BA%E6%9C%AC%E3%81%AE%E8%89%B2)󠁿

他の Web ページのようにエディターをスタイルできます。次のコードは背景色とフォント
の色を青に変更します。

    ```notranslate
    /* `style-editor.css` ファイルに追加する */
    body {
    	background-color: #d3ebf3;
    	color: #00005d;
    }
    ```

### 󠀁[エディターの幅の変更](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%A8%E3%83%87%E3%82%A3%E3%82%BF%E3%83%BC%E3%81%AE%E5%B9%85%E3%81%AE%E5%A4%89%E6%9B%B4)󠁿

エディターのメインのカラムの幅を変更するには `style-editor.css` に次の CSS を追加
します。

    ```notranslate
    /* メインのカラム幅 */
    .wp-block {
    	max-width: 720px;
    }

    /* 「幅広」ブロックの幅 */
    .wp-block[data-align="wide"] {
    	max-width: 1080px;
    }

    /* 「全幅」ブロックの幅 */
    .wp-block[data-align="full"] {
    	max-width: none;
    }
    ```

テーマと合わせるためにこれらのエディターの幅を使用できます。`%` や `px` を含む任意
の CSS 幅の単位を使用できます。

[スタイルシートでのスタイルの適用](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/block-tutorial/applying-styles-with-stylesheets/)
も参照してください。

## 󠀁[埋め込みコンテンツのレスポンシブ化](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E5%9F%8B%E3%82%81%E8%BE%BC%E3%81%BF%E3%82%B3%E3%83%B3%E3%83%86%E3%83%B3%E3%83%84%E3%81%AE%E3%83%AC%E3%82%B9%E3%83%9D%E3%83%B3%E3%82%B7%E3%83%96%E5%8C%96)󠁿

「埋め込み」ブロックは、iFrame 内に埋め込まれたコンテンツのアスペクト比を反映する
ため、自動的に埋め込みコンテンツに対してスタイルを適用します。アスペクト比にレスポンシブ
な形でのブロックスタイルは次のようになります。

    ```notranslate
    <figure class="wp-embed-aspect-16-9 wp-has-aspect-ratio">...</figure>
    ```

アスペクト比を保ったままコンテンツをリサイズするには `<body>` 要素に `wp-embed-responsive`
クラスが必要です。デフォルトでは設定されないため、テーマは `responsive-embeds` 機能
をオプトインする必要があります。

    ```notranslate
    add_theme_support( 'responsive-embeds' );
    ```

## 󠀁[スペースの制御](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%82%B9%E3%83%9A%E3%83%BC%E3%82%B9%E3%81%AE%E5%88%B6%E5%BE%A1)󠁿

いくつかのブロックはパディングの制御を持つことができます。この機能は標準で無効の
ため、テーマはサポートを宣言してオプトインする必要があります。

Some blocks can have padding controls. This is off by default, and requires the 
theme to opt in by declaring support:

    ```notranslate
    add_theme_support( 'custom-spacing' );
    ```

## 󠀁[リンク色の制御](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%AA%E3%83%B3%E3%82%AF%E8%89%B2%E3%81%AE%E5%88%B6%E5%BE%A1)󠁿

link サポートは WordPress 5.8の一部として安定動作します。デフォルトは `false` ですが、
テーマは [theme.json ファイル](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/curating-the-editor-experience/theme-json)
を通して有効化できます。

    ```notranslate
    {
    	"settings": {
    		"color": {
    			"link": true
    		}
    	}
    }
    ```

> 代替として、Gutenberg プラグインが有効な場合は、古いレガシーサポートである `add_theme_support('
> experimental-link-color' )` も機能します。このフォールバックは、Gutenberg プラグ
> インのサポートするバージョンが WordPress 5.9 以上になった時点で削除されます。

ユーザーがブロックのリンク色を設定すると、新しいスタイルが追加されます。

    ```notranslate
    .wp-elements-<uuid> a {
    	color: <link-color> !important;
    }
    ```

このとき

 * `<uuid>` は、ランダムな番号です
 * `<link-color>` は、`var(--wp--preset--color--slug)` (プリセット値が選択された
   場合)、または、生のカラー値 (カスタム値が選択された場合) です。

このブロックには、クラス `.wp-elements-<uuid>` が付けられます。

## 󠀁[外観ツール](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E5%A4%96%E8%A6%B3%E3%83%84%E3%83%BC%E3%83%AB)󠁿

この設定を使用すると、以下のグローバルスタイル設定が有効になります。

 * border: color, radius, style, width
 * color: link
 * spacing: blockGap, margin, padding
 * typography: lineHeight
 * dimensions: aspectRatio, height, minHeight, width
 * position: sticky

    ```notranslate
    add_theme_support( 'appearance-tools' );
    ```

## 󠀁[枠線](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E6%9E%A0%E7%B7%9A)󠁿

すべての枠線の設定を有効化します。

    ```notranslate
    add_theme_support( 'border' );
    ```

## 󠀁[リンク色](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%AA%E3%83%B3%E3%82%AF%E8%89%B2)󠁿

リンク色の設定を有効化します。

    ```notranslate
    add_theme_support( 'link-color' );
    ```

## 󠀁[ブロックベースのテンプレートパーツ](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/theme-support/?output_format=md#%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%83%99%E3%83%BC%E3%82%B9%E3%81%AE%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%83%91%E3%83%BC%E3%83%84)󠁿

ブロックベースのテンプレートパーツにより管理者は、ブロックを使用してサイトの一部
を編集できます。この設定はデフォルトではオフで、テーマはサポートを宣言することで
オプトインする必要があります。

    ```notranslate
    add_theme_support( 'block-template-parts' );
    ```

この機能はブロックベースではないテーマにのみ関連します。ブロックベースのテーマでは
サイトエディターの一部として、ブロックベースのテンプレートパーツを既にサポートし
ています。

スタンドアロンのテンプレートパーツエディターでは、エディターは新規テンプレートパーツ
の作成や、既存テンプレートパーツの削除はできません。これは、テーマが手動でテンプレート
パーツをPHPテンプレートに含める必要があるためです。

ブロックベースのテンプレートパーツの詳細については、[テーマハンドブックのブロックテンプレートとテンプレートパーツのセクション](https://developer.wordpress.org/themes/block-themes/templates-and-template-parts/#block-c5fa39a2-a27d-4bd2-98d0-dc6249a0801a)
を参照してください。

[原文](https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/themes/theme-support.md)

公開日

2020年7月24日

最終更新

2026年8月13日

[  前へ: グローバル設定とスタイル (theme.json)](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/themes/global-settings-and-styles/)

[  次へ: Thunks in Core-Data](https://ja.wordpress.org/team/handbook/block-editor/how-to-guides/thunks/)