Having trouble getting help?
Contact Support
Contact Support
Style and appearance in EJ2 TypeScript List box control
2 May 20234 minutes to read
To modify the ListBox appearance, you need to override the default CSS of ListBox component. Please find the list of CSS classes and its corresponding section in ListBox component. Also, you have an option to create your own custom theme for the controls using our Theme Studio
.
CSS Class | Purpose of Class | |
---|---|---|
.e-listbox-wrapper | To customize the listbox wrapper | |
.e-list-parent .e-list-item | To customize the listbox list items | |
.e-list-parent .e-list-item:hover | To customize the listbox list items on hover | |
.e-list-parent .e-list-item.e-selected | To customize the listbox selected list item | |
.e-listboxtool-wrapper .e-listbox-tool | To customize the listbox toolbar | |
.e-listboxtool-wrapper .e-listbox-tool .e-btn | To customize the listbox toolbar button | |
.e-listboxtool-wrapper .e-listbox-tool .e-btn .e-btn-icon.e-icons::before | To customize the listbox toolbar icon |
Horizontal ListBox
You can use cssClass property to display the Listbox horizontally.
import { ListBox } from '@syncfusion/ej2-dropdowns';
// define the array of object
let data: { [key: string]: Object }[] = [
{ text: 'Hennessey Venom' },
{ text: 'Bugatti Chiron' },
{ text: 'Bugatti Veyron Super Sport' },
{ text: 'SSC Ultimate Aero' },
{ text: 'Koenigsegg CCR' },
{ text: 'McLaren F1' },
{ text: 'Aston Martin One- 77' },
{ text: 'Jaguar XJ220' },
{ text: 'McLaren P1' },
{ text: 'Ferrari LaFerrari' },
];
// initialize ListBox component
let listObj: ListBox = new ListBox({
//set the data to dataSource property
dataSource: data,
cssClass: 'e-horizontal-listbox'
});
listObj.appendTo('#listbox');
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 ListBox</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="styles.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/28.2.3/ej2-base/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/28.2.3/ej2-inputs/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/28.2.3/ej2-dropdowns/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/28.2.3/ej2-buttons/styles/material.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container' style="margin:0 auto; width:250px;">
<h4>Select your favorite car:</h4>
<input id='listbox' />
</div>
</body>
</html>