ヘッダーは、ページの上部に配置されるページのルートコンポーネントです。1つ以上のツールバーのラッパーとして使用することが推奨されていますが、あらゆる要素をラップするために使用することができます。ツールバーがヘッダー内で使用される場合、コンテンツは正しいサイズになるように調整され、ヘッダーはデバイスセーフ領域を考慮します。
基本的な使い方
<ion-header>
<ion-toolbar>
<ion-title>Header</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<h1>Content</h1>
</ion-content>半透明のヘッダー
ヘッダーは、translucentプロパティを設定することで、ネイティブiOSアプリケーションで見られる透明度と一致させることができます。コンテンツをヘッダーの背後にスクロールさせるには、コンテンツにfullscreenプロパティを設定する必要があります。この効果は、モードが"ios"であり、デバイスがbackdrop-filterをサポートしている場合にのみ適用されます。
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>Header</ion-title>
</ion-toolbar>
</ion-header>
<ion-content [fullscreen]="true" class="ion-padding">
<h1>Animal Facts</h1>
<h2>Rhinoceros</h2>
<img
alt="rhino standing near grass"
src="https://images.unsplash.com/flagged/photo-1556983257-71fddc36bc75?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1742&q=80"
/>
<p>
The rhinoceros gets its name from one of its most notable features: its horns. The word rhinoceros come from the
Greek words rhino meaning “nose” and ceros meaning “horn.” The number of horns that a rhino has varies on the
species. The two African species (the black rhino and the white rhino) and the Sumatran rhino have two horns, while
the Javan rhino and one-horned rhino have one horn.
</p>
<h2>Sea Turtle</h2>
<img
alt="brown sea turtle in water"
src="https://images.unsplash.com/photo-1573551089778-46a7abc39d9f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1974&q=80"
/>
<p>
Sea turtles are characterized by a large, streamlined shell and non-retractile head and limbs. Unlike other turtles,
sea turtles cannot pull their limbs and head inside their shells. Their limbs are flippers that are adapted for
swimming, so they are vulnerable while on land.
</p>
<h2>Giraffe</h2>
<img
alt="giraffe sticking its tongue out"
src="https://images.unsplash.com/photo-1577114995803-d8ce0e2b4aa9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1746&q=80"
/>
<p>
Giraffes are known for their long, tall appearance. They have a small hump on their back like a camel and have a
spotted pattern similar to that of a leopard. Because of the combination of these features, some people called the
giraffe a “camel-leopard.” That’s where the giraffe’s species name “camelopardalis” comes from.
</p>
<h2>Elephant</h2>
<img
alt="two grey elephants on grass plains during sunset"
src="https://images.unsplash.com/photo-1564760055775-d63b17a55c44?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1754&q=80"
/>
<p>
Elephants are the largest existing land animal, with massive bodies, large ears, and long trunks. Elephants’ long
trunks are multifunctional. They are used to pick up objects, trumpet warnings, greet other elephants, or suck up
water for drinking or bathing.
</p>
<h2>Dolphin</h2>
<img
alt="black and white dolphin in water"
src="https://images.unsplash.com/photo-1607153333879-c174d265f1d2?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1742&q=80"
/>
<p>
Dolphins range in color depending on the species, from white, pearl, and pink to darker shades of brown, gray, blue,
and black. They have smooth skin, flippers, and a dorsal fin. They have a long, slender snout with about 100 teeth
and a streamlined body. They have a single blowhole on top of their head, which has a flap that opens to reveal a
pair of nostrils. The dolphin uses these nostrils for breathing when it surfaces.
</p>
</ion-content>折りたたみのヘッダー
Ionicでは、iOSネイティブアプリケーションで見られる、大きなツールバーのタイトルを表示し、スクロールすると小さなタイトルに折りたたむ機能を提供しています。これは、コンテンツの上に1つ、コンテンツの中に1つ、合計2つのヘッダーを追加し、コンテンツの中にあるヘッダーに collapse プロパティを "condense" に設定することで実現できます。この効果は、モードが "ios "のときのみ適用されます。
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>Header</ion-title>
</ion-toolbar>
</ion-header>
<ion-content [fullscreen]="true">
<ion-header collapse="condense">
<ion-toolbar>
<ion-title size="large">Header</ion-title>
</ion-toolbar>
</ion-header>
<div class="ion-padding">
<h1>Animal Facts</h1>
<h2>Rhinoceros</h2>
<img
alt="rhino standing near grass"
src="https://images.unsplash.com/flagged/photo-1556983257-71fddc36bc75?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1742&q=80"
/>
<p>
The rhinoceros gets its name from one of its most notable features: its horns. The word rhinoceros come from the
Greek words rhino meaning “nose” and ceros meaning “horn.” The number of horns that a rhino has varies on the
species. The two African species (the black rhino and the white rhino) and the Sumatran rhino have two horns,
while the Javan rhino and one-horned rhino have one horn.
</p>
<h2>Sea Turtle</h2>
<img
alt="brown sea turtle in water"
src="https://images.unsplash.com/photo-1573551089778-46a7abc39d9f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1974&q=80"
/>
<p>
Sea turtles are characterized by a large, streamlined shell and non-retractile head and limbs. Unlike other
turtles, sea turtles cannot pull their limbs and head inside their shells. Their limbs are flippers that are
adapted for swimming, so they are vulnerable while on land.
</p>
<h2>Giraffe</h2>
<img
alt="giraffe sticking its tongue out"
src="https://images.unsplash.com/photo-1577114995803-d8ce0e2b4aa9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1746&q=80"
/>
<p>
Giraffes are known for their long, tall appearance. They have a small hump on their back like a camel and have a
spotted pattern similar to that of a leopard. Because of the combination of these features, some people called the
giraffe a “camel-leopard.” That’s where the giraffe’s species name “camelopardalis” comes from.
</p>
<h2>Elephant</h2>
<img
alt="two grey elephants on grass plains during sunset"
src="https://images.unsplash.com/photo-1564760055775-d63b17a55c44?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1754&q=80"
/>
<p>
Elephants are the largest existing land animal, with massive bodies, large ears, and long trunks. Elephants’ long
trunks are multifunctional. They are used to pick up objects, trumpet warnings, greet other elephants, or suck up
water for drinking or bathing.
</p>
<h2>Dolphin</h2>
<img
alt="black and white dolphin in water"
src="https://images.unsplash.com/photo-1607153333879-c174d265f1d2?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1742&q=80"
/>
<p>
Dolphins range in color depending on the species, from white, pearl, and pink to darker shades of brown, gray,
blue, and black. They have smooth skin, flippers, and a dorsal fin. They have a long, slender snout with about 100
teeth and a streamlined body. They have a single blowhole on top of their head, which has a flap that opens to
reveal a pair of nostrils. The dolphin uses these nostrils for breathing when it surfaces.
</p>
</div>
</ion-content>フェードヘッダー
多くのネイティブiOSアプリケーションは、ツールバーにフェード効果を持たせています。これは、ヘッダーの collapse プロパティを "fade" に設定することで実現可能です。ページが最初に読み込まれたとき、ヘッダーの背景と境界線は非表示になります。コンテンツがスクロールされると、ヘッダーは再びフェードインします。この効果は、モードが「ios」のときだけ適用されます。
この機能は、折りたたみヘッダーと組み合わせることができます。collapseプロパティに"fade"を設定した場合は、コンテンツの外側にあるヘッダーに適用する必要があります。
<ion-header collapse="fade">
<ion-toolbar>
<ion-title>Header</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<h1>Animal Facts</h1>
<h2>Rhinoceros</h2>
<img
alt="rhino standing near grass"
src="https://images.unsplash.com/flagged/photo-1556983257-71fddc36bc75?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1742&q=80"
/>
<p>
The rhinoceros gets its name from one of its most notable features: its horns. The word rhinoceros come from the
Greek words rhino meaning “nose” and ceros meaning “horn.” The number of horns that a rhino has varies on the
species. The two African species (the black rhino and the white rhino) and the Sumatran rhino have two horns, while
the Javan rhino and one-horned rhino have one horn.
</p>
<h2>Sea Turtle</h2>
<img
alt="brown sea turtle in water"
src="https://images.unsplash.com/photo-1573551089778-46a7abc39d9f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1974&q=80"
/>
<p>
Sea turtles are characterized by a large, streamlined shell and non-retractile head and limbs. Unlike other turtles,
sea turtles cannot pull their limbs and head inside their shells. Their limbs are flippers that are adapted for
swimming, so they are vulnerable while on land.
</p>
<h2>Giraffe</h2>
<img
alt="giraffe sticking its tongue out"
src="https://images.unsplash.com/photo-1577114995803-d8ce0e2b4aa9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1746&q=80"
/>
<p>
Giraffes are known for their long, tall appearance. They have a small hump on their back like a camel and have a
spotted pattern similar to that of a leopard. Because of the combination of these features, some people called the
giraffe a “camel-leopard.” That’s where the giraffe’s species name “camelopardalis” comes from.
</p>
<h2>Elephant</h2>
<img
alt="two grey elephants on grass plains during sunset"
src="https://images.unsplash.com/photo-1564760055775-d63b17a55c44?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1754&q=80"
/>
<p>
Elephants are the largest existing land animal, with massive bodies, large ears, and long trunks. Elephants’ long
trunks are multifunctional. They are used to pick up objects, trumpet warnings, greet other elephants, or suck up
water for drinking or bathing.
</p>
<h2>Dolphin</h2>
<img
alt="black and white dolphin in water"
src="https://images.unsplash.com/photo-1607153333879-c174d265f1d2?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1742&q=80"
/>
<p>
Dolphins range in color depending on the species, from white, pearl, and pink to darker shades of brown, gray, blue,
and black. They have smooth skin, flippers, and a dorsal fin. They have a long, slender snout with about 100 teeth
and a streamlined body. They have a single blowhole on top of their head, which has a flap that opens to reveal a
pair of nostrils. The dolphin uses these nostrils for breathing when it surfaces.
</p>
</ion-content>仮想スクロールの使用方法
フェードヘッダーが正しく動作するためには、スクロールコンテナが必要です。仮想スクロールソリューションを使用する場合は、カスタムスクロールターゲットを提供する必要があります。コンテンツのスクロールを無効にし、スクロールを担当する要素に .ion-content-scroll-host クラスを追加する必要があります。
<ion-header collapse="fade">
<ion-toolbar>
<ion-title>Header</ion-title>
</ion-toolbar>
</ion-header>
<ion-content [scrollY]="false">
<div class="ion-content-scroll-host ion-padding">
<h1>Animal Facts</h1>
<h2>Rhinoceros</h2>
<img
alt="rhino standing near grass"
src="https://images.unsplash.com/flagged/photo-1556983257-71fddc36bc75?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1742&q=80"
/>
<p>
The rhinoceros gets its name from one of its most notable features: its horns. The word rhinoceros come from the
Greek words rhino meaning “nose” and ceros meaning “horn.” The number of horns that a rhino has varies on the
species. The two African species (the black rhino and the white rhino) and the Sumatran rhino have two horns,
while the Javan rhino and one-horned rhino have one horn.
</p>
<h2>Sea Turtle</h2>
<img
alt="brown sea turtle in water"
src="https://images.unsplash.com/photo-1573551089778-46a7abc39d9f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1974&q=80"
/>
<p>
Sea turtles are characterized by a large, streamlined shell and non-retractile head and limbs. Unlike other
turtles, sea turtles cannot pull their limbs and head inside their shells. Their limbs are flippers that are
adapted for swimming, so they are vulnerable while on land.
</p>
<h2>Giraffe</h2>
<img
alt="giraffe sticking its tongue out"
src="https://images.unsplash.com/photo-1577114995803-d8ce0e2b4aa9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1746&q=80"
/>
<p>
Giraffes are known for their long, tall appearance. They have a small hump on their back like a camel and have a
spotted pattern similar to that of a leopard. Because of the combination of these features, some people called the
giraffe a “camel-leopard.” That’s where the giraffe’s species name “camelopardalis” comes from.
</p>
<h2>Elephant</h2>
<img
alt="two grey elephants on grass plains during sunset"
src="https://images.unsplash.com/photo-1564760055775-d63b17a55c44?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1754&q=80"
/>
<p>
Elephants are the largest existing land animal, with massive bodies, large ears, and long trunks. Elephants’ long
trunks are multifunctional. They are used to pick up objects, trumpet warnings, greet other elephants, or suck up
water for drinking or bathing.
</p>
<h2>Dolphin</h2>
<img
alt="black and white dolphin in water"
src="https://images.unsplash.com/photo-1607153333879-c174d265f1d2?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1742&q=80"
/>
<p>
Dolphins range in color depending on the species, from white, pearl, and pink to darker shades of brown, gray,
blue, and black. They have smooth skin, flippers, and a dorsal fin. They have a long, slender snout with about 100
teeth and a streamlined body. They have a single blowhole on top of their head, which has a flap that opens to
reveal a pair of nostrils. The dolphin uses these nostrils for breathing when it surfaces.
</p>
</div>
</ion-content>Borders
"md"モードでは、ヘッダーの下部に box-shadow が表示されます。 "ios"モードでは、ヘッダの下部に border が表示されます。これらは、ヘッダーに .ion-no-border クラスを追加することで削除することができます。
<ion-header class="ion-no-border">
<ion-toolbar>
<ion-title>Header</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<h1>Content</h1>
</ion-content>プロパティ
collapse
| Description | ヘッダーに適用されるスクロール効果を記述します。iOS modeでのみ適用されます。 通常、折りたたみ式ラージタイトルに使用します。 |
| Attribute | collapse |
| Type | "condense" | "fade" | undefined |
| Default | undefined |
mode
| Description | modeは、どのプラットフォームのスタイルを使用するかを決定します。 This is a virtual property that is set once during initialization and will not update if you change its value after the initial render. |
| Attribute | mode |
| Type | "ios" | "md" |
| Default | undefined |
translucent
| Description | trueの場合、ヘッダーは半透明になります。modeが "ios" で、デバイスが backdrop-filter をサポートしている場合にのみ適用されます。 注意:ヘッダーの後ろにコンテンツをスクロールさせるには、コンテンツに fullscreen 属性が設定されている必要があります。 |
| Attribute | translucent |
| Type | boolean |
| Default | false |
イベント
No events available for this component.
メソッド
No public methods available for this component.
CSS Shadow Parts
No CSS shadow parts available for this component.
CSSカスタムプロパティ
No CSS custom properties available for this component.
Slots
No slots available for this component.