Popover

Popovers display related content or functionality that is related to a particular element.

Default

Storybook failed to load.

With title

Popovers can be configured to have a title, this is displayed at the top opposite a close button.

Storybook failed to load.

With title & text button

As above, but with the close button displayed as text.

Storybook failed to load.

On the side

Storybook failed to load.

Attach to external element

Storybook failed to load.

Opened by an input

You can use a BpkInput enhanced with the withOpenEvents higher-order component to open popovers.

Storybook failed to load.

bpk-component-popover

Backpack popover component.

Installation

Check the main Readme for a complete installation guide.

Usage


                                                
                                                import { createRef } from 'react';
                                                import BpkButton from '@skyscanner/backpack-web/bpk-component-button';
                                                import BpkPopover from '@skyscanner/backpack-web/bpk-component-popover';
                                                import BpkText from '@skyscanner/backpack-web/bpk-component-text';
                                                
                                                class App extends Component {
                                                  constructor() {
                                                    super();
                                                
                                                    this.ref = createRef();
                                                    this.state = {
                                                      isOpen: false,
                                                    };
                                                
                                                  }
                                                
                                                  openPopover = () => {
                                                    this.setState({
                                                      isOpen: true,
                                                    });
                                                  }
                                                
                                                  closePopover = () => {
                                                    this.setState({
                                                      isOpen: false,
                                                    });
                                                  }
                                                
                                                  const target = (
                                                    <div ref={this.ref} className={'my-popover-target'}>
                                                      <BpkButton
                                                        onClick={this.openPopover}>
                                                          Open
                                                      </BpkButton>
                                                    </div>
                                                  )
                                                
                                                  render() {
                                                    return (
                                                      <div id="popover-container">
                                                        <BpkPopover
                                                          id="my-popover"
                                                          target={target}
                                                          onClose={this.closePopover}
                                                          isOpen={this.state.isOpen}
                                                          label="My popover"
                                                          closeButtonLabel="Close"
                                                          closeButtonProps={{
                                                            tabIndex: 0,
                                                          }}
                                                        >
                                                          <BpkText>My popover content</BpkText>
                                                        </BpkPopover>
                                                      </div>
                                                    );
                                                  }
                                                }

Props

Check out the full list of props on Skyscanner's design system documentation website.

Props

Storybook failed to load.