Comments (7)
Can you clarify the issue with an example? In Radix Themes the Dropdown Menu Content component already comes with a built-in Scroll Area:
Screen.Recording.2023-10-06.at.11.12.16.mov
from primitives.
Thanks @vladmoroz for confirming this! It doesn't work for me though. This is my code, in a nutshell:
export const TeamSwitcher: React.FC<Props> = props => {
const { teams, currentTeamId, onChange, onCreateNew } = props;
const [portalContainer] = useState(() => document.getElementById("portal"));
const currentTeam = defined(teams.find(t => t.id === currentTeamId));
return (
<DropdownMenu.Root>
<DropdownMenu.Trigger tw="w-full p-2 flex items-center justify-center gap-3 rounded-xl hover:bg-n200A data-[state=open]:bg-n200A">
<TeamListItem team={currentTeam} selected={false} />
</DropdownMenu.Trigger>
<DropdownMenu.Portal container={portalContainer}>
<DropdownMenu.Content tw="p-1 min-w-[248px] shadow-md-dark bg-bg-front rounded-lg" align="start">
{teams.map(t => (
<DropdownMenu.Item
tw="p-2 hover:bg-n200A data-[highlighted]:bg-n200A rounded-xl"
key={t.id}
onClick={() => onChange(t.id)}>
<TeamListItem team={t} selected={t.id === currentTeamId} />
</DropdownMenu.Item>
))}
</DropdownMenu.Content>
</DropdownMenu.Portal>
</DropdownMenu.Root>
);
};
Even without passing our portal doesn't work π€·ββοΈ
from primitives.
The documentation example doesn't scroll either: https://codesandbox.io/s/jovial-carlos-wlzjnh
menu-scroll.mp4
from primitives.
@nuthinking your examples import the Dropdown Menu primitive which comes with no presentational styles like scroll. If that's what you wanted to use, you'll have to add an overflow style yourself or compose it with the Scroll Area.
If you wanted a themed Dropdown Menu component which comes with pre-defined styles and is pre-composed with the Scroll Area, you should get it from the @radix-ui/themes
package
from primitives.
Gotcha! Adding overflow-y: auto
to the content doesn't do anything. The element height is not modified. Any idea where I can find a working example? I would prefer not using the themed version. Thanks a lot! π
from primitives.
@nuthinking you need to add max-height to enable overflow. You can use --radix-dropdown-menu-content-available-height
variable for that, hereβs an example:
https://github.com/radix-ui/themes/blob/main/packages/radix-ui-themes/src/components/dropdown-menu.css
from primitives.
@vladmoroz thank you so much!
from primitives.
Related Issues (20)
- open dropdown (probably any modal) from select item - clicking select item will select the item instead of closing the dropdown
- Slot component causes a warning in React 19 about accessing `.ref` directly HOT 2
- [Accordion] layout shift with initial open items. HOT 1
- [AVATAR] Reload on error HOT 2
- Expose active trigger width and offset in NavigationMenuViewport
- Not getting proper typing on Popper types in Popover HOT 1
- Add "indeterminate" state to Switch component
- Outdated (not maintained?) changelog on website HOT 1
- NavigationMenu does not respond on hover in Chrome/Chromium on Linux (Ubunto/Mint)
- React 19 compatibility HOT 1
- Replacing a Dialog with another once causes layout shift HOT 1
- Pls give ability to turn off Keyboard Interactions in primirives like (Accordion)
- How can I read component internal state HOT 1
- Focused Toast removal with `Escape` key broken in `1.1.6-rc.1`
- Add support for popper-content-wrapper styling
- Add support for React 19, radix-ui/react-forms. While React 19 is still in beta it would be nice if the standard NPM install did not require --legacy-peer-deps HOT 1
- navigating between tabs using arrow keys doesn't lead to the same result as navigating using clicking
- Typing Space triggers tabs switching even when activation mode is set to manual
- Select Keyboard Navigation not working
- Getting `(0 , react__WEBPACK_IMPORTED_MODULE_0__.createContext) is not a function` Error when using Radix Scroll Area
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from primitives.