BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/diceui/radix/stack

stack

diceui-radix/stack
FreeComponent

diceui/radix publishes no description for this item.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/radix-nova/stack.json

Source

ui/stack.tsxraw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/radix-nova/stack.json · first 6 KB
1"use client";
2
3import { cva } from "class-variance-authority";
4import { Slot as SlotPrimitive } from "radix-ui";
5import * as React from "react";
6import { cn } from "@/lib/utils";
7
8interface ItemDimension {
9 itemId: number;
10 size: number;
11}
12
13type Side = "top" | "bottom";
14
15function getDataState(isExpanded: boolean) {
16 return isExpanded ? "expanded" : "collapsed";
17}
18
19interface StackContextValue {
20 side: Side;
21 childrenCount: number;
22 itemCount: number;
23 expandedItemCount: number;
24 gap: number;
25 scale: number;
26 offset: number;
27 expandOnHover: boolean;
28 isExpanded: boolean;
29 isInteracting: boolean;
30 dimensions: ItemDimension[];
31 setDimensions: React.Dispatch<React.SetStateAction<ItemDimension[]>>;
32}
33
34const StackContext = React.createContext<StackContextValue | null>(null);
35
36function useStackContext(consumerName: string) {
37 const context = React.useContext(StackContext);
38 if (!context) {
39 throw new Error(`\`${consumerName}\` must be used within \`Stack\``);
40 }
41 return context;
42}
43
44interface StackProps extends React.ComponentProps<"div"> {
45 side?: Side;
46 itemCount?: number;
47 expandedItemCount?: number;
48 gap?: number;
49 scale?: number;
50 offset?: number;
51 expandOnHover?: boolean;
52 asChild?: boolean;
53}
54
55function Stack(props: StackProps) {
56 const {
57 side = "bottom",
58 itemCount = 3,
59 expandedItemCount,
60 gap = 8,
61 scale = 0.05,
62 offset = 10,
63 className,
64 children,
65 style,
66 onMouseEnter: onMouseEnterProp,
67 onMouseLeave: onMouseLeaveProp,
68 onMouseMove: onMouseMoveProp,
69 onPointerDown: onPointerDownProp,
70 onPointerUp: onPointerUpProp,
71 expandOnHover = false,
72 asChild,
73 ...rootProps
74 } = props;
75
76 const [isExpanded, setIsExpanded] = React.useState(false);
77 const [isInteracting, setIsInteracting] = React.useState(false);
78 const [dimensions, setDimensions] = React.useState<ItemDimension[]>([]);
79
80 const childrenArray = React.Children.toArray(children).filter(
81 React.isValidElement,
82 );
83 const childrenCount = childrenArray.length;
84
85 const effectiveExpandedItemCount = expandedItemCount ?? childrenCount;
86
87 const onMouseEnter = React.useCallback(
88 (event: React.MouseEvent<HTMLDivElement>) => {
89 onMouseEnterProp?.(event);
90 if (event.defaultPrevented) return;
91
92 if (expandOnHover) {
93 setIsExpanded(true);
94 }
95 },
96 [expandOnHover, onMouseEnterProp],
97 );
98
99 const onMouseMove = React.useCallback(
100 (event: React.MouseEvent<HTMLDivElement>) => {
101// … truncated

What it pulls in

npm packages

  • radix-ui

Files it writes

  • ui/stack.tsx

Facts

Registry
diceui/radix
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-01
Last confirmed
today

Go to the source

www.diceui.com sadmann7/diceui on GitHub Raw registry item This item as JSON

More from diceui/radix

All 58 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
action-baraction-bardiceui/radixComponentsFree1 dep · 2 files
angle-sliderangle-sliderdiceui/radixComponentsFree1 dep · 3 files
avatar-groupavatar-groupdiceui/radixComponentsFree1 dep
badge-overflowbadge-overflowdiceui/radixComponentsFree1 dep · 2 files
bannerbannerdiceui/radixComponentsFree1 dep
checkbox-groupcheckbox-groupdiceui/radixComponentsFree1 dep
circular-progresscircular-progressdiceui/radixComponentsFree1 dep
client-onlyclient-onlydiceui/radixComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex