React Carousel 개요
Ignite UI for React 텍스트 슬라이드, 링크 및 기타 HTML 요소가 포함된 이미지 컬렉션을 앞뒤로 탐색하는 사용자에게 슬라이드쇼와 같은 웹 경험을 만드는 가장 유연한 방법을 제공하는 반응형 경량 구성 요소입니다.
React Carousel 구성 요소를 사용하면 애니메이션, 슬라이드 전환 및 사용자 지정을 사용할 수 있으므로 인터페이스를 쉽게 조정하고 사용자 정의 캐러셀 React 구축할 수 있습니다.
React 캐러셀 예시
아래에서 볼 수 있는 React Carousel 데모는 이미지만 포함된 슬라이드를 보여줍니다.
EXAMPLE
TSX
CarouselOverview.css
index.css
import React from "react" ;
import ReactDOM from "react-dom/client" ;
import {
IgrCarousel,
IgrCarouselSlide,
} from "@infragistics/igniteui-react" ;
import "igniteui-webcomponents/themes/light/bootstrap.css" ;
import "./CarouselOverview.css" ;
import "./index.css" ;
export default function CarouselOverview() {
return (
<div className ="carousel-container" >
<IgrCarousel >
<IgrCarouselSlide >
<div className ="image-container" >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/ignite-ui-angular-indigo-design.png" />
</div >
</IgrCarouselSlide >
<IgrCarouselSlide >
<div className ="image-container" >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/slider-image-chart.png" />
</div >
</IgrCarouselSlide >
<IgrCarouselSlide >
<div className ="image-container" >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/ignite-ui-angular-charts.png" />
</div >
</IgrCarouselSlide >
</IgrCarousel >
</div >
);
}
const root = ReactDOM.createRoot (document.getElementById("root" ));
root.render (<CarouselOverview /> );
tsx コピー .carousel-container {
padding : 16px ;
}
.image-container {
display : flex;
align-items : center;
justify-content : center;
}
img {
object-fit : fill;
max-width : 90% ;
}
igc-carousel {
margin -inline: auto;
max-width : 75% ;
height : 450px ;
}
igc-carousel-slide::part (base) {
display : flex;
justify-content : center;
align-items : center;
max-width : 75% ;
margin -inline: auto;
}
css コピー
이 샘플이 마음에 드시나요? Ignite UI for React 전체에 액세스하고 몇 분 만에 나만의 앱을 빌드하기 시작하세요. 무료로 다운로드하세요.
용법
먼저, 다음 명령을 실행하여 Ignite UI for React 설치해야 합니다.
npm install igniteui-react
cmd
그런 다음 필요한 CSS를 IgrCarousel
가져오고 다음과 같이 모듈을 등록해야 합니다.
import { IgrCarousel, IgrCarouselSlide } from 'igniteui-react' ;
import 'igniteui-webcomponents/themes/light/bootstrap.css' ;
tsx
Ignite UI for React에 대한 전체 소개를 보려면 시작하기 항목을 읽어보세요.
이제 Ignite UI for React Carousel을 가져왔으므로 및 해당 슬라이드의 IgrCarousel
기본 구성부터 시작할 수 있습니다.
선택기를 IgrCarousel
사용하여 슬라이드를 래핑합니다. 슬라이드에는 다른 구성 요소를 포함하여 유효한 html 콘텐츠가 포함될 수 있습니다.
<IgrCarousel >
<IgrCarouselSlide >
<img src ="assets/images/carousel/ignite-ui-angular-indigo-design.png" />
</IgrCarouselSlide >
<IgrCarouselSlide >
<img src ="assets/images/carousel/slider-image-chart.png" />
</IgrCarouselSlide >
<IgrCarouselSlide >
<img src ="assets/images/carousel/ignite-ui-angular-charts.png" />
</IgrCarouselSlide >
</IgrCarousel >
tsx
슬라이드가 기본적으로 활성화되도록 하려면 다음 속성을 사용합니다 Active
.
<IgrCarousel >
...
<IgrCarouselSlide >
...
</IgrCarouselSlide >
<IgrCarouselSlide active ={true} >
...
</IgrCarouselSlide >
</IgrCarousel >
tsx
활성 슬라이드가 설정되지 않은 경우 기본적으로 첫 번째 슬라이드가 설정됩니다. 초기 렌더링 또는 후속 업데이트에 활성 슬라이드가 여러 개 있는 경우 마지막 슬라이드만 고려됩니다.
예
캐러셀 구성
기본적으로 의 IgrCarousel
disableLoop
속성은 false 로 설정되어 있습니다(다음 작업을 사용하여 탐색하여 첫 번째 슬라이드가 마지막 슬라이드 뒤에 오거나 이전 작업을 사용하여 첫 번째 슬라이드 뒤에 올 때 반복이 발생합니다 ). 루핑 동작은 속성 값을 disableLoop
true 로 설정하여 비활성화할 수 있습니다.
<IgrCarousel disableLoop ={true} >
...
</IgrCarousel >
tsx
각 슬라이드 인덱스를 추적하기 위해 캐러셀에는 기본적으로 캐러셀에 배치 end
되는 표시기가 있습니다. 이 동작을 변경하려면 속성을 사용하여 indicatorsOrientation
할당합니다 start
.
<IgrCarousel indicatorsOrientation ={CarouselIndicatorsOrientation.Start} >
...
</IgrCarousel >
tsx
기본적으로 탐색 IgrCarousel
버튼과 표시기가 표시됩니다. hideIndicators
이 속성을 사용하여 표시기를 숨기고 hideNavigation
속성을 사용하여 탐색 단추를 숨깁니다.
<IgrCarousel hideNavigation ={true} hideIndicators ={true} >
...
</IgrCarousel >
tsx
IgrCarousel
수직 모드를 지원합니다. vertical
속성을 사용하여 사용하도록 설정합니다.
<IgrCarousel vertical ={true} >
...
</IgrCarousel >
tsx
맞춤 지표
To add React custom carousel indicators, use the IgrCarouselIndicator
:
<IgrCarousel >
<IgrCarouselIndicator >
<span key ="empty" > 🤍</span >
<span slot ="active" >
❤️
</span >
</IgrCarouselIndicator >
<IgrCarouselIndicator >
<span key ="empty" > 🤍</span >
<span slot ="active" >
❤️
</span >
</IgrCarouselIndicator
<IgrCarouselSlide >
<img
src ="https://ko.infragistics.com/angular-demos-lob/assets/images/carousel/ignite-ui-angular-indigo-design.png"
/>
</IgrCarouselSlide >
<IgrCarouselSlide key ="second" >
<img src ="https://ko.infragistics.com/angular-demos-lob/assets/images/carousel/slider-image-chart.png" />
</IgrCarouselSlide >
</IgrCarousel >
tsx
Ignite UI for React Carousel 구성 요소를 사용하면 단일 지표의 활성 및 비활성 상태에 대해 서로 다른 요소를 사용할 수 있습니다. 인디케이터를 선언할 때 각 슬롯에 대해 두 개의 요소(empty 및 active)를 제공해야 하며, 이는 동일하더라도 마찬가지입니다.
이를 위해 및 next-button
슬롯을 previous-button
사용합니다.
<IgrCarousel >
<IgrIcon slot ="previous-button" name ="previous" collection ="material" > </IgrIcon >
<IgrIcon slot ="next-button" name ="next" collection ="material" > </IgrIcon >
...
</IgrCarousel >
tsx
다른 구성 요소가 포함된 슬라이드
이 캐러셀에는 양식과 이미지가 포함된 슬라이드가 포함됩니다.
<IgrCarousel >
<IgrCarouselSlide >
<div >
<img src ="assets/images/svg/carousel/SignUp.svg" />
<form >
<IgrInput type ="text" placeholder ="Username" >
<IgrIcon slot ="prefix" name ="person" > </IgrIcon >
</IgrInput >
<IgrInput type ="password" placeholder ="Password" >
<IgrIcon slot ="prefix" name ="password" > </IgrIcon >
</IgrInput >
<IgrButton type ="reset" >
<span > Sign In</span >
</IgrButton >
</form >
</div >
</IgrCarouselSlide >
<IgrCarouselSlide >
<div >
<img src ="assets/images/svg/carousel/Route.svg" />
<form >
<IgrInput type ="text" placeholder ="Search" >
<IgrIcon slot ="prefix" name ="search" > </IgrIcon >
</IgrInput >
<IgrButton type ="reset" >
<span > Search</span >
</IgrButton >
</form >
</div >
</IgrCarouselSlide >
</IgrCarousel >
tsx
데모
EXAMPLE
TSX
CarouselComponents.css
index.css
import React , { useEffect } from "react" ;
import ReactDOM from "react-dom/client" ;
import {
IgrButton,
IgrCarousel,
IgrCarouselSlide,
IgrIcon,
IgrInput,
registerIconFromText,
} from "@infragistics/igniteui-react" ;
import "igniteui-webcomponents/themes/light/bootstrap.css" ;
import "./CarouselComponents.css" ;
import "./index.css" ;
const icons = [
{
name: "person" ,
iconText:
'<svg width="24" height="24" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><path d="M16 15.503A5.041 5.041 0 1 0 16 5.42a5.041 5.041 0 0 0 0 10.083zm0 2.215c-6.703 0-11 3.699-11 5.5v3.363h22v-3.363c0-2.178-4.068-5.5-11-5.5z"/></svg>' ,
},
{
name: "password" ,
iconText:
'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.25 10.0546V8C5.25 4.27208 8.27208 1.25 12 1.25C15.7279 1.25 18.75 4.27208 18.75 8V10.0546C19.8648 10.1379 20.5907 10.348 21.1213 10.8787C22 11.7574 22 13.1716 22 16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H8C5.17157 22 3.75736 22 2.87868 21.1213C2 20.2426 2 18.8284 2 16C2 13.1716 2 11.7574 2.87868 10.8787C3.40931 10.348 4.13525 10.1379 5.25 10.0546ZM6.75 8C6.75 5.10051 9.10051 2.75 12 2.75C14.8995 2.75 17.25 5.10051 17.25 8V10.0036C16.867 10 16.4515 10 16 10H8C7.54849 10 7.13301 10 6.75 10.0036V8ZM14 16C14 17.1046 13.1046 18 12 18C10.8954 18 10 17.1046 10 16C10 14.8954 10.8954 14 12 14C13.1046 14 14 14.8954 14 16Z"/></svg>' ,
},
{
name: "search" ,
iconText:
'<svg width="24" height="24" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" /></svg>' ,
},
];
export default function CarouselComponents() {
useEffect(() => {
icons.forEach((icon) => {
registerIconFromText(icon.name, icon.iconText);
});
}, []);
return (
<div className ="carousel-container" >
<IgrCarousel >
<IgrCarouselSlide >
<div >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/svg/carousel/SignUp.svg" />
<form >
<IgrInput type ="text" placeholder ="Username" >
<IgrIcon slot ="prefix" name ="person" > </IgrIcon >
</IgrInput >
<IgrInput type ="password" placeholder ="Password" >
<IgrIcon slot ="prefix" name ="password" > </IgrIcon >
</IgrInput >
<IgrButton type ="reset" >
<span > Sign In</span >
</IgrButton >
</form >
</div >
</IgrCarouselSlide >
<IgrCarouselSlide >
<div >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/svg/carousel/Route.svg" />
<form >
<IgrInput type ="text" placeholder ="Search" >
<IgrIcon slot ="prefix" name ="search" > </IgrIcon >
</IgrInput >
<IgrButton type ="reset" >
<span > Search</span >
</IgrButton >
</form >
</div >
</IgrCarouselSlide >
</IgrCarousel >
</div >
);
}
const root = ReactDOM.createRoot (document.getElementById("root" ));
root.render (<CarouselComponents /> );
tsx コピー .carousel-container {
padding : 16px ;
}
igc-carousel {
margin -inline: auto;
max-width : 75% ;
height : 500px ;
}
igc-carousel-slide {
display : flex;
justify-content : center;
align-items : center;
}
igc-carousel-slide div {
text-align : center;
max-width : 40% ;
margin -inline: auto;
}
igc-carousel-slide div * {
margin -block: 8px ;
}
css コピー
애니메이션
애니메이션 슬라이드 전환은 최종 사용자에게 회전판과 상호 작용할 때 좋은 경험을 제공합니다.
캐러셀은 기본적으로 애니메이션을 slide
사용하도록 구성되지만 대체 애니메이션으로도 지원됩니다 fade
.
Use the animationType
property to change the animation.
<IgrCarousel animationType ="fade" >
...
</IgrCarousel >
tsx
Setting none
to the animationType
property disables the animations.
데모
아래 데모는 캐러셀이 지원하는 다양한 유형의 애니메이션을 보여줍니다.
EXAMPLE
TSX
CarouselAnimations.css
index.css
import React , { useRef, useState } from "react" ;
import ReactDOM from "react-dom/client" ;
import {
HorizontalTransitionAnimation,
IgrButton,
IgrCard,
IgrCardActions,
IgrCardContent,
IgrCardHeader,
IgrCardMedia,
IgrCarousel,
IgrCarouselSlide,
IgrCheckboxChangeEventArgs,
IgrSelect,
IgrSelectItem,
IgrSwitch,
} from "@infragistics/igniteui-react" ;
import "igniteui-webcomponents/themes/light/bootstrap.css" ;
import "./CarouselAnimations.css" ;
import "./index.css" ;
export default function CarouselComponents() {
const [animationType , setAnimationType ] = useState<HorizontalTransitionAnimation > ('slide' );
const [isCarouselVertical , setIsCarouselVertical ] = useState<boolean > (false );
const onSelectChange = (e: CustomEvent<IgrSelectItem > ) => {
const value = e.detail.value as HorizontalTransitionAnimation;
setAnimationType(value);
}
const onSwitchChange = (e: IgrCheckboxChangeEventArgs) => {
setIsCarouselVertical(e.detail.checked);
}
return (
<div className ="carousel-wrapper" >
<div className ="action-wrapper" >
<div className ="action" >
<span > Animation type</span >
<IgrSelect onChange ={onSelectChange} >
<IgrSelectItem value ="slide" selected ={true} >
<span > Slide</span >
</IgrSelectItem >
<IgrSelectItem value ="fade" >
<span > Fade</span >
</IgrSelectItem >
<IgrSelectItem value ="none" >
<span > None</span >
</IgrSelectItem >
</IgrSelect >
</div >
<div className ="action" >
<IgrSwitch
onChange ={onSwitchChange}
labelPosition ="before"
>
<span > Vertical alignment</span >
</IgrSwitch >
</div >
</div >
<IgrCarousel
hideIndicators ={true}
animationType ={animationType}
vertical ={isCarouselVertical} >
<IgrCarouselSlide >
<div className ="slide-wrapper" >
<IgrCard >
<IgrCardHeader >
<h3 slot ="title" >
Ignite UI for Angular
</h3 >
</IgrCardHeader >
<IgrCardContent >
<p >
30 + Material-based Angular components to code speedy web apps
faster.
</p >
</IgrCardContent >
<IgrCardMedia >
<img
src ="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/slide1-angular.png"
/>
</IgrCardMedia >
<IgrCardActions >
<IgrButton
slot ="start"
href ="https://www.infragistics.com/products/ignite-ui-angular"
target ="_blank"
rel ="noopener"
>
<span > Visit Page</span >
</IgrButton >
</IgrCardActions >
</IgrCard >
</div >
</IgrCarouselSlide >
<IgrCarouselSlide >
<div className ="slide-wrapper" >
<IgrCard >
<IgrCardHeader >
<h3 slot ="title" >
Ignite UI for Javascript
</h3 >
</IgrCardHeader >
<IgrCardContent >
<p >
A complete JavaScript UI library empowering you to build
data-rich responsive web apps.
</p >
</IgrCardContent >
<IgrCardMedia >
<img
src ="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/slide2-ignite.png"
/>
</IgrCardMedia >
<IgrCardActions >
<IgrButton
slot ="start"
href ="https://www.infragistics.com/products/ignite-ui"
target ="_blank"
rel ="noopener"
>
<span > Visit Page</span >
</IgrButton >
</IgrCardActions >
</IgrCard >
</div >
</IgrCarouselSlide >
<IgrCarouselSlide >
<div className ="slide-wrapper" >
<IgrCard >
<IgrCardHeader >
<h3 slot ="title" >
Ultimate UI for ASP.NET
</h3 >
</IgrCardHeader >
<IgrCardContent >
<p >
Build full-featured business apps with the most versatile set
of ASP.NET AJAX UI controls.
</p >
</IgrCardContent >
<IgrCardMedia >
<img
src ="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/slide3-aspnet.png"
/>
</IgrCardMedia >
<IgrCardActions >
<IgrButton
slot ="start"
href ="https://www.infragistics.com/products/aspnet"
target ="_blank"
rel ="noopener"
>
<span > Visit Page</span >
</IgrButton >
</IgrCardActions >
</IgrCard >
</div >
</IgrCarouselSlide >
</IgrCarousel >
</div >
);
}
const root = ReactDOM.createRoot (document.getElementById("root" ));
root.render (<CarouselComponents /> );
tsx コピー .carousel-wrapper {
height : 600px ;
width : 90% ;
margin : 20px auto;
display : flex;
flex-direction : column;
justify-content : space-between;
}
.action-wrapper {
height : 40px ;
width : 500px ;
display : flex;
justify-content : space-between;
margin-bottom : 10px ;
}
.action {
display : flex;
align-items : center;
}
.slide-wrapper {
display : flex;
align-items : center;
justify-content : center;
padding : 10px ;
}
igc-carousel {
border : 0.5px solid #dde0e4 ;
}
igc-select {
width : 150px ;
margin-left : 10px ;
--ig-size: var (--ig-size-small);
}
igc-card {
border : none;
}
igc-card-header {
padding : 8px 16px ;
}
css コピー
항해
전환 및 탐색은 캐러셀의 가장 중요한 기능입니다.
캐러셀의 탐색은 사용자가 모바일 장치에서 탐색 버튼, 표시기, 키보드 탐색 및 터치 조작을 통해 처리할 수 있습니다.
터치 제스처
기본적으로 캐러셀은 모든 터치 지원 장치에서 사용할 수 있습니다.
캐러셀 애니메이션은 터치 장치에서 완벽하게 지원되므로 캐러셀은 모든 플랫폼과 일관되고 프로그레시브 웹 애플리케이션(PWA )에서 사용될 때 훌륭합니다.
키보드 탐색
탐색 버튼
Space
/ Enter
key - 다음/이전 슬라이드로 이동합니다.
지표
Arrow Left
키 - 이전(오른쪽에서 왼쪽 모드에서 다음) 슬라이드로 이동합니다.
Arrow Right
키 - 다음(오른쪽에서 왼쪽 모드의 이전) 슬라이드로 이동합니다.
Home
키 - 첫 번째(오른쪽에서 왼쪽 모드의 마지막) 슬라이드로 이동합니다.
End
키 - 마지막(오른쪽에서 왼쪽 모드의 첫 번째) 슬라이드로 이동합니다.
자동 전환
IgrCarousel
사용자 상호 작용 없이 슬라이드를 자동으로 변경하도록 쉽게 구성할 수 있습니다. 이렇게 하면 속성에 대한 interval
전환 간격만 설정하여 자신만의 슬라이드 쇼를 만들 수 있으며, 이 간격은 슬라이드 전환 사이의 시간(밀리초)을 결정합니다.
캐러셀 콘텐츠 위에 마우스를 올려 놓거나 키보드 포커스를 캐러셀 콘텐츠로 이동하면 자동 전환이 일시 중지됩니다. 마우스가 캐러셀에서 멀어지거나 키보드 초점이 캐러셀 콘텐츠 밖으로 이동하면 자동 전환이 다시 시작됩니다. disablePauseOnInteraction 속성을 true로 설정하여 이를 방지할 수 있습니다.
<IgrCarousel interval ={2000} disablePauseOnInteraction ={true} >
...
</IgrCarousel >
tsx
고급 예
루핑이 활성화된 완전 자동화된 캐러셀을 만들어 보겠습니다. 표시기를 각 슬라이드의 썸네일 표현으로 구성합니다.
이 목표를 달성하려면 캐러셀에 대해 다음 구성을 수행해야 합니다.
캐러셀은 템플릿에서 다음과 같이 표시됩니다.
const images = [
{
src: "assets/images/carousel/WonderfulCoast.png" ,
alt: "Wonderful Coast" ,
},
{
src: "assets/images/carousel/CulturalDip.png" ,
alt: "Cultural Dip" ,
},
{
src: "assets/images/carousel/GoldenBeaches.png" ,
alt: "Golden Beaches" ,
},
{
src: "assets/images/carousel/IslandOfHistory.png" ,
alt: "Island Of History" ,
},
{
src: "assets/images/carousel/AmazingBridge.png" ,
alt: "Amazing Bridge" ,
},
];
<IgrCarousel
disablePauseOnInteraction ={true}
hideNavigation ={true}
interval ={2000}
vertical ={true}
animationType ="fade"
>
{images.map((image, index) => {
return (
<React.Fragment key ={index} >
<IgrCarouselSlide >
<img src ={image.src} alt ={image.alt} />
</IgrCarouselSlide >
<IgrCarouselIndicator >
<img
className ="blurred"
src ={image.src.replace( ".png ", "Thumb.png ")}
alt ={ `${image.alt } Thumb `}
width ="50"
height ="60"
/>
<img
slot ="active"
src ={image.src.replace( ".png ", "Thumb.png ")}
alt ={ `${image.alt } Thumb Active `}
width ="50"
height ="60"
/>
</IgrCarouselIndicator >
</React.Fragment >
);
})}
</IgrCarousel >
tsx
이러한 구성의 결과는 다음과 같습니다.
EXAMPLE
TSX
CarouselThumbnail.css
index.css
import React from "react" ;
import ReactDOM from "react-dom/client" ;
import {
IgrCarousel,
IgrCarouselIndicator,
IgrCarouselSlide,
} from "@infragistics/igniteui-react" ;
import "igniteui-webcomponents/themes/light/bootstrap.css" ;
import "./CarouselThumbnail.css" ;
import "./index.css" ;
export default function CarouselThumbnail() {
const images = [
{
src: "https://www.infragistics.com/angular-demos-lob/assets/images/carousel/WonderfulCoast.png" ,
alt: "Wonderful Coast" ,
},
{
src: "https://www.infragistics.com/angular-demos-lob/assets/images/carousel/CulturalDip.png" ,
alt: "Cultural Dip" ,
},
{
src: "https://www.infragistics.com/angular-demos-lob/assets/images/carousel/GoldenBeaches.png" ,
alt: "Golden Beaches" ,
},
{
src: "https://www.infragistics.com/angular-demos-lob/assets/images/carousel/IslandOfHistory.png" ,
alt: "Island Of History" ,
},
{
src: "https://www.infragistics.com/angular-demos-lob/assets/images/carousel/AmazingBridge.png" ,
alt: "Amazing Bridge" ,
},
];
return (
<div className ="container sample" >
<IgrCarousel
disablePauseOnInteraction ={true}
hideNavigation ={true}
interval ={2000}
vertical ={true}
animationType ="fade"
>
{images.map((image, index) => {
return (
<React.Fragment key ={index} >
<IgrCarouselSlide >
<img src ={image.src} alt ={image.alt} />
</IgrCarouselSlide >
<IgrCarouselIndicator >
<img
className ="blurred"
src ={image.src.replace( ".png ", "Thumb.png ")}
alt ={ `${image.alt } Thumb `}
width ="50"
height ="60"
/>
<img
slot ="active"
src ={image.src.replace( ".png ", "Thumb.png ")}
alt ={ `${image.alt } Thumb Active `}
width ="50"
height ="60"
/>
</IgrCarouselIndicator >
</React.Fragment >
);
})}
</IgrCarousel >
</div >
);
}
const root = ReactDOM.createRoot (document.getElementById("root" ));
root.render (<CarouselThumbnail /> );
tsx コピー igc-carousel {
margin -inline: auto;
max-width : 75% ;
}
igc-carousel::part (indicators) {
border-radius : 2px ;
}
.blurred {
filter : blur (2px );
opacity : 0.5 ;
}
css コピー
접근성
WAI-ARIA 역할, 상태 및 속성
Carousel 기본 요소 역할은 특정 목적과 관련된 콘텐츠가 포함된 섹션인 region
이며 사용자는 쉽게 탐색할 수 있기를 원할 것입니다.
캐러셀 표시기에는 역할 tab
있습니다. 사용자에게 렌더링할 탭 콘텐츠를 선택하기 위한 메커니즘을 제공하는 그룹화 레이블입니다.
탭 집합(캐러셀 표시기)의 컨테이너 역할을 하는 요소는 역할 tablist
이 있습니다.
각 슬라이드 요소는 tabpanel
역할로 설정됩니다.
ARIA 지원
캐러셀 구성 요소
Attributes
aria-roledescription 을 "carousel"로 설정합니다.
aria-live - 스크린 리더가 라이브 영역에 대한 업데이트를 처리해야 하는 우선 순위를 설정하는 데 사용되며, 가능한 설정은 다음과 같습니다.off 및 polite . 기본 설정은 polite 이며 슬라이드 집합의 컨테이너 역할을 하는 요소로 설정됩니다. interval
옵션이 설정되고 캐러셀이 재생 중인 상태이면 aria-live 속성이 off 로 설정됩니다.
aria-label (navigation buttons) - "Previous slide"/"Next slide".
Slide component
Indicator component
API 참조
추가 리소스