Getting Started with KendoReact Popup

The KendoReact Popup positions a piece of content next to a specific anchor component.

The KendoReact Popup is distributed through NPM under the kendo-react-popup package.

The Popup component is part of KendoReact, a professionally built commercial UI library. To try out this component you need to sign up for a 30-day trial, which gives you access to the full KendoReact library.

Basic Usage

The following example demonstrates the Popup in action.

<style>
  .popup-content {
    padding: 30px;
    color: #787878;
    background-color: #fcf7f8;
    border: 1px solid rgba(0,0,0,.05);
  }
</style>
class AppComponent extends React.Component {
    anchor = null;
    constructor(props) {
        super(props);
        this.state = { show: false };
    }

    componentDidMount() {
        this.setState({show: true});
    }

    render() {
        return (
            <div>
                <button
                    className="k-button"
                    onClick={this.onClick}
                    ref={(button) => {
                        this.anchor = button;
                    }}
                >
                    {this.state.show ? 'Hide' : 'Show'}
                </button>
                <Popup
                    anchor={this.anchor}
                    show={this.state.show}
                    popupClass={'popup-content'}
                >
                    Popup content.
                </Popup>
            </div>
        );
    }

    onClick = () => {
        this.setState({ show: !this.state.show });
    }
}

ReactDOM.render(
    <AppComponent />,
    document.querySelector('my-app')
);

Functionality and Features

Installation

  1. Download and install the package. Use Node.js v5.0.0 or later.

    npm install --save @progress/kendo-react-popup
  2. Once installed, import the package module.

    // ES2015 module syntax
    import { Popup } from '@progress/kendo-react-popup';
    // CommonJS format
    const { Popup } = require('@progress/kendo-react-popup');
  3. You are required to install one of the Kendo UI themes to style your components. For more information on how to add the styles, refer to the article on getting started.

Dependencies

The Popup package requires you to install the following peer dependencies in your application:

  • react 16.8.2*
  • react-dom