Search results

Templates in React Breadcrumb component

03 Dec 2021 / 2 minutes to read

The Breadcrumb component provides a way to customize the items using itemTemplate and the separators using separatorTemplate properties.

Item Template

In the following example, Shopping Cart details are used as breadcrumb Items and the items are customized by the chips component using itemTemplate.

Source
Preview
index.tsx
index.html
index.css
index.jsx
Copied to clipboard
import { BreadcrumbComponent, BreadcrumbItemDirective, BreadcrumbItemsDirective } from '@syncfusion/ej2-react-navigations';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';

class App extends React.Component<{}, {}> {
   chipTemplate(data: any): JSX.Element {
        return (
            <ChipListComponent>
                <ChipsDirective>
                    <ChipDirective text={data.text}></ChipDirective>
                </ChipsDirective>
            </ChipListComponent>
        );
    }
    public render() {
        return (
            <BreadcrumbComponent cssClass="e-breadcrumb-chips" itemTemplate={this.chipTemplate}>
                <BreadcrumbItemsDirective>
                    <BreadcrumbItemDirective text="Cart"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Billing"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Shipping"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Payment"></BreadcrumbItemDirective>
                </BreadcrumbItemsDirective>
            </BreadcrumbComponent>
        );
    }
}
ReactDom.render(<App />,document.getElementById('element'));
Copied to clipboard
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React ContextMenu</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="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-buttons/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-popups/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-navigations/styles/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='element'>
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>
Copied to clipboard
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}

body {
	margin-top: 100px;
	text-align: center;
}
Copied to clipboard
import { BreadcrumbComponent, BreadcrumbItemDirective, BreadcrumbItemsDirective } from '@syncfusion/ej2-react-navigations';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';
class App extends React.Component {
    chipTemplate(data) {
        return (<ChipListComponent>
                <ChipsDirective>
                    <ChipDirective text={data.text}></ChipDirective>
                </ChipsDirective>
            </ChipListComponent>);
    }
    render() {
        return (<BreadcrumbComponent cssClass="e-breadcrumb-chips" itemTemplate={this.chipTemplate}>
                <BreadcrumbItemsDirective>
                    <BreadcrumbItemDirective text="Cart"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Billing"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Shipping"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Payment"></BreadcrumbItemDirective>
                </BreadcrumbItemsDirective>
            </BreadcrumbComponent>);
    }
}
ReactDom.render(<App />, document.getElementById('element'));

Separator Template

In the following example, the separators are customized with icons using separatorTemplate.

Source
Preview
index.tsx
index.html
index.css
index.jsx
Copied to clipboard
import { BreadcrumbComponent, BreadcrumbItemDirective, BreadcrumbItemsDirective } from '@syncfusion/ej2-react-navigations';
import * as React from 'react';
import * as ReactDom from 'react-dom';

class App extends React.Component<{}, {}> {
       arrowSeparatorTemplate(): JSX.Element {
        return (
            <span className="e-icons e-arrow"></span>
        );
    }
    public render() {
        return (
            <BreadcrumbComponent separatorTemplate={this.arrowSeparatorTemplate}>
                <BreadcrumbItemsDirective>
                    <BreadcrumbItemDirective text="Cart"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Billing"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Shipping"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Payment"></BreadcrumbItemDirective>
                </BreadcrumbItemsDirective>
            </BreadcrumbComponent>
        );
    }
}
ReactDom.render(<App />,document.getElementById('element'));
Copied to clipboard
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React ContextMenu</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="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-buttons/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-popups/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-navigations/styles/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='element'>
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>
Copied to clipboard
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}

body {
	margin-top: 100px;
	text-align: center;
}

.content-wrapper {
    width: 90%;
    margin: 0 auto;
    min-width: 85px;
    padding-top: 20px;
}

.content-wrapper div.row {
    padding: 15px 0px;
}

@media only screen and (max-width: 480px) {
    .content-wrapper {
        width: 92%;
    }

    .col-xs-6,
    .col-xs-4,
    .col-xs-12 {
        padding: 10px 5px;
        width: 100%;
    }

    .content-wrapper div.row {
        padding: 0px;
    }
}

@font-face {
    font-family: 'e-bicons';
    src:
    url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAAKAIAAAwAgT1MvMj1wS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cgU3luY2Z1c2lvbiBNZXRybyBTdHVkaW93d3cuc3luY2Z1c2lvbi5jb20AIABlAC0AYgBjAG8AbgBzAFIAZQBnAHUAbABhAHIAZQAtAGIAYwBvAG4AcwBlAC0AYgBjAG8AbgBzAFYAZQByAHMAaQBvAG4AIAAxAC4AMABlAC0AYgBjAG8AbgBzAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAHUAcwBpAG4AZwAgAFMAeQBuAGMAZgB1AHMAaQBvAG4AIABNAGUAdAByAG8AIABTAHQAdQBkAGkAbwB3AHcAdwAuAHMAeQBuAGMAZgB1AHMAaQBvAG4ALgBjAG8AbQAAAAACAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYBAgEDAQQBBQEGAQcAE2RvY3VtZW50LXNldHRpbmctd2YOZm9sZGVyLW9wZW4tMDERY2hldnJvbi1yaWdodF8wMy0KY2hlY2stbWFyawhob3VzZS0wNAAAAAA=) format('truetype');
    font-weight: normal;
    font-style: normal;
    }
    .e-bicons {
        font-family: 'e-bicons' !important;
        font-size: 14px;
	}
    .e-arrow:before {
        content: "\e253";
        font-weight: 800;
        font-size: 21px;
    }
Copied to clipboard
import { BreadcrumbComponent, BreadcrumbItemDirective, BreadcrumbItemsDirective } from '@syncfusion/ej2-react-navigations';
import * as React from 'react';
import * as ReactDom from 'react-dom';
class App extends React.Component {
    arrowSeparatorTemplate() {
        return (<span className="e-icons e-arrow"></span>);
    }
    render() {
        return (<BreadcrumbComponent separatorTemplate={this.arrowSeparatorTemplate}>
                <BreadcrumbItemsDirective>
                    <BreadcrumbItemDirective text="Cart"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Billing"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Shipping"></BreadcrumbItemDirective>
                    <BreadcrumbItemDirective text="Payment"></BreadcrumbItemDirective>
                </BreadcrumbItemsDirective>
            </BreadcrumbComponent>);
    }
}
ReactDom.render(<App />, document.getElementById('element'));