Skip to content

Latest commit

 

History

History
150 lines (100 loc) · 3.8 KB

File metadata and controls

150 lines (100 loc) · 3.8 KB

import { InstallScript } from './components/InstallScript/InstallScript'; import * as demos from './demos';

Installation

After installation import package styles at the root of your application:

import '@gfazioli/mantine-depth-select/styles.css';

You can import styles within a layer @layer mantine-depth-select by importing @gfazioli/mantine-depth-select/styles.layer.css file.

import '@gfazioli/mantine-depth-select/styles.layer.css';

Usage

A 3D stack select component inspired by macOS Time Machine. Navigate through stacked cards with perspective transforms and smooth transitions. Use keyboard arrows, click the second card, mouse wheel, touch swipe, or use the built-in controls to navigate.

The controlsPosition prop controls where the navigation arrows are placed: right (default) or left. Set withControls={false} to hide the built-in controls and use your own.

You must set w and h props to define the area where cards live. Cards should use h="100%" to fill the available height.

Controlled

Use value and onChange for controlled mode. Navigation also works via keyboard (ArrowUp/Down, Home/End), mouse wheel, and touch swipe:

Scroll navigation

By default, you can navigate the stack using the mouse wheel or trackpad gestures. The page scroll is automatically blocked while interacting with the component. Set withScrollNavigation={false} to disable this behavior.

Loop

Set loop to enable infinite navigation. When you reach the last item, the next navigation wraps back to the first item and vice versa:

Controls alignment

Use controlsProps to customize the built-in controls. The justify prop aligns them vertically: start (top), center (default), or end (bottom). You can also set w for a fixed width to prevent layout shifts when labels change:

Custom controls

Set withControls={false} to hide the built-in navigation and use your own controls. Use value and onChange to manage navigation externally:

Controls as children

You can also use DepthSelect.Controls as a child component with withControls={false}. This gives you access to props like labelFormatter directly on the controls:

Rich cards

You can use any React content inside items. Here is an example with decorated cards featuring images, badges and buttons:

Use cases

Pricing plan selector

The depth stack creates a natural visual hierarchy, making the front card feel "recommended." Navigate between plans to compare features:

Document version history

Browse through document versions with author info and change summaries. The depth effect naturally communicates "older = further back":

Onboarding wizard

A step-by-step onboarding flow where completed steps move behind the current one. More engaging than a traditional linear stepper:

Emoji stack

Items don't need to be cards — any React content works. This example uses emoji with varying widths to test how different-sized content behaves:

Image gallery

Browse through a collection of images with the depth stack. Enable loop for infinite scrolling. Each card uses Mantine's Image component with fit="cover":

Styles API

DepthSelect supports Styles API, you can add styles to any inner element of the component with classNames prop.