Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@radix-ui/react-dropdown-menu
Advanced tools
The @radix-ui/react-dropdown-menu package is a set of low-level, unstyled UI primitives for building accessible dropdown and context menus in React applications. It provides the core functionality for dropdown menus without enforcing specific styling, allowing developers to customize the appearance as needed.
Triggering a Dropdown Menu
This code sample shows how to create a basic dropdown menu with a trigger and several items. The `DropdownMenu.Root` component wraps the entire menu, `DropdownMenu.Trigger` is used to open the menu, and `DropdownMenu.Content` contains the menu items.
{"import * as DropdownMenu from '@radix-ui/react-dropdown-menu';\n\nexport default function Example() {\n return (\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>Actions</DropdownMenu.Trigger>\n <DropdownMenu.Content>\n <DropdownMenu.Item>Item 1</DropdownMenu.Item>\n <DropdownMenu.Item>Item 2</DropdownMenu.Item>\n <DropdownMenu.Item>Item 3</DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n );\n}"}
Creating Submenus
This code demonstrates how to create a submenu within a dropdown menu. The `DropdownMenu.Sub` component is used to wrap the submenu, with `DropdownMenu.SubTrigger` to open the submenu and `DropdownMenu.SubContent` to contain the submenu items.
{"import * as DropdownMenu from '@radix-ui/react-dropdown-menu';\n\nexport default function Example() {\n return (\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>Actions</DropdownMenu.Trigger>\n <DropdownMenu.Content>\n <DropdownMenu.Item>Item 1</DropdownMenu.Item>\n <DropdownMenu.Sub>\n <DropdownMenu.SubTrigger>More Options</DropdownMenu.SubTrigger>\n <DropdownMenu.SubContent>\n <DropdownMenu.Item>Sub Item 1</DropdownMenu.Item>\n </DropdownMenu.SubContent>\n </DropdownMenu.Sub>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n );\n}"}
Customizing Menu Items
This code snippet illustrates how to customize the appearance of dropdown menu items using CSS-in-JS with the `styled` function from a library like `@stitches/react`. The `StyledItem` component is a styled version of `DropdownMenu.Item` with custom padding, border radius, and focus styles.
{"import * as DropdownMenu from '@radix-ui/react-dropdown-menu';\nimport { styled } from '@stitches/react';\n\nconst StyledItem = styled(DropdownMenu.Item, {\n padding: '10px 20px',\n borderRadius: '3px',\n '&:focus': {\n backgroundColor: 'blue',\n color: 'white'\n }\n});\n\nexport default function Example() {\n return (\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>Actions</DropdownMenu.Trigger>\n <DropdownMenu.Content>\n <StyledItem>Custom Item 1</StyledItem>\n <StyledItem>Custom Item 2</StyledItem>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n );\n}"}
react-select is a flexible and feature-rich select input control for React. It provides a powerful set of features for single and multi-value selection with search and filter capabilities. It differs from @radix-ui/react-dropdown-menu in that it is more focused on selection rather than general-purpose dropdown functionality.
downshift is a set of primitives to build simple, flexible, WAI-ARIA compliant enhanced input React components. Its main use case is for autocomplete and dropdown components. It is similar to @radix-ui/react-dropdown-menu but provides more built-in functionality for handling input and selection logic.
react-dropdown is a simple dropdown component for React, similar to @radix-ui/react-dropdown-menu. It provides a straightforward API for creating dropdowns with options. However, it is less customizable and does not offer the same level of accessibility features as @radix-ui/react-dropdown-menu.
react-dropdown-menu
$ yarn add @radix-ui/react-dropdown-menu
# or
$ npm install @radix-ui/react-dropdown-menu
View docs here.
FAQs
Unknown package
The npm package @radix-ui/react-dropdown-menu receives a total of 2,603,821 weekly downloads. As such, @radix-ui/react-dropdown-menu popularity was classified as popular.
We found that @radix-ui/react-dropdown-menu demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.