Styles and Appearances in React ListBox

24 Sep 20268 minutes to read

Modify the React ListBox appearance by overriding the default CSS of the React ListBox component. Refer to the CSS class table below for customization options. You can also create custom themes using Theme Studio.

CSS Class Purpose of Class  
  .e-listbox-wrapper To customize the React ListBox wrapper
  .e-list-parent .e-list-item To customize the React ListBox list items
  .e-list-parent .e-list-item:hover To customize the React ListBox list items on hover
  .e-list-parent .e-list-item.e-selected To customize the React ListBox selected list item
  .e-listboxtool-wrapper .e-listbox-tool To customize the React ListBox toolbar
  .e-listboxtool-wrapper .e-listbox-tool .e-btn To customize the React ListBox toolbar button
  .e-listboxtool-wrapper .e-listbox-tool .e-btn .e-btn-icon.e-icons::before To customize the React ListBox toolbar icon

Horizontal ListBox

Display the React ListBox horizontally using the cssClass property:

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ListBoxComponent } from '@syncfusion/ej2-react-dropdowns';
function App() {
    // define the array of object
    let data = [
        { text: 'Hennessey Venom', id: 'list-01' },
        { text: 'Bugatti Chiron', id: 'list-02' },
        { text: 'Bugatti Veyron Super Sport', id: 'list-03' },
        { text: 'SSC Ultimate Aero', id: 'list-04' },
        { text: 'Koenigsegg CCR', id: 'list-05' },
        { text: 'McLaren F1', id: 'list-06' },
        { text: 'Aston Martin One- 77', id: 'list-07' },
        { text: 'Jaguar XJ220', id: 'list-08' },
        { text: 'McLaren P1', id: 'list-09' },
        { text: 'Ferrari LaFerrari', id: 'list-10' },
    ];
    return (
    // specifies the tag for render the ListBox component
    <ListBoxComponent dataSource={data} cssClass='e-horizontal-listbox'/>);
}
export default App;
ReactDOM.render(<App />, document.getElementById('sample'));
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ListBoxComponent } from '@syncfusion/ej2-react-dropdowns';

function App() {
  // define the array of object
  let data: { [key: string]: Object }[] = [
    { text: 'Hennessey Venom', id: 'list-01' },
    { text: 'Bugatti Chiron', id: 'list-02' },
    { text: 'Bugatti Veyron Super Sport', id: 'list-03' },
    { text: 'SSC Ultimate Aero', id: 'list-04' },
    { text: 'Koenigsegg CCR', id: 'list-05' },
    { text: 'McLaren F1', id: 'list-06' },
    { text: 'Aston Martin One- 77', id: 'list-07' },
    { text: 'Jaguar XJ220', id: 'list-08' },
    { text: 'McLaren P1', id: 'list-09' },
    { text: 'Ferrari LaFerrari', id: 'list-10' },
  ];
  return (
      // specifies the tag for render the ListBox component
    <ListBoxComponent dataSource={data} cssClass='e-horizontal-listbox'/>
  );
}
export default App;
ReactDOM.render(<App />, document.getElementById('sample'));
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React ListBox</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
   <link href="https://cdn.syncfusion.com/ej2/35.2.12/tailwind3.css" rel="stylesheet">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
    <style>
        #loader {
            color: #008cff;
            height: 40px;
            left: 45%;
            position: absolute;
            top: 45%;
            width: 30%;
        }

        /* Custom css for horizontal listbox */
        .e-horizontal-listbox .e-list-parent {
            display: inline-flex;
            align-items: center;
        }

        .e-horizontal-listbox {
            overflow-y: hidden;
            height: 100px;
        }

        .e-horizontal-listbox .e-list-parent .e-list-item {
            width: max-content;
            line-height: 100px;
            height: 100px;
        }
    </style>
</head>

<body>
    <div id='sample' style="margin: 20px auto 0; width:250px;">
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>