Popover
To implement Popover component into your project you’ll need to add the import:
import Popover from "@kiwicom/orbit-components/lib/Popover";
After adding import to your project you can use it simply like:
<Popover content="Your content"><Button /></Popover>
Props
The table below contains all types of props available in the Popover component.
| Name | Type | Default | Description | 
|---|---|---|---|
| actions | React.Node | Actions to display at the bottom of the Popover See Functional specs. | |
| content | React.Node | The content to display in the Popover. | |
| children | React.Node | The reference element where the Popover will appear. | |
| dataTest | string | Optional prop for testing purposes. | |
| id | string | Set idforPopover. | |
| offset | offset | {left: 0, top: 0} | Optional prop to set position offset. | 
| fixed | boolean | Changes position to fixed from absolute, good for use in sticky components. | |
| noPadding | boolean | true | Adds or removes padding around popover’s content. | 
| opened | boolean | Prop for programmatically controlling Popover inner state. If openedis present open triggers are ignored. | |
| overlapped | boolean | false | If true, the content of Popover will overlap the trigger children. | 
| renderInPortal | boolean | true | Optional prop, set it to falseif you’re rendering Popover inside a custom portal, defaults totrue. | 
| width | string | Width of popover, if undefined, it is set to auto. | |
| maxHeight | string | The maximum height of the content of the popover, if undefined, it is set to 100%. | |
| onClose | () => void \| Promise | Function for handling onClose. | |
| onOpen | () => void \| Promise | Function for handling onOpen. | |
| placement | placement | bottom-start | 12 different placements to choose from. | 
| lockScrolling | boolean | true | Whether to prevent scrolling of the rest of the page while Popover is open on mobile. This is trueby default to provide a better user experience. | 
| noFlip | boolean | false | Turns off automatic flipping of the Popover when there is not enough space. | 
| allowOverflow | boolean | false | Allows the Popover to be cut off instead of moving it while scrolling to keep it visible. | 
| labelClose | React.Node | Close | The label for the close button displayed on mobile devices. | 
| renderTimeout | number | 0 | The timeout for rendering the Popover. | 
| zIndex | number | 710 | The zIndex value of the Popover component. | 
| ariaLabel | string | Optional prop for aria-labelattribute. | |
| ariaLabelledby | string | Optional prop for aria-labelledbyattribute. | |
| role | "dialog" \| "menu" \| "grid" \| "listbox" \| "tree" | "dialog" | Optional prop for roleattribute on the popover. | 
placement
| value | 
|---|
| "top" | 
| "right" | 
| "bottom" | 
| "left" | 
| "top-start" | 
| "top-end" | 
| "right-start" | 
| "right-end" | 
| "bottom-start" | 
| "bottom-end" | 
| "left-start" | 
| "left-end" | 
| "auto" | 
| "auto-start" | 
| "auto-end" | 
offset
| key | value | 
|---|---|
| top | number | 
| left | number | 
Functional specs
- Whenever - onClickfires, the component will calculate possible positions that can be applied and the first possible will be applied, if none is provided to the- placementprop.
- The - actionsprop is a way to override the default close behavior with your own actions. Keep in mind that one of the actions should close the popover.
- The Popover component supports rendering of many different components inside its children. You can use a combination of e.g. Text, Stack, ListChoice for example: 
<Popovercontent={<React.Fragment><ListChoicetitle="Choice Title"description="Further description"icon={<Accommodation />}onClick={action}/><ListChoicetitle="Choice Title"description="Further description"icon={<Accommodation />}onClick={action}/><ListChoicetitle="Choice Title"description="Further description"icon={<Accommodation />}onClick={action}/></React.Fragment>}><Button>Open Popover</Button></Popover>
Accessibility
- Buttonis the most common trigger component for opening and closing the popover. The- Popovercomponent renders a wrapping- divwith the- role="button"attribute by default. Ensure that the trigger component is set as a non-interactive component (for example, using the- asComponentprop) to avoid the accessibility violation of nesting interactive controls (- Interactive controls must not be nested).
- The - ariaLabelledbyprop allows you to specify an- aria-labelledbyattribute for the popover content component. This attribute provides a reference to one or more elements that label the popover content. By using- ariaLabelledby, the accessibility of popover component is improved and it is easier for users with assistive technologies to understand the context and purpose of the content.
- The - ariaLabelprop allows you to specify an- aria-labelattribute for the popover content component. This attribute provides additional information to screen readers, enhancing the accessibility of the component. By using- ariaLabel, you can ensure that users who rely on assistive technologies receive the necessary context and information about the component’s purpose and functionality.