Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/significa/react-snuggle

An intimate and comfortable way to layout your components. (NOT MAINTAINED)
https://github.com/significa/react-snuggle

css css-grid masonry react tiles

Last synced: about 2 months ago
JSON representation

An intimate and comfortable way to layout your components. (NOT MAINTAINED)

Awesome Lists containing this project

README

        


React Snuggle

minzip
Lightweight React component to create css-based masonry-like layouts.
Snuggle all your components really tight 🛌

[Demo](https://significa.github.io/react-snuggle/)

Like a loving couple snuggling in bed, `react-snuggle` basically tries to make everything very intimate and comfortable by filling every space available (using CSS grid and a bit of javascript).

## Features

- **🤟 Responsive:** It works on all size screens;
- **🤙 Customizable:** Easily change how your elements should snuggle;
- **🤝 Use your favorite library:** CSS-in-JS, css modules, plain css, whatever. Feel free to use whatever you want;

#### Install:

```sh
yarn add react-snuggle
```

#### Usage:

```jsx
import Snuggle from 'react-snuggle'

const List = () => (

Item

Item

...

)
```

### Options

| Name | Type | Default |
| ----------- | --------------- | --------- |
| item | _React.Element_ | `

` |
| container | _React.Element_ | `
` |
| rowGap | _Number_ | 20 |
| columnWidth | _Number_ | 250 |

### Methods

**resize**
Recalculate all spaces available and snuggle each element z its space, it is helpful for lazing loading, resize listeners, and loading images.

Example:

```jsx
const Component = () => {
const snuggleRef = useRef()

const onLoad = () => {
if (snuggleRef.current) {
snuggleRef.current.resize()
}
}

return (



)
}
```

### Todo

- [ ] Span options (element fill two columns or more);
- [ ] Filter elements;
- [ ] Missing tests;
- [ ] ...

### License

[MIT](https://github.com/Significa/react-snuggle/blob/master/LICENSE)

### Kudos

@andybarefoot
[Masonry style layout with CSS Grid](https://medium.com/@andybarefoot/a-masonry-style-layout-using-css-grid-8c663d355ebb)

---

Significa Lda

[Significa](https://significa.pt/) is an Oporto based digital studio founded in late 2013. Despite being specialised in Interaction Design and Brand Development, we believe that good design thinking can answer almost any question and solve most problems. We aim to provide meaningful design solutions to achieve the best user engagement possible in any situation.