Skip to content

Latest commit

 

History

History

bpk-component-dialog

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

bpk-component-dialog

Backpack dialog component.

Installation

Check the main Readme for a complete installation guide.

Usage

import { Component } from 'react';
import BpkDialog from '@skyscanner/backpack-web/bpk-component-dialog';
import BpkButton from '@skyscanner/backpack-web/bpk-component-button';

class App extends Component {
  constructor() {
    super();

    this.state = {
      isOpen: false,
    };
  }

  onOpen = () => {
    this.setState({
      isOpen: true,
    });
  };

  onClose = () => {
    this.setState({
      isOpen: false,
    });
  };

  render() {
    return (
      <div id="dialog-container">
        <div id="pagewrap">
          <BpkButton onClick={this.onOpen}>Open dialog</BpkButton>
        </div>
        <BpkDialog
          ariaLabel="example dialog to showcase component"
          closeLabel="Close dialog"
          id="my-dialog"
          className="my-classname"
          isOpen={this.state.isOpen}
          onClose={this.onClose}
          getApplicationElement={() => document.getElementById('pagewrap')}
          renderTarget={() => document.getElementById('dialog-container')}
        >
          This is a dialog. You can put anything you want in here.
        </BpkDialog>
      </div>
    );
  }
}

Props

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