DioxusLabs / DioxusLabs/dioxus
CSS modules can't handle prefixes
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
**Problem**
If I have a CSS module like so:
```css
.sidebar {
background: red;
padding: 20px;
}
.sidebarButton {
background: blue;
}
```
then the `Classes::sidebar_button` class doesn't actually work. The reason is that because it has the same `sidebar` prefix as an already mangled class, it mangles the prefix on accident instead of the entire class.
```css
.sidebarfb811ee670c8c644 {
background: red;
padding: 20px
}
.sidebarfb811ee670c8c644Button {
background: #00f
}
```
in the DOM it's correct, but due to the mismatch can't find the class:
```html
```
**Steps To Reproduce**
Steps to reproduce the behavior:
```rust
css_module!(Classes = "/assets/sidebar.css");
#[component]
pub fn Sidebar() -> Element {
rsx! {
div { class: "{Classes::sidebar}",
button { class: "{Classes::sidebar_button}", "Hi" }
}
}
}
```
**Expected behavior**
The button should be blue.
**Screenshots**

**Environment:**
- Dioxus version: https://github.com/DioxusLabs/dioxus/commit/1001d78c7fbf717df50e9209513b03676e03635c
- Rust version: 1.86
- OS info: Windows 11
- App platform: desktop
**Questionnaire**
I'm interested in fixing this myself, if no one else fixes it.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.