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

[Bug]:Challenges in Extending Web Components: CSS Dependency Issues #17721

Open
2 tasks done
sibyaugustine opened this issue Oct 11, 2024 · 0 comments
Open
2 tasks done

Comments

@sibyaugustine
Copy link

Package

@carbon/web-components

Browser

Chrome, Firefox, Safari, Edge

Package version

2.15.0

React version

No response

Description

Extending the web components is not applying CSS correctly. There is an option to extend the web components, but doing so does not render the components properly due to their dependency on Carbon styles. I checked the code, and it appears that some CSS styles depend on the component name. For example, with cds-button, giving it a new name does not apply its base CSS, as it is hardcoded with cds-button.

Reproduction/example

NA

Steps to reproduce

Use the following code , and it does not render the button correctly

import { css, customElement } from 'lit';
import CDSButton from '@carbon/web-components/es/components/button/button';

@customElement('my-button')
class MyButton extends CDSButton {
  // Custom CSS to enforce `field-02` (light) style of the dropdown
  static styles = css`
    ${CDSButton .styles}
    .cds--list-box {
      background-color: white;
    }
  `;
}

Suggested Severity

Severity 2 = User cannot complete task, and/or no workaround within the user experience of a given component.

Application/PAL

No response

Code of Conduct

@sibyaugustine sibyaugustine changed the title [Bug]: [Bug]:Challenges in Extending Web Components: CSS Dependency Issues Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant