mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
- 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>
30 lines
726 B
Plaintext
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.
|