Skip to content

Improve the TabSheet API #170

@tomivirkki

Description

@tomivirkki

The current way of using the <TabSheet> component is a bit clunky, since you have to pair a <Tab> and the content component together with an id (using the tab -helper function together with a spread operator).

<TabSheet>
  <Tabs slot="tabs">
    <Tab id="dashboard-tab">Dashboard</Tab>
    <Tab id="payment-tab"><i>Payment</i></Tab>
  </Tabs>

  <div {...tab('dashboard-tab')}>This is the Dashboard tab content</div>
  <div {...tab('payment-tab')}>This is the Payment tab content</div>
</TabSheet>

Improve the <TabSheet> API by introducing a helper component (<TabSheetTab>) which abstracts away the underlying id-based pairing, for example:

<TabSheet>
  <TabSheetTab header="Dashboard">
    <div>This is the Dashboard tab content</div>
  </TabSheetTab>

  <TabSheetTab header={<i>Payment</i>}>
    <div>This is the Payment tab content</div>
  </TabSheetTab>
</TabSheet>

The outcome in both cases:

Screenshot 2023-12-20 at 10 42 48

Prototype at https://github.com/vaadin/react-components/tree/feat/tabsheet-api

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions