Masonry
Tiles of different heights packed into the shortest column, every column ending on the same line. They rise in one after another and glide to their new place when the column count changes. Layout.
Open playgroundAbout
Masonry is a React component in the Layout category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { Masonry } from "@ashutoshswamy/smoui" and set items, columns, gap among its 4 props.
Install
npm i @ashutoshswamy/smouiUsage
import { Masonry } from "@ashutoshswamy/smoui";
<Masonry minWidth={160} items={[{ id: "1", title: "Dawn", ratio: 1.3 }, { id: "2", title: "Harbor", ratio: 0.8 }]} />Props 4
- items
`ratio` is height over width.
{ id; title; ratio; src?; tag? }[]- columns / minWidth
Fixed count, or fit as many as minWidth allows.
numberdefaultauto / 160- gap
Px.
numberdefault10- flush
Stretch each column's tiles slightly (up to 35%) so every column ends on the same line. Off leaves the bottom edge ragged.
booleandefaulttrue
More layout components
- AccordionStacked disclosures. The plus turns to a cross and the answer unfolds on a spring.
- BentoGridMixed-size tiles that rise in as a stagger, lift on hover, with a light that trails the cursor.
- CarouselDrag or flick: slides coast then snap to centre on a spring while the neighbours shrink and dim.
- EmptyStateWhat to show when there is nothing yet. Cards fan out behind an icon, the text rises in and hovering spreads the cards.
- ReorderListA list you reorder by its grip. Neighbours slide aside on a spring, and the keyboard works too: focus the grip, press arrow up or down. Moves are announced.
- SidebarA navigation rail that folds to icons. One accent pill stretches between pages, items group under headings, and the profile row shrinks to an avatar instead of vanishing.