package com.vaadin.demo.component.tabs;
import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.tabs.TabSheet;
import com.vaadin.flow.router.Route;
@Route("tabsheet-basic")
public class TabSheetBasic extends Div {
public TabSheetBasic() {
// tag::snippet[]
TabSheet tabSheet = new TabSheet();
tabSheet.add("Dashboard",
new Div(new Text("This is the Dashboard tab content")));
tabSheet.add("Payment",
new Div(new Text("This is the Payment tab content")));
tabSheet.add("Shipping",
new Div(new Text("This is the Shipping tab content")));
add(tabSheet);
// end::snippet[]
}
}
tabsheet-basic.tsx
import React from 'react';
import { TabSheet, TabSheetTab } from '@vaadin/react-components/TabSheet.js';
function Example() {
return (
// tag::snippet[]
<TabSheet>
<TabSheetTab label="Dashboard">
<div>This is the Dashboard tab content</div>
</TabSheetTab>
<TabSheetTab label="Payment">
<div>This is the Payment tab content</div>
</TabSheetTab>
<TabSheetTab label="Shipping">
<div>This is the Shipping tab content</div>
</TabSheetTab>
</TabSheet>
// end::snippet[]
);
}
tabsheet-basic.ts
import '@vaadin/tabs';
import '@vaadin/tabsheet';
import { html, LitElement } from 'lit';
import { customElement } from 'lit/decorators.js';
import { applyTheme } from 'Frontend/generated/theme';
@customElement('tabsheet-basic')
export class Example extends LitElement {
protected override createRenderRoot() {
const root = super.createRenderRoot();
// Apply custom theme (only supported if your app uses one)
applyTheme(root);
return root;
}
protected override render() {
return html`
<!-- tag::snippet[] -->
<vaadin-tabsheet>
<vaadin-tabs slot="tabs">
<vaadin-tab id="dashboard-tab">Dashboard</vaadin-tab>
<vaadin-tab id="payment-tab">Payment</vaadin-tab>
<vaadin-tab id="shipping-tab">Shipping</vaadin-tab>
</vaadin-tabs>
<div tab="dashboard-tab">This is the Dashboard tab content</div>
<div tab="payment-tab">This is the Payment tab content</div>
<div tab="shipping-tab">This is the Shipping tab content</div>
</vaadin-tabsheet>
<!-- end::snippet[] -->
`;
}
}