Files
LCUI/docs/en/devtools/css-modules.mdx
CopilotandLiu 437d93d34e docs: add native doc-viewer and widget documentation (#324)
- Add examples/doc-viewer, an LCUI-based documentation viewer with an
  MDX compiler pipeline that converts source MDX files into C/TSX
  page components rendered by lcui build.
- Add zh-CN and en documentation for 5 widgets (anchor, button,
  scrollarea, text, text-input), each with C/TSX/XML example variants
  and widget-fields data.
- Add handbook and overview documentation.

Co-authored-by: Liu <lc-soft@live.cn>
2026-08-05 22:42:19 +08:00

30 lines
726 B
Plaintext

# CSS Modules
CSS Modules create locally scoped CSS classes for TSX components, avoiding naming conflicts and improving maintainability.
## Usage
Create a file with the `.module.css` suffix:
```css title="MyComponent.module.css"
.card {
border: 1px solid #eee;
border-radius: 4px;
}
```
Import it in a `.tsx` file:
```tsx title="MyComponent.tsx"
import styles from "./MyComponent.module.css";
```
Use the `styles` object instead of string class names in JSX:
```diff
- <Widget className="card" />
+ <Widget className={styles.card} />
```
During compilation, `@lcui/cli` converts `.module.css` into C identifier bindings, automatically generating unique C constant names for class names to avoid global conflicts.