You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65Lines changed: 65 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ React CSS Modules implement automatic mapping of CSS modules. Every CSS class is
16
16
-[Module Bundler](#module-bundler)
17
17
- [webpack](#webpack)
18
18
- [Browserify](#browserify)
19
+
-[Extending CSS Styles](#extending-css-styles)
19
20
-[Decorator](#decorator)
20
21
-[Options](#options)
21
22
-[`allowMultiple`](#allowmultiple)
@@ -153,6 +154,70 @@ Refer to [webpack-demo](https://github.com/css-modules/webpack-demo) or [react-c
153
154
154
155
Refer to [`css-modulesify`](https://github.com/css-modules/css-modulesify).
155
156
157
+
### Extending CSS Styles
158
+
159
+
Use `styles` property to overwrite the default component styles.
160
+
161
+
Explanation using `Table` component:
162
+
163
+
```js
164
+
importReactfrom'react';
165
+
importCSSModulesfrom'react-css-modules';
166
+
importstylesfrom'./table.css';
167
+
168
+
classTableextendsReact.Component {
169
+
render () {
170
+
return<div styleName='table'>
171
+
<div styleName='row'>
172
+
<div styleName='cell'>A0</div>
173
+
<div styleName='cell'>B0</div>
174
+
</div>
175
+
</div>;
176
+
}
177
+
}
178
+
179
+
exportdefaultCSSModules(Table, styles);
180
+
```
181
+
182
+
In this example, `CSSModules` is used to decorate `Table` component using `./table.css` CSS Modules. When `Table` component is rendered, it will use the properties of the `styles` object to construct `className` values.
183
+
184
+
Using `styles` property you can overwrite the default component `styles` object, e.g.
[Interoperable CSS](https://github.com/css-modules/icss) can [extend other ICSS](https://github.com/css-modules/css-modules#dependencies). Use this feature to extend default styles, e.g.
In this example, `table-custom-styles.css` selectively extends `table.css` (the default styles of `Table` component).
218
+
219
+
Refer to the [`UsingStylesProperty` example](https://github.com/gajus/react-css-modules-examples/tree/master/src/UsingStylesProperty) for an example of a working implementation.
function_classCallCheck(instance,Constructor){if(!(instanceinstanceofConstructor)){thrownewTypeError('Cannot call a class as a function');}}
14
16
15
17
function_inherits(subClass,superClass){if(typeofsuperClass!=='function'&&superClass!==null){thrownewTypeError('Super expression must either be null or a function, not '+typeofsuperClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor: {value: subClass,enumerable: false,writable: true,configurable: true}});if(superClass)Object.setPrototypeOf ? Object.setPrototypeOf(subClass,superClass) : subClass.__proto__=superClass;}
@@ -18,18 +20,20 @@ var _linkClass = require('./linkClass');
0 commit comments