Justifying content in tab header

<div class="e-tab-header" headerStyle="e-background" width = "1400px">

       

            <div>Requirement Detail</div>

            <div>Sources</div>

            <div>Customers</div>

            <div>Compliance</div>

            <div>Tags</div>

            <div>Reports</div>

        <div class="button-row" style="float:right;" >

            <button mat-flat-button>in tab header</button>

          </div>  

        

     </div> <!--end tab header-->


        <div class="button-row" style="float:right; ">

            <button mat-flat-button>outside tab header</button>

        </div>


I am trying to left-justify the tabs and right-justify the button. In the screenshot, the purple line is the right border of the tab header. The button inside the header should be there while the tabs themselves stay put. How can I achieve this?

Thank you Walter





Attachment: tab_header_dcce11ed.zip

5 Replies 1 reply marked as answer

RV Ravikumar Venkatesan Syncfusion Team May 9, 2022 03:46 PM UTC

Hi Walter,


Greetings from Syncfusion support.


We have validated your query “Justifying content in tab header” at our end. We suspect that you need to align the tab headers with buttons that need to be aligned on the right side of the tab and we have achieved it with help of the code mentioned below.


[app.component.html]

<ejs-tab #htmlTab cssClass="html-tab" (created)="afterCreated()">

</ejs-tab>



[app.component.ts]

export class AppComponent {

    @ViewChild('htmlTab'tabTabComponent;

 

    public afterCreated() {

        if (this.tab && this.tab.element) {

            const buttonsHTMLElement[] = [].slice.call(this.tab.element.querySelectorAll('.custom-btn')) as HTMLElement[];

            for (const button of buttons) {

                const toolbarItemHTMLElement = (button as HTMLElement).closest('.e-toolbar-item');

                toolbarItem.style.position = 'inherit';

                toolbarItem.style.float = 'right';

            }

        }

    }

}


[app.component.css]

.html-tab.e-tab .e-tab-header .e-toolbar-items {

    width100%;

}


Sample: https://stackblitz.com/edit/ej2-angular-tab-align-tab-header-items?file=app.component.html,app.component.css,app.component.ts


Kindly try the shared sample and let us know if you need any further assistance.


Regards,

Ravikumar Venkatesan


Marked as answer

WC Walter Cook May 9, 2022 08:35 PM UTC

That's fantastic! No way I would have come up with that.

Thank you.




SK Satheesh Kumar Balasubramanian Syncfusion Team May 10, 2022 06:23 AM UTC

You are most welcome!!!



WC Walter Cook June 3, 2022 10:52 PM UTC

The right-justification is great.

I'm looking for the buttons to just be buttons, not select tabs. Is that possible?

Can you lay a button in the header but not act like a tab control?

Cheers




RM Ruksar Moosa Sait Syncfusion Team June 6, 2022 11:31 AM UTC

Hi Walter,


We have checked on your requirement and let you know that it is possible to render a button in the tab header, but not possible to make it not behave like a tab component.


Regards,

Ruksar Moosa Sait


Loader.
Up arrow icon