Skip to content

[Popover] How to align the start of the popover with the center of the trigger? #1195

Closed
@benface

Description

@benface

First of all, amazing work on this library. The alpha version looks super solid already.

I've come across a potential limitation when using Popover. My design requires me to align the left / start of the popover with the center of the trigger (minus an offset, because actually the goal is to align the center of the first column of the popover, which has a fixed width... but that's irrelevant). With the align prop, it only seems possible to align the start of the popover with the start of the trigger, the center of the popover with the center of the trigger, or the end of the popover with the end of the trigger. Is there a solution I'm not seeing, given that the trigger has an unknown/dynamic width? If not, I have 2 potential (but very rough) ideas of how it could be handled (assuming you agree that it's a worthy use case!)

  1. Another prop named triggerAlign or something, which would default to the same value as align, but in my case I would set it to center.
  2. I have no idea if this is technically feasible, but maybe the alignOffset prop could accept a function that would receive the dimensions of the trigger and of the popup, and could do some math based on those to return an offset value?

Thanks so much again, I'm excited to see how this library evolves.

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions