Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 3 months ago
JSON representation
An intimate and comfortable way to layout your components. (NOT MAINTAINED)
- Host: GitHub
- URL: https://github.com/significa/react-snuggle
- Owner: significa
- License: mit
- Created: 2018-08-31T13:35:28.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-27T06:57:48.000Z (almost 2 years ago)
- Last Synced: 2024-07-03T23:07:00.446Z (4 months ago)
- Topics: css, css-grid, masonry, react, tiles
- Language: JavaScript
- Homepage: https://significa.github.io/react-snuggle
- Size: 3.13 MB
- Stars: 261
- Watchers: 3
- Forks: 9
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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](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.