dynamic-island
cult-ui/dynamic-islandUnverifiedComponent
iOS-style dynamic island component with expandable content and smooth animations
Install it
npx shadcn@latest add https://raw.githubusercontent.com/nolly-studio/cult-ui/HEAD/apps/www/dynamic-island.jsonSource
1"use client"23import React, {4 createContext,5 ReactNode,6 useCallback,7 useContext,8 useEffect,9 useReducer,10 useRef,11 useState,12} from "react"13import { AnimatePresence, motion, useWillChange } from "motion/react"1415const stiffness = 40016const damping = 3017const MIN_WIDTH = 69118const MAX_HEIGHT_MOBILE_ULTRA = 40019const MAX_HEIGHT_MOBILE_MASSIVE = 7002021const min = (a: number, b: number) => (a < b ? a : b)2223export type SizePresets =24 | "reset"25 | "empty"26 | "default"27 | "compact"28 | "compactLong"29 | "large"30 | "long"31 | "minimalLeading"32 | "minimalTrailing"33 | "compactMedium"34 | "medium"35 | "tall"36 | "ultra"37 | "massive"3839const SIZE_PRESETS = {40 RESET: "reset",41 EMPTY: "empty",42 DEFAULT: "default",43 COMPACT: "compact",44 COMPACT_LONG: "compactLong",45 LARGE: "large",46 LONG: "long",47 MINIMAL_LEADING: "minimalLeading",48 MINIMAL_TRAILING: "minimalTrailing",49 COMPACT_MEDIUM: "compactMedium",50 MEDIUM: "medium",51 TALL: "tall",52 ULTRA: "ultra",53 MASSIVE: "massive",54} as const5556type Preset = {57 width: number58 height?: number59 aspectRatio: number60 borderRadius: number61}6263const DynamicIslandSizePresets: Record<SizePresets, Preset> = {64 [SIZE_PRESETS.RESET]: {65 width: 150,66 aspectRatio: 1,67 borderRadius: 20,68 },69 [SIZE_PRESETS.EMPTY]: {70 width: 0,71 aspectRatio: 0,72 borderRadius: 0,73 },74 [SIZE_PRESETS.DEFAULT]: {75 width: 150,76 aspectRatio: 44 / 150,77 borderRadius: 46,78 },79 [SIZE_PRESETS.MINIMAL_LEADING]: {80 width: 52.33,81 aspectRatio: 44 / 52.33,82 borderRadius: 22,83 },84 [SIZE_PRESETS.MINIMAL_TRAILING]: {85 width: 52.33,86 aspectRatio: 44 / 52.33,87 borderRadius: 22,88 },89 [SIZE_PRESETS.COMPACT]: {90 width: 235,91 aspectRatio: 44 / 235,92 borderRadius: 46,93 },94 [SIZE_PRESETS.COMPACT_LONG]: {95 width: 300,96 aspectRatio: 44 / 235,97 borderRadius: 46,98 },99 [SIZE_PRESETS.COMPACT_MEDIUM]: {100 width: 351,101 aspectRatio: 64 / 371,102 borderRadius: 44,103 },104 [SIZE_PRESETS.LONG]: {105 width: 371,106 aspectRatio: 84 / 371,107 borderRadius: 42,108 },109 [SIZE_PRESETS.MEDIUM]: {110 width: 371,111 aspectRatio: 210 / 371,112 borderRadius: 22,113 },114 [SIZE_PRESETS.LARGE]: {115 width: 371,116 aspectRatio: 84 / 371,117 borderRadius: 42,118 },119 [SIZE_PRESETS.TALL]: {120 width: 371,121 aspectRatio: 210 / 371,122 borderRadius: 42,123 },124 [SIZE_PRESETS.ULTRA]: {125 width: 630,126 aspectRatio: 630 / 800,127 borderRadius: 42,128 },129 [SIZE_PRESETS.MASSIVE]: {130// … truncated
What it pulls in
npm packages
Files it writes
More from cult/ui
All 157 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-instructionsai-instructions | cult/ui | Components | Unverified | 2 deps | |
| ai-instructions-demoai-instructions-demo | cult/ui | Components | Unverified | no deps | |
| animated-numberanimated-number | cult/ui | Components | Unverified | 1 dep | |
| animated-number-demoanimated-number-demo | cult/ui | Components | Unverified | no deps | |
| bg-animate-buttonbg-animate-button | cult/ui | Components | Unverified | no deps | |
| bg-animate-button-demobg-animate-button-demo | cult/ui | Components | Unverified | no deps | |
| bg-animated-fractal-dot-gridbg-animated-fractal-dot-grid | cult/ui | Components | Unverified | 1 dep | |
| bg-animated-fractal-dot-grid-demobg-animated-fractal-dot-grid-demo | cult/ui | Components | Unverified | no deps |
