Getting Started with the KendoReact ScrollView

This guide provides the information you need to start using the KendoReact ScrollView — it includes instructions about the available installation approaches, the required dependencies, the code for running the project, and links to additional resources.

ninja-iconThe ScrollView is part of KendoReact, a professional grade UI library with 110+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.Start Free Trial

After the completion of this guide, you will be able to achieve an end result as demonstrated in the following example.

Change Theme
Theme
Loading ...

Setting Up Your React Project

Before you install the KendoReact ScrollView, make sure that you have a running React project. The easiest way to set up a React project is to use the Create React App approach that is described in the Get Started with KendoReact article.

Installing the ScrollView Package

All KendoReact packages are distributed through npm and offer a similar installation experience. To use the ScrollView component, start with the installation of the ScrollView npm package and its dependencies. Use Node.js v5.0.0 or later.

sh
npm install --save @progress/kendo-react-scrollview @progress/kendo-react-intl @progress/kendo-licensing @progress/kendo-svg-icons

Importing the Component

After installing the package, import the ScrollView component in the React App. In the src/App.js file of your React project, import the ScrollView component from the ScrollView package.

jsx
// ES2015 module syntax
import { ScrollView } from "@progress/kendo-react-scrollview";
jsx
// CommonJS format
const { ScrollView } = require('@progress/kendo-react-scrollview');

Using the Component

  1. Map the array of objects by adding the following code in the src/App.js file.
jsx
const items = [
    { position: 1, url: 'https://demos.telerik.com/kendo-ui/content/shared/images/photos/1.jpg' },
    { position: 2, url: 'https://demos.telerik.com/kendo-ui/content/shared/images/photos/2.jpg' },
    { position: 3, url: 'https://demos.telerik.com/kendo-ui/content/shared/images/photos/3.jpg' },
    { position: 4, url: 'https://demos.telerik.com/kendo-ui/content/shared/images/photos/4.jpg' }
];
  1. Add the component's markup to the src/App.js file in your project.
jsx
import 'style.css';

const App = () => {
    return (
        <div>
            <ScrollView style={{ width: 512, height: 384 }}>
                {items.map((item, index) => {
                    return (
                        <div className="image-with-text" key={index}>
                            <p>
                                Showing image {item.position} of {items.length}.
                            </p>
                            <img
                                src={item.url}
                                alt={'KendoReact ScrollView Photo'}
                                style={{ width: 512, height: 384 }}
                                draggable={false}
                            />
                        </div>
                    );
                })}
            </ScrollView>
        </div>
    );
};
export default App;
  1. Add the component's styles to the src/style.css file in your project.
scss
/* center the ScrollView horizontally */
/* k-scrollview is the default component class */
.k-scrollview {
    margin: 0 auto;
}
/* enable absolute positioning inside the ScrollView template */
.image-with-text {
    position: relative;
}

/* style the overlay text inside the ScrollView */
.image-with-text > p {
    position: absolute;
    top: 1rem;
    left: 1.6rem;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    font-style: italic;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}
  1. To style the ScrollView, install and import the Default theme, which is one of the three beautiful themes for KendoReact.

    2.1. Install the Default theme package.

    sh
    npm install --save @progress/kendo-theme-default

    2.2. Import the CSS file from the package in src/App.js. Add this import before your existing App.css import.

    jsx
    import '@progress/kendo-theme-default/dist/all.css';
  2. Build and run the application by typing the following command in the root folder of your project:

    sh
    npm start
  3. Navigate to http://localhost:3000 to see the KendoReact ScrollView component on the page.

Activating Your License Key

Using any of the UI components in the KendoReact library requires either a commercial license key or an active trial license key.

Follow the instructions on the KendoReact My License page to activate your trial or commercial license. You can skip this step if your application already contains a KendoReact license file.

Dependencies

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

Package NameDescription
react 16.8.2*Contains the functionality necessary to define React components.
react-domContains the React renderer for the web.
@progress/kendo-licensingContains the internal infrastructure related to licensing.
@progress/kendo-react-intlContains the KendoReact Internationalization package that applies the desired cultures by providing services and pipes for the parsing and formatting of dates and numbers.
@progress/kendo-svg-iconsContains the KendoReact SVG icons.

Learning Resources