From 463dc35064237873ec87ac6232389c2685ec8013 Mon Sep 17 00:00:00 2001 From: ifeichuan Date: Mon, 8 Jun 2026 22:14:21 +0800 Subject: [PATCH] fix(Carousel): make slide indicators keyboard accessible The slide indicators were rendered as `` with only an `onClick` handler, so keyboard-only users could neither focus them with Tab nor activate them with Enter/Space (issue #976). Switch the indicators to ``, which is natively focusable and activatable via Enter/Space, and add: - `aria-label="Go to slide N"` so screen readers announce each control - `aria-current` to expose which slide is active - button resets (border/padding/appearance) to preserve the dot styling - a `:focus-visible` outline so keyboard focus is visible Updated across all 4 variants (JS/TS x CSS/Tailwind). --- src/content/Components/Carousel/Carousel.css | 8 ++++++++ src/content/Components/Carousel/Carousel.jsx | 5 ++++- src/tailwind/Components/Carousel/Carousel.jsx | 7 +++++-- src/ts-default/Components/Carousel/Carousel.css | 8 ++++++++ src/ts-default/Components/Carousel/Carousel.tsx | 5 ++++- src/ts-tailwind/Components/Carousel/Carousel.tsx | 7 +++++-- 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/content/Components/Carousel/Carousel.css b/src/content/Components/Carousel/Carousel.css index 4a9e443fd..9aab9f289 100644 --- a/src/content/Components/Carousel/Carousel.css +++ b/src/content/Components/Carousel/Carousel.css @@ -121,11 +121,19 @@ .carousel-indicator { height: 8px; width: 8px; + border: none; + padding: 0; + appearance: none; border-radius: 50%; cursor: pointer; transition: background-color 150ms; } +.carousel-indicator:focus-visible { + outline: 2px solid #fff; + outline-offset: 2px; +} + .carousel-indicator.active { background-color: #fff; } diff --git a/src/content/Components/Carousel/Carousel.jsx b/src/content/Components/Carousel/Carousel.jsx index 5ca67412a..57b45485d 100644 --- a/src/content/Components/Carousel/Carousel.jsx +++ b/src/content/Components/Carousel/Carousel.jsx @@ -245,9 +245,12 @@ export default function Carousel({
{items.map((_, index) => ( -
{items.map((_, index) => ( -
{items.map((_, index) => ( -
{items.map((_, index) => ( -