An open API service indexing awesome lists of open source software.

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.

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.