Command palette

@yasinsensoy/native

React Native · Components

Popover

An info or form panel that opens next to the trigger.

3 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

Code

import { Popover, Button, TextField } from "@yasinsensoy/native";

<Popover
  trigger={<Button variant="outline">Boyutlar</Button>}
  title="Dimensions"
>
  {({ close }) => (
    <>
      <TextField label="Width" defaultValue="100%" />
      <Button size="sm" onClick={close}>Apply</Button>
    </>
  )}
</Popover>

Events

  1. Events appear here when you interact with the preview.

Import

import { Popover } from "@yasinsensoy/native";

Popover

component

An info or form panel that opens next to the trigger. Same API as Popover on web. On a phone it becomes a bottom sheet (mobileSheet); tapping outside and the Android back button close it. Looks the same on iOS and Android.

Popover({ trigger, children, title, description, label, side, open, defaultOpen, onOpenChange, mobileSheet, closeOnBackButton, style, testID, }: PopoverProps): JSX.Element

Examples

<Popover trigger={<Button variant="outline">Dimensions</Button>} title="Dimensions">
  {({ close }) => <DimensionsForm onSave={close} />}
</Popover>

Values received when children is given as a function.

NameTypeDescription
close() => voidCloses the panel.

PopoverProps

interface

Props of the Popover component (same names as on web).

NameTypeDefaultDescription
triggerReactElementElement that opens and closes the panel, usually a Button.
children?ReactNode | ((context: PopoverRenderContext) => ReactNode)Content of the panel. When a function, it receives { close }.
title?ReactNodeTitle on top of the panel; screen readers announce the panel by this name.
description?ReactNodeDescription below the title.
label?stringScreen reader name; give it when there is no visible title.
side?Placement"auto"Position relative to the trigger (e.g. "top-right"); flips to the opposite side if it does not fit. See Placement.
open?booleanWhether it is open in controlled use.
defaultOpen?booleanfalseOpen initially in uncontrolled use?
onOpenChange?(open: boolean) => voidCalled with the new state when it opens or closes.
mobileSheet?booleantrueTurn into a bottom sheet on narrow screens (phones)?
closeOnBackButton?booleantrueShould the Android back button close the open panel?
style?ViewStylePanel style (e.g. { width: 320 }).
testID?stringTest id (panel).