¥CSS Modules
要使用内置的 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";