Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Portal component #1524

Open
cpakken opened this issue Mar 2, 2025 · 9 comments
Open

Add a Portal component #1524

cpakken opened this issue Mar 2, 2025 · 9 comments
Labels
component: portal This is the name of the generic UI component, not the React module! new feature New feature or request waiting for 👍 Waiting for upvotes

Comments

@cpakken
Copy link

cpakken commented Mar 2, 2025

Feature request

Base-UI is internally using portals for components like

Please expose the as its own component

Similar to https://www.radix-ui.com/primitives/docs/utilities/portal

@cpakken cpakken added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 2, 2025
@mj12albert mj12albert added new feature New feature or request component: portal This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 3, 2025
@mj12albert mj12albert changed the title Simple Portal Component Add a Portal component Mar 3, 2025
@mj12albert
Copy link
Member

@cpakken Could you share some details about your use-case for using a portal directly?

As you said, all the components that could have a portal should already provide it

@mj12albert mj12albert added the waiting for 👍 Waiting for upvotes label Mar 3, 2025
@cpakken
Copy link
Author

cpakken commented Mar 3, 2025

I have a <ReaderView /> component that I want to maximize to the viewport by portaling out with fixed position. I can use React's native portal but I'd rather use BaseUI's underlying portal if I'm going to be using its other components. This way I don't need to create a separate portal dom node and just keep things consistent

@mj12albert
Copy link
Member

Actually the internal portals are just Floating UI's portal: https://github.com/mui/base-ui/blob/master/packages/react/src/select/portal/SelectPortal.tsx#L19

@colmtuite
Copy link
Contributor

@cpakken Do you need focus management for your use case? We have a lite Portal that we use internally that we could export, but it doesn't include focus management.

@cpakken
Copy link
Author

cpakken commented Mar 3, 2025

@colmtuite that would be nice, there are some control buttons in the <ReaderView />

@colmtuite
Copy link
Contributor

@cpakken Can you provide much more detail on what you're trying to do? It would be a bit of work to export a Portal that works with focus management, as opposed to just exporting the lite Portal. I'd love to get a closer look at the problem you're having?

@cpakken
Copy link
Author

cpakken commented Mar 10, 2025

@colmtuite I think this is overcomplicated my use case. I just wanted an equivalent to:

import { Portal } from 'radix-ui'

I have a custom element, that I would like to use portal and instead of making a separate element appended to and then use React's portal I wanted to leverage what Base UI has already implemented.

@atomiks
Copy link
Contributor

atomiks commented Mar 11, 2025

@cpakken the main issue with portals is that they need proper focus management to remain accessible to non-pointer users. Our existing components (like Dialog or Popover) handle portaling and focus management tightly coupled together, which can often be used for other related components. Can ReaderView be a Dialog?

If we export a Portal component, it would not handle any focus management and simply move the element outside of clipping containers—matching what Base UI does internally for things like the NumberField virtual cursor subcomponent. But a11y concerns need to be taken into consideration

@cpakken
Copy link
Author

cpakken commented Mar 11, 2025

@atomiks Oh. I just realized I can use and then set position: fixed with width and height set to screen dimensions. I think that will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: portal This is the name of the generic UI component, not the React module! new feature New feature or request waiting for 👍 Waiting for upvotes
Projects
None yet
Development

No branches or pull requests

4 participants