-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
🐛 bugSomething isn't workingSomething isn't working
Description
Current Behavior
When dynamically setting the className prop on a Baloise React component (e.g., BalCard), the component loses its default styles and only applies the custom classes. This happens when the class is updated after an event (e.g., button click). The expected behavior is that custom classes should be merged with the component’s default classes, not replace them.
import "@baloise/ds-styles/css/all.css";
import "./styles.css";
import { BalCard, BalButton } from "@baloise/ds-react";
import { useState } from "react";
export default function App() {
const [customClassNames, setCustomClassNames] = useState<string>("bg-green");
const updateCustomClassNames = () => {
setCustomClassNames("bg-red p-large");
};
return (
<div className="App">
<div className="container pt-large">
<BalCard className={customClassNames}>hellooo</BalCard>
<BalButton
onClick={updateCustomClassNames}
className={customClassNames}
>
Text button
</BalButton>
</div>
</div>
);
}Expected Behavior
Custom classes should be merged with the component’s default classes. For example, after updating the class, should still have its rounded border and default layout, in addition to the new background color and padding.
Steps to Reproduce
- Render a Baloise component (e.g., ) with a custom className.
- Update the className dynamically (e.g., after clicking a button).
- Observe that the component loses its default styles (e.g., rounded borders, layout).
Version
19.8.2
Browsers
Chrome
Device
Desktop
Code Reproduction URL
https://codesandbox.io/p/sandbox/c53gsl
Additional Information
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
🐛 bugSomething isn't workingSomething isn't working