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

popover placement #2900

Closed
2 tasks done
hamzasaleem2 opened this issue Mar 4, 2024 · 2 comments
Closed
2 tasks done

popover placement #2900

hamzasaleem2 opened this issue Mar 4, 2024 · 2 comments

Comments

@hamzasaleem2
Copy link

hamzasaleem2 commented Mar 4, 2024

Feature description

possible to make placement inside popover? regular: right,left,top,bottom

example:
<popover placement="right"/>

Affected component/components

popover

Additional Context

Additional details here...

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues and PRs
@Nagalsky
Copy link

Nagalsky commented Mar 4, 2024

@hamzasaleem2 https://www.radix-ui.com/primitives/docs/components/popover#content - take a look side and align props

@hamzasaleem2
Copy link
Author

can't believe i missed it. thanks!

needed two things to make it look like this, just incase anyone else is looking for it.

image

add side to className
include side={side} in content ref
set align to "start"

const PopoverContent = React.forwardRef<
  React.ElementRef<typeof PopoverPrimitive.Content>,
  React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> >(
  (
    { className, align = "start", side = "right", sideOffset = 4, ...props },
    ref
  ) => (
    <PopoverPrimitive.Portal>
      <PopoverPrimitive.Content
        ref={ref}
        align={align}
        side={side}
        sideOffset={sideOffset}
        className={cn(
          "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
          className
        )}
        {...props}
      />
    </PopoverPrimitive.Portal>
  )
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants