Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: How to create custom cds-tab component #18147

Open
1 task done
iv-arsenovic-levi9-com opened this issue Nov 25, 2024 · 0 comments
Open
1 task done

[Question]: How to create custom cds-tab component #18147

iv-arsenovic-levi9-com opened this issue Nov 25, 2024 · 0 comments

Comments

@iv-arsenovic-levi9-com
Copy link

iv-arsenovic-levi9-com commented Nov 25, 2024

Question for Carbon

Hello,

I am trying to create and override the cds-tab element in my Web Component using Lit 3.

I referred to the Carbon Web Components documentation on using custom styles, but when I tried to implement the same, I encountered issues:

The component renders as "blank" and is not functional.
Events, such as clicks, are not working properly.
Below is the code for my custom component:

Image

import { css } from 'lit-element';
import { customElement } from 'lit/decorators.js';

import CDSTab from '@carbon/web-components/es/components/tabs/tab.js';

// tried without this also
import '@carbon/web-components/es/components/tabs/index.js';

@customElement('to-tab')
export class ToTab extends CDSTab {
  static styles = [CDSTab.styles, css``];
}

When I try to use this component, it doesn't work as expected:

render() {
    return html`
      <to-tabs value="tab1" @cds-tabs-selected=${this._handleSelectedTab}>
        <to-tab id="test" value="test">Test</to-tab>
        <cds-tab id="tab1" value="tab1"> 1.Tab1 </cds-tab>
        <cds-tab id="tab2" value="tab2"> 2.Tab2 </cds-tab>
        <cds-tab id="tab3" value="tab3"> 3.Tab3 </cds-tab>
        <cds-tab id="tab4" value="tab4"> 4.Tab4 </cds-tab>
      </to-tabs>
    `;
  }

Custom to-tab Issues are that styles are not applied and component event does not working.

Image

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🕵️‍♀️ Triage
Development

No branches or pull requests

1 participant