Popover
Painel
import { Popover } from '@rivocode/ui'Quando usar
Painel ancorado de conteúdo livre. A peça entre o Tooltip, que só mostra texto
curto, e o Dialog, que rouba a tela inteira.
Compõe com PopoverTrigger, PopoverContent, PopoverTitle,
PopoverDescription e PopoverClose.
side, align e sideOffset ficam no PopoverContent: quem escreve a tela
pensa neles junto com o conteúdo.
No React Native
Não porta. O painel ancorado ao gatilho é um problem de tela estreita antes de ser um problem de toque: ele nasce debaixo do dedo que o abriu e não tem para onde fugir. No React Native o equivalente é o Sheet, que sobe de baixo e não disputa espaço com nada.
API
| Prop | Tipo |
|---|---|
actionsRef0.4.0A ref to imperative actions. | RefObject<PopoverRootActions | null> |
defaultOpen0.4.0Whether the popover is initially open. | boolean |
defaultTriggerId0.4.0ID of the trigger that the popover is associated with. | string | null |
handle0.4.0A handle to associate the popover with a trigger. | PopoverHandle<Payload> |
modal0.4.0Determines if the popover enters a modal state when open. | "trap-focus" | boolean |
onOpenChange0.4.0Event handler called when the popover is opened or closed. | ((open: boolean, eventDetails: PopoverRootChangeEventDetails) => void) |
onOpenChangeComplete0.4.0Event handler called after any animations complete when the popover is opened or closed. | ((open: boolean) => void) |
open0.4.0Whether the popover is currently open. | boolean |
triggerId0.4.0ID of the trigger that the popover is associated with. | string | null |
Partes
Popover se monta com estas peças. Todas vivem nesta página, porque separar cada uma num endereço obrigaria a abrir seis abas para montar uma tela.
PopoverClose
/popover-close.mdFecha o painel de dentro dele, sem você guardar estado.
O painel já fecha com Esc e com clique fora; este serve para o botão que conclui (o Aplicar de um filtro, o Entendi de uma explicação) fechar junto com o que ele faz.
| Prop | Tipo |
|---|---|
nativeButton0.4.0Whether the component renders a native `<button>` element when replacing it via the `render` prop. | boolean |
render0.4.0Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ComponentRenderFn<HTMLProps, PopoverCloseState>ReactElement<unknown, stringJSXElementConstructor<any>> |
Além destas, a peça aceita className, style, id e children, repassados ao elemento de baixo.
PopoverContent
/popover-content.mdO painel, em portal no contêiner do RivoProvider.
side, align e sideOffset moram aqui de propósito: quem escreve a tela
decide o lado junto com o conteúdo, e não na raiz, longe do que vai dentro. O
painel vira sozinho quando não cabe do lado pedido.
São as mesmas três props, com o mesmo significado e a mesma folga padrão de
6px, no MenuContent, no SelectContent, no ComboboxContent e no
TooltipContent: o que flutua nesta biblioteca também se posiciona igual.
| Prop | Tipo |
|---|---|
align0.4.0Alinhamento no eixo do lado escolhido. | Align |
finalFocus0.4.0Determines the element to focus when the popover is closed. | booleanRefObject<HTMLElementnull>((closeType: InteractionType) => voidbooleanHTMLElementnull) |
initialFocus0.4.0Determines the element to focus when the popover is opened. | booleanRefObject<HTMLElementnull>((openType: InteractionType) => voidbooleanHTMLElementnull) |
render0.4.0Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ComponentRenderFn<HTMLProps, PopoverPopupState>ReactElement<unknown, stringJSXElementConstructor<any>> |
side0.4.0Lado preferido do gatilho. | Side |
sideOffset0.4.0Distancia entre o gatilho e o painel, em pixels. | number | OffsetFunction |
Além destas, a peça aceita className, style, id e children, repassados ao elemento de baixo.
PopoverDescription
/popover-description.mdO texto do painel, ligado a ele por aria-describedby.
| Prop | Tipo |
|---|---|
render0.4.0Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ComponentRenderFn<HTMLProps, PopoverDescriptionState>ReactElement<unknown, stringJSXElementConstructor<any>> |
Além destas, a peça aceita className, style, id e children, repassados ao elemento de baixo.
PopoverTitle
/popover-title.mdO título do painel, ligado a ele por aria-labelledby.
Sem ele o leitor de tela abre um painel sem nome, e quem navega por teclado descobre onde está lendo o primeiro parágrafo.
| Prop | Tipo |
|---|---|
render0.4.0Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ComponentRenderFn<HTMLProps, PopoverTitleState>ReactElement<unknown, stringJSXElementConstructor<any>> |
Além destas, a peça aceita className, style, id e children, repassados ao elemento de baixo.
PopoverTrigger
/popover-trigger.mdO que abre o painel, e a âncora dele.
A posição é medida a partir daqui, então o gatilho é o elemento visível ao lado
do qual o painel deve aparecer, e não um invólucro maior que o empurraria para
longe. Com openOnHover, abre na passagem do mouse; use com parcimônia, porque
painel que abre sozinho atravessa o caminho de quem só estava passando.
Ele não tem pele própria (o uso comum é render={<Button />}, e duas fontes de
estilo brigariam), mas tem o anel de foco do teclado. Foco não é pele: quando o
gatilho é escrito à mão, o anel daqui é o único que existe.
| Prop | Tipo |
|---|---|
closeDelay0.4.0How long to wait before closing the popover that was opened on hover. | number |
delay0.4.0How long to wait before the popover may be opened on hover. | number |
handle0.4.0A handle to associate the trigger with a popover. | PopoverHandle<unknown> |
nativeButton0.4.0Whether the component renders a native `<button>` element when replacing it via the `render` prop. | boolean |
openOnHover0.4.0Whether the popover should also open when the trigger is hovered. | boolean |
payload0.4.0A payload to pass to the popover when it is opened. | unknown |
render0.4.0Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ComponentRenderFn<HTMLProps, PopoverTriggerState>ReactElement<unknown, stringJSXElementConstructor<any>> |
Além destas, a peça aceita className, style, id e children, repassados ao elemento de baixo.