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
위에서 몇 가지 사항을 알 수 있습니다. 첫째, 우리가 원할 때 태그 머리글 제목으로서의 요소(예: h3 제목, 우리는 그것을 IgrCardHeader 태그에 삽입하고 슬롯 이름을 title. 반대로, 다른 제목 요소를 만들고 싶다면 subtitle 우리는 슬롯의 이름을 지정할 것입니다. subtitle.
카드에 표시하려는 이미지나 비디오는 태그 안에 래핑합니다 IgrCardMedia. 이를 IgrCardMedia 통해 내부에 배치된 콘텐츠의 크기를 조정하여 요소의 전체 콘텐츠 상자를 채우는 동안 종횡비를 유지할 수 있습니다. 개체의 종횡비가 상자의 종횡비와 일치하지 않으면 개체가 그에 맞게 잘립니다.
태그 안에 IgrCardContent 무엇이든 넣을 수 있습니다. 일반적으로 텍스트는 거기로 이동합니다.
카드에는 설정된 경우 카드에서 그림자를 제거하고 얇은 테두리로 대체하여 카드를 배경과 분리하는 outlined 속성이 있습니다.
수평 레이아웃
기본적으로 카드의 모든 섹션(헤더, 콘텐츠, 미디어, 작업)은 수직으로 배치됩니다. 수직 공간이 많을 때 좋습니다. 카드의 섹션을 수평으로 배치하고 싶다고 가정해 보겠습니다. 간단한 CSS를 사용하여 이러한 레이아웃을 구현할 수 있습니다.
다음은 윤곽선이 있는 가로 카드의 예입니다.
<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 요소를 사용하여 and를 IgrCardHeader 함께 묶고, 세 IgrCardContent 로로 정렬하고, 래핑 div 요소에 클래스를 적용.card-horizontal 하여 카드의 두 섹션을 가로로 정렬합니다.
importReactfrom'react';
importReactDOMfrom'react-dom/client';
import'./index.css';
import'./CardHorizontal.css';
import { IgrCard, IgrCardHeader, IgrCardContent, IgrCardActions, IgrCardModule } from"@infragistics/igniteui-react";
import'igniteui-webcomponents/themes/light/bootstrap.css';
IgrCardModule.register();
exportdefaultclass CardHorizontal extendsReact.Component<any, any> {
constructor(props: any) {
super(props);
}
publicrender(): JSX.Element {
return (
<divclassName="container sample"><divclassName="card-wrapper"><IgrCard><divkey="cardContainer"className="card-horizontal"><divkey="cardHeaderContainer"><IgrCardHeaderkey="cardHeader"><imgkey="headerImg"src="https://static.infragistics.com/xplatform/images/music/rozes.jpg"slot="thumbnail"></img><h5key="headerTitle"slot="title">Rozes</h5><h5key="headerSubtitle"slot="subtitle">Under the Grave (2016)</h5></IgrCardHeader><IgrCardContentkey="cardContent"><pkey="content">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><divkey="divider"className="divider"></div><IgrCardActionskey="cardActions"><spankey="actionsPrevious"className="material-icons">skip_previous</span><spankey="actionsPlay"className="material-icons">play_arrow</span><spankey="actionsNext"className="material-icons">skip_next</span></IgrCardActions></div></IgrCard></div></div>
);
}
}
// rendering above class to the React DOMconstroot = ReactDOM.createRoot(document.getElementById('root'));
root.render(<CardHorizontal/>);
tsx
아래는 세로 카드를 만드는 방법을 보여주는 예로, 카드의 모든 섹션이 세로로 배치되고 세 IgrCardMedia로 섹션과 함께 표시됩니다.
<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
이 글에서는 카드 구성 요소로 많은 것을 다루었습니다. 간단한 카드를 만들고 이미지를 추가하여 조금 더 매력적으로 만들었습니다. 아바타, 버튼, 아이콘과 같은 추가 React 카드 내부에 사용하여 경험을 풍부하게 하고 기능을 추가했습니다. 마지막으로 빌딩 블록의 주요 색상을 변경하여 카드의 모양을 변경했습니다.