UI Dropdown Menu
remocn/dropdown-menuFreeComponent
A dropdown menu whose opened/closed state is a pure function of the timeline; the trigger reuses the Button primitive and the reveal panel composes DropdownMenuItem rows. The panel fade, scale, lift, and chevron are keyframed presets.
Install it
npx shadcn@latest add https://www.remocn.dev/r/dropdown-menu.jsonSource
1"use client";23import {4 type ButtonStyle,5 type ButtonStyleContext,6 buttonStyle,7 buttonStyleContext,8} from "@/components/remocn/button";9import {10 DropdownMenuItemRow,11 type DropdownMenuItemStyle,12 type DropdownMenuItemStyleContext,13 dropdownMenuItemStyle,14 dropdownMenuItemStyleContext,15} from "@/components/remocn/dropdown-menu-item";16import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";1718export type DropdownMenuState = "opened" | "closed";1920export interface DropdownMenuStyle {21 panelOpacity: number;22 panelScale: number;23 panelTranslateY: number;24 chevronRotation: number;25}2627export interface DropdownMenuStyleContext {28 triggerCtx: ButtonStyleContext;29 panelBg: string;30 panelBorder: string;31 triggerFg: string;32 mutedFg: string;33 radius: number;34 itemCtx: DropdownMenuItemStyleContext;35}3637export function dropdownMenuStyleContext(38 theme: RemocnTheme,39): DropdownMenuStyleContext {40 return {41 triggerCtx: buttonStyleContext("outline", theme),42 panelBg: theme.popover,43 panelBorder: theme.border,44 triggerFg: theme.foreground,45 mutedFg: theme.mutedForeground,46 radius: theme.radius,47 itemCtx: dropdownMenuItemStyleContext(theme),48 };49}5051export function dropdownMenuStyle(52 state: DropdownMenuState,53 _ctx: DropdownMenuStyleContext,54): DropdownMenuStyle {55 switch (state) {56 case "opened":57 return {58 panelOpacity: 1,59 panelScale: 1,60 panelTranslateY: 0,61 chevronRotation: 180,62 };63 default:64 return {65 panelOpacity: 0,66 panelScale: 0.96,67 panelTranslateY: -4,68 chevronRotation: 0,69 };70 }71}7273const WIDTH = 240;7475export interface DropdownMenuProps {76 state?: DropdownMenuState;77 style?: DropdownMenuStyle;78 label?: string;79 items?: string[];80 highlightedIndex?: number;81 pressedIndex?: number;82 itemStyles?: (DropdownMenuItemStyle | undefined)[];83 triggerStyle?: ButtonStyle;84 theme?: Partial<RemocnTheme>;85 className?: string;86}8788export function DropdownMenu({89 state = "closed",90 style,91 label = "Options",92 items = ["Profile", "Billing", "Settings", "Log out"],93 highlightedIndex = -1,94 pressedIndex = -1,95 itemStyles,96 triggerStyle,97 theme: themeOverride,98 className,99}: DropdownMenuProps) {100 const theme = useRemocnTheme(themeOverride, "light");101102 const ctx = dropdownMenuStyleContext(theme);103 const v = style ?? dropdownMenuStyle(state, ctx);104105 const trigger = triggerStyle ?? buttonStyle("idle", ctx.triggerCtx);106107// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from remocn
All 277 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| UI Accordionaccordion | remocn | Components | Free | 1 dep · 2 files | |
| UI AI Prompt Flowai-prompt-flow | remocn | Components | Free | 1 dep | |
| UI Alert Dialogalert-dialog | remocn | Components | Free | 1 dep · 2 files | |
| Animated Bar Chartanimated-bar-chart | remocn | Components | Free | 1 dep | |
| Animated Line Chartanimated-line-chart | remocn | Components | Free | 1 dep | |
| ASCII Dissolveascii-dissolve | remocn | Components | Free | 2 deps | |
| ASCII Renderascii-render | remocn | Components | Free | 1 dep | |
| Backdropbackdrop | remocn | Components | Free | 1 dep |
