https://github.com/ariaminaei/compose-classes
A small utility function to make react components that use css modules to have extensible styles.
https://github.com/ariaminaei/compose-classes
css-modules react
Last synced: 10 months ago
JSON representation
A small utility function to make react components that use css modules to have extensible styles.
- Host: GitHub
- URL: https://github.com/ariaminaei/compose-classes
- Owner: AriaMinaei
- Created: 2018-09-22T19:31:54.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-22T19:40:52.000Z (over 7 years ago)
- Last Synced: 2025-01-23T16:54:56.316Z (12 months ago)
- Topics: css-modules, react
- Language: TypeScript
- Homepage:
- Size: 191 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Compose css classes
A small utility function to make react components that use css modules to have extensible styles.
## Example
```typescript
/**
* Foo.tsx
**/
import * as css from './Foo.css'
import composeClasses from 'compose-css-classes'
type Props = {
css?: Partial
}
export const Foo = (props: Props) => {
const classes = composeClasses(css, props)
return
}
/**
* Bar.tsx
**/
import * as css from './Bar.css'
export const Bar = () => {
// a div will be rendered that has both the container class
// from Foo.css and also the fooContaienr class from Bar.css
return
}
```
```css
/**
* Foo.css
**/
.container {
background: black;
}
/**
* Bar.css
**/
.fooContainer {
color: white;
}
```
Look at `src/index.test.ts` for more examples.