0.24.4 • Published 8 months ago
@k8slens/lds-carousel
Licence
MIT
Version
0.24.4
Deps
3
Size
56 kB
Vulns
0
Weekly
0
@k8slens/lds-carousel
Carousel component for the Lens Design System – auto-playing slide carousel with dot navigation.
Installation
npm install @k8slens/lds-carousel @k8slens/lds-tokens
Setup
import "@k8slens/lds-tokens/lib/electron/font-face.css";
import "@k8slens/lds/lib/es/index.css";
import "@k8slens/lds-carousel/lib/es/index.css";
Usage
import Carousel from "@k8slens/lds-carousel";
export const Component = () => (
<Carousel>
<img src="src" alt="Alt text" />
<img src="src" alt="Alt text" />
<img src="src" alt="Alt text" />
</Carousel>
);
Video Autoplay
To autoplay a video on the first slide:
import { Carousel } from "@k8slens/lds-carousel";
export const Component = () => {
const videoRef = React.useRef<HTMLVideoElement>(null);
const [isVideoPlaying, setIsVideoPlaying] = useState(false);
const [playing, setVideoPlaying] = useState(false);
useEffect(() => {
if (videoRef?.current && playing && !isVideoPlaying) {
videoRef.current.play().catch(console.log);
}
}, [videoRef, playing, isVideoPlaying]);
return (
<Carousel isVideoPlaying={isVideoPlaying} setVideoPlaying={setVideoPlaying}>
<video
key="video-1" // Key must include "video"
ref={videoRef}
autoPlay={playing}
src="video.mp4"
muted // Mute video to avoid autoplay issues
onPlay={() => setIsVideoPlaying(true)}
onPause={() => setIsVideoPlaying(false)}
onEnded={() => setIsVideoPlaying(false)}
/>
<img src="src" alt="Alt text" />
<img src="src" alt="Alt text" />
<img src="src" alt="Alt text" />
</Carousel>
);
};
Documentation
Browse examples at lens-design-system.k8slens.dev.
AI Assistance
This package includes an llms.txt file with API documentation optimized for LLMs. Add to your project's AI configuration (e.g., AGENTS.md or CLAUDE.md):
Read node_modules/@k8slens/lds-carousel/llms.txt for carousel API reference.
Use the LDS Carousel component instead of custom implementations.