1- import { Preview , Props , Story } from ' @storybook/addon-docs/blocks' ;
1+ import { ArgsTable , Canvas , Story } from ' @storybook/addon-docs/blocks' ;
22
3- # [ Unstable ] Popover
3+ # Popover
44
55[ Source code] ( https://github.com/carbon-design-system/carbon/tree/main/packages/react/src/components/Popover )
6+   ; |  ;
7+ [ Usage guidelines] ( https://www.carbondesignsystem.com/components/popover/usage )
8+   ; |  ;
69
710<!-- START doctoc generated TOC please keep comment here to allow auto update -->
811<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
@@ -17,14 +20,77 @@ import { Preview, Props, Story } from '@storybook/addon-docs/blocks';
1720
1821## Overview
1922
20- **Note: this component is currently experimental and does not follow semver.**
23+ `Popover` is a primitive component used to build custom components which render
24+ over other elements on the page. For example, `Popover` is used to build
25+ our popover components in Carbon.
2126
22- The Popover component is used to build layers that appear on top of the current
23- surface.
27+ The `Popover` component accepts two items as `children`: a trigger element and
28+ a `PopoverContent` component which contains the content to be rendered inside of the
29+ `Popover`.
30+
31+ ```jsx
32+ import { Popover , PopoverContent } from ' @carbon/react' ;
33+ import React from ' react' ;
34+
35+ function CustomComponent() {
36+ const [open , setOpen ] = React .useState (false );
37+
38+ return (
39+ <Popover open = { open } >
40+ <button
41+ type = " button"
42+ onClick = { () => {
43+ setOpen (! open );
44+ }} >
45+ Toggle
46+ </button >
47+ <PopoverContent >
48+ The content that is revealed by interacting with the Toggle button
49+ </PopoverContent >
50+ </Popover >
51+ );
52+ }
53+ ```
54+
55+ ## Visibility
56+
57+ The `open` prop allows you to control the visibility of the `Popover`. This is
58+ often tracked in state and is toggled based on the trigger render inside of the
59+ `Popover`. A trigger must be an interactive element and in most cases it will be
60+ a `<button>`.
61+
62+ ## Alignment
63+
64+ The `align` prop allows you to specify where your content should be placed
65+ relative to the popover. For example, if you provide `align="top"` to the
66+ `Popover` component then the popover will render above your component.
67+ Similarly, if you provide `align="bottom"` then the popover will render below
68+ your component.
69+
70+ You can also configure the placement of the caret, if it is enabled, by choosing
71+ between `left` and `right` or `bottom` and `top`, depending on where your
72+ popover is being rendered.
73+
74+ If you are using `align="top"`, then you can choose between `align="top-left"`
75+ and `align="top-right"`. These options will place the caret closer to the left
76+ or right edges of the popover.
77+
78+ If you are using `align="left"` or `align="right"`, you can use `top` or
79+ `bottom` to control this alignment.
80+
81+ ## Appearance
82+
83+ The `Popover` component has several props which you can use to customize its
84+ appearance, including:
85+
86+ - `caret`: to conditionally display a `caret` or render the popover directly
87+ beside the trigger element
88+ - `dropShadow`: to display a drop shadow on the popover content
89+ - `highContrast`: to display a high contrast variant of the popover
2490
2591## Component API
2692
27- <Props />
93+ <ArgsTable />
2894
2995## Feedback
3096
0 commit comments