CSS 模块

CSS 模块

¥CSS Modules

本文档仅在使用 Classic Remix 编译器 时适用。如果你使用的是 Remix Vite,请使用 Vite 内置 CSS 模块 支持。

要使用内置的 CSS 模块支持,首先确保你已在应用中设置了 CSS 打包

¥To use the built-in CSS Modules support, first ensure you've set up CSS bundling in your application.

然后,你可以通过 .module.css 文件名约定选择使用 CSS 模块。例如:

¥You can then opt into CSS Modules via the .module.css file name convention. For example:

.root {
  border: solid 1px;
  background: white;
  color: #454545;
}
import styles from "./styles.module.css";

export const Button = React.forwardRef(
  ({ children, ...props }, ref) => {
    return (
      <button
        {...props}
        ref={ref}
        className={styles.root}
      />
    );
  }
);
Button.displayName = "Button";
Remix v2.17 中文网 - 粤ICP备13048890号