معرض متحرّك

Carousel

عرض شرائح متاح الوصول في React بأسهم ونقاط ولوحة مفاتيح وسحب وتكرار، بنمط دور carousel وإعلانات حيّة. تنقّل يراعي الاتجاه العربي.

يعرض Carousel شريحة واحدة في كل مرة داخل CarouselViewport. يعمل التنقل بالأسهم والنقاط ولوحة المفاتيح والسحب، وأضف loop للدوران المستمر.

متى تستخدمه

استخدم Carousel لمجموعة صغيرة من الشرائح المتساوية الأهمّية، مثل الخدمات المميّزة أو الإعلانات في صفحة البوّابة الرئيسية. اجعلها شرائح قليلة ولا تشغّل تلقائيًا محتوى يحتاج المستخدم إلى قراءته.

إن كان على المستخدم مقارنة العناصر، فالشبكة أفضل من عرض الشرائح.

أمثلة

نقاط

أسهم

أسهم ونقاط وتكرار

الخصائص

الخصائص التي يعرّفها Carousel. سمات العنصر الأصلي تمرّ كما هي.

<Carousel>

الخاصيةالنوعالافتراضيالوصف
indexnumberControlled active index (a slide, or a page when slideSize is set).
defaultIndexnumberUncontrolled initial index. Defaults to 0.
onIndexChange(index: number) => voidFires with the new index on any navigation.
controls"both" | "dots" | "arrows"Which controls to lay out: dots below, arrows flanking, or both.
loopbooleanWrap past the ends instead of stopping.
dotSizeDotSizeDot indicator diameter: sm 8 · md 12 · lg 16 px.
arrowStyleArrowStyleArrow button style: filled green primary, transparent subtle, or the square gray neutral (SDGA Button Neutral).
arrowSizeArrowSizeArrow button diameter: sm 32 · md 40 · lg 48 px.
swipebooleanEnable pointer/touch swipe to navigate. Defaults to true.
autoplaybooleanAuto-advance (house extension; pauses on hover/focus + reduced-motion).
autoplayIntervalnumberAuto-advance interval in ms. Defaults to 5000.
slideSizestringFixed inline size of every slide (any CSS length). Switches to page-based navigation: the viewport shows as many whole slides as fit, and arrows/dots move one page at a time. Without it, each slide fills the viewport.
gapstringSpace between slides (any CSS length). Defaults to 0.
align"center" | "start"Where the active page sits when slides don't fill the viewport; center lets the neighbours peek at both edges.
flushbooleanDrop the SDGA shell padding (inline 24 / block 32) so the carousel sits flush in its container.
arrowGapstringSpace between the arrows and the viewport (flank, SDGA 44px) or their inset from its edges (overlay, 0).
arrowPlacement"overlay" | "flank"flank (default) lays the arrows out beside the viewport; overlay floats them over its edges.
announce(index: number, count: number) => stringBuilds the screen-reader announcement after navigation (a visually hidden status). Defaults to Slide {n} of {m}.

<CarouselSlide>

الخاصيةالنوعالافتراضيالوصف
indexnumber0-based position - injected by CarouselViewport.

<CarouselNav>

الخاصيةالنوعالافتراضيالوصف
labelstringAccessible label for the icon-only button.
asChildbooleanCompose with a custom element (e.g. a router link) via Radix Slot.
childrenreact.ReactNodeOverride the default chevron glyph.

<CarouselDots>

الخاصيةالنوعالافتراضيالوصف
barebooleanDrop the pill padding (SDGA "Dots Only").
dotLabel(index: number, count: number) => stringBuild each dot's accessible label. Defaults to Go to slide {n}.

إمكانية الوصول

يعرض عرض الشرائح role="region" مع aria-roledescription="carousel"، وكل شريحة role="group" بوصف شريحة. ينقل السهمان الأيسر والأيمن بين الشرائح، ويقفز Home وEnd إلى الطرفين، وتُعلّم الشرائح غير النشطة بـ inert فلا يمكن التركيز على محتوى مخفي.

تُعلن تغييرات الشرائح بهدوء، ولزرَي السابق والتالي أسماء متاحة، وتحمل النقطة الحالية aria-current.