primitive dialog strips out radix/themes styles #2862
Unanswered
aryankarim
asked this question in
Help
Replies: 3 comments
-
Not sure if this is the correct solution. But I found out that portal takes the dialog to body where it is outside the theme HOC. So I removed the Portal and it works fine now. I tried using Dialog.Portal's |
Beta Was this translation helpful? Give feedback.
0 replies
-
Same here |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here is my wrapper for NextJS: import { ComponentProps } from 'react'
import * as RadixPopover from '@radix-ui/react-popover'
import classNames from 'classnames'
import ClientPortal from '@/components/lib/ClientPortal'
const Popover = RadixPopover.Root
export const PopoverTrigger = RadixPopover.Trigger
export const PopoverArrow = RadixPopover.Arrow
export const PopoverAnchor = RadixPopover.Anchor
export const PopoverPortal = ClientPortal
export interface PopoverContentProps extends ComponentProps<typeof RadixPopover.Content> {}
export const PopoverContent = ({ children, className, ...props }: PopoverContentProps) => (
<RadixPopover.Content
{...props}
className={classNames('w-[var(--radix-popover-trigger-width)] p-4 shadow-lg', className)}>
{children}
</RadixPopover.Content>
)
export default Popover And the portal: 'use client'
import { useRef, useEffect, useState, ReactNode } from 'react'
import { createPortal } from 'react-dom'
interface PortalProps {
children: ReactNode
}
const ClientPortal = (props: PortalProps) => {
const ref = useRef<Element | null>(null)
const [mounted, setMounted] = useState(false)
useEffect(() => {
ref.current = document.querySelector<HTMLElement>('#portal')
setMounted(true)
}, [])
return mounted && ref.current ? createPortal(props.children, ref.current) : null
}
export default ClientPortal
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Are we not allowed to use themes components inside primitive dialog? or am I missing something here?
Beta Was this translation helpful? Give feedback.
All reactions