Ignite UI for React の完全な概要については、作業の開始トピックを参照してください。
次に、デモのカード テンプレートを表すために、以下のコードを追加します:
<IgrCard><IgrCardMedia><imgsrc="https://images.unsplash.com/photo-1518235506717-e1ed3306a89b?ixlib=rb-1.2.1&auto=format&fit=crop&w=640&q=50"></img></IgrCardMedia><IgrCardHeader><h3slot="title">New York City</h3><h5slot="subtitle">City in New York</h5></IgrCardHeader><IgrCardContent><p>New York City comprises 5 boroughs sitting where the
Hudson River meets the Atlantic Ocean. At its core is Manhattan,
a densely populated borough that’s among the world’s major commercial,
financial and cultural centers.</p></IgrCardContent><IgrCardActions><IgrButton><span>Read more</span><IgrRipple /></IgrButton><divslot="end"><IgrIconButtonname="twitter"collection="material"><IgrRipple /></IgrIconButton><IgrIconButtonname="facebook"collection="material"><IgrRipple /></IgrIconButton></div></IgrCardActions></IgrCard>tsx
<IgrCard><divclassName="card-horizontal"><div><IgrCardHeader><imgsrc="https://static.infragistics.com/xplatform/images/music/rozes.jpg"slot="thumbnail"></img><h5slot="title">Rozes</h5><h5slot="subtitle">Under the Grave (2016)</h5></IgrCardHeader><IgrCardContent><p>As I have always said: I write what’s real and what’s true,
even if it means throwing myself under the bus.</p></IgrCardContent></div><divclassName="divider"></div><IgrCardActions><spanclassName="material-icons">skip_previous</span><spanclassName="material-icons">play_arrow</span><spanclassName="material-icons">skip_next</span></IgrCardActions></div></IgrCard>tsx
追加の div 要素を使用して IgrCardHeader と IgrCardContent をバンドルし、それらを垂直方向に整列させ、.card-horizontal クラスをラッピング div 要素に適用して、カードの 2 つのセクションを水平方向に整列させます。
importReactfrom'react';
importReactDOMfrom'react-dom/client';
import'./index.css';
import'./CardHorizontal.css';
import { IgrCard, IgrCardHeader, IgrCardContent, IgrCardActions } from"@infragistics/igniteui-react";
import'igniteui-webcomponents/themes/light/bootstrap.css';
exportdefaultfunction CardHorizontal() {
return (
<divclassName="container sample"><divclassName="card-wrapper"><IgrCard><divclassName="card-horizontal"><div><IgrCardHeader><imgsrc="https://static.infragistics.com/xplatform/images/music/rozes.jpg"slot="thumbnail"></img><h5slot="title">Rozes</h5><h5slot="subtitle">Under the Grave (2016)</h5></IgrCardHeader><IgrCardContent><p>As I have always said: I write what’s real and what’s true,
even if it means throwing myself under the bus.</p></IgrCardContent></div><divclassName="divider"></div><IgrCardActions><spanclassName="material-icons">skip_previous</span><spanclassName="material-icons">play_arrow</span><spanclassName="material-icons">skip_next</span></IgrCardActions></div></IgrCard></div></div>
);
}
// rendering above component to the React DOMconstroot = ReactDOM.createRoot(document.getElementById('root'));
root.render(<CardHorizontal/>);
tsx
<IgrCard><divclassName="semi-horizontal"><div><IgrCardHeader><IgrAvatarsrc="https://static.infragistics.com/xplatform/images/music/singer_with_mic.jpg"slot="thumbnail" /><h5slot="title">HERE</h5><h5slot="subtitle">by Mellow D</h5></IgrCardHeader><IgrCardContent><p>Far far away, behind the word mountains,
far from the countries Vokalia and Consonantia,
there live the blind texts.</p></IgrCardContent><IgrCardActions><IgrButton><span>Play Album</span></IgrButton></IgrCardActions></div><IgrCardMediaclassName='card-media'><imgsrc="https://static.infragistics.com/xplatform/images/music/singer_female.jpg"></img></IgrCardMedia></div></IgrCard>tsx
importReactfrom"react";
importReactDOMfrom"react-dom/client";
import"./index.css";
import"./CardSemiHorizontal.css";
import {
IgrCard,
IgrCardHeader,
IgrCardContent,
IgrCardActions,
IgrCardMedia,
IgrAvatar,
IgrButton,
} from"@infragistics/igniteui-react";
import"igniteui-webcomponents/themes/light/bootstrap.css";
exportdefaultfunction CardSemiHorizontal() {
return (
<divclassName="container sample center"><divclassName="card-wrapper"><IgrCard><divclassName="semi-horizontal"><div><IgrCardHeader><IgrAvatarsrc="https://static.infragistics.com/xplatform/images/music/singer_with_mic.jpg"slot="thumbnail"
/><h5slot="title">HERE</h5><h5slot="subtitle">by Mellow D</h5></IgrCardHeader><IgrCardContent><p>
Far far away, behind the word mountains, far from the
countries Vokalia and Consonantia, there live the blind texts.
</p></IgrCardContent><IgrCardActions><IgrButton><span>Play Album</span></IgrButton></IgrCardActions></div><IgrCardMediaclassName="card-media"><imgsrc="https://static.infragistics.com/xplatform/images/music/singer_female.jpg"></img></IgrCardMedia></div></IgrCard></div></div>
);
}
// rendering above component to the React DOMconstroot = ReactDOM.createRoot(document.getElementById("root"));
root.render(<CardSemiHorizontal />);
tsx