Slide-CN

Deck

The main component to create a slide deck

Overview

This is the root component of your presentation. It controls which slide is shown.

The Deck component handles everything from Keyboard navigations and swipe guestures, to animations and more.

The children of this component are the different slides of the presentation.

Installation

pnpm dlx shadcn@latest add https://slide-cn.com/r/deck.json
npx shadcn@latest add https://slide-cn.com/r/deck.json
yarn dlx shadcn@latest add https://slide-cn.com/r/deck.json
bunx --bun shadcn@latest add https://slide-cn.com/r/deck.json

Demo

A mini deck with keyboard navigation (use arrow keys or swipe)

Slide 1

Use arrow keys to navigate →

Usage

<Deck>
	<Slide key={0}>
		<FirstSlide />
	</Slide>
	<Slide key={1}>
		<SecondSlide />
	</Slide>
</Deck>

Reference

useDeck()

This hook allows you to control the slide navigation. For most use cases it is already taken care of, but if you want a fine grained way of going to the next/previous slide, or jumping to any slide, then you can use this hook.

You can use this as follows:

const deck = useDeck();

function handleContactInfoClick() {
	deck.goTo(CONTACT_INFO_SLIDE);
}

For more info checkout the useDeck hook

Built by Prithvi. Code is available on GitHub

On this page