Download the PHP package bugo/flexgrid without Composer
On this page you can find all versions of the php package bugo/flexgrid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bugo/flexgrid
More information about bugo/flexgrid
Files in bugo/flexgrid
Package flexgrid
Short Description Fluent PHP builder for CSS Grid and Flexbox layouts
License MIT
Informations about the package flexgrid
# FlexGrid PHP Builder
Fluent PHP library for generating CSS Grid and Flexbox layouts. Supports named areas, line-based placement, responsive breakpoints, and ready-made presets for common patterns.
Installation
Quick start
GridBuilder
GridBuilder is the main class. All methods return static, so they chain freely.
Columns and rows
Use GridValue helpers to avoid writing CSS strings by hand:
Shorthand methods for repeated tracks:
Gap
Named template areas
Use GridTemplate to define the visual layout as an ASCII-art grid:
For a more compact syntax, pass the area names as strings directly:
Grid items (child elements)
Attach GridItem objects to the builder to generate child selectors alongside the container:
Line-based placement
When named areas are not used, place items by grid line numbers:
Alignment
Grid alignment is split into two enums:
ItemAlignment:align-items,justify-items,align-self,justify-selfContentAlignment:align-content,justify-content
ItemAlignment cases: Start, End, Center, Stretch, Baseline.
ContentAlignment cases: Start, End, Center, Stretch, SpaceBetween, SpaceAround, SpaceEvenly.
Self-alignment on items:
Auto flow and implicit tracks
Responsive breakpoints
responsive(int $minWidth, callable) wraps a variant in @media (min-width: …). media(string $query, callable) accepts any media query string.
Inline styles
toInlineStyle() returns a string suitable for the HTML style attribute — no selector, no braces:
Inline grid
Presets
The Grid facade provides one-liner factory methods for the most common layouts. Every preset returns a GridBuilder you can keep chaining.
Grid::columns()
Equal N-column layout.
Grid::fluid()
Responsive fluid columns using auto-fill. Columns collapse automatically when the container is too narrow.
Grid::sidebar()
Fixed-width sidebar on the left, fluid content on the right.
Grid::centered()
Centers content at a max-width by placing fluid gutters on either side.
Place your content in the middle column:
Grid::holyGrail()
Classic five-area layout: header across the top, sidebar + main content + aside in the middle, footer across the bottom.
Grid::dashboard()
Two-column dashboard with a persistent sidebar and a three-row main area.
Grid::masonry()
Dense auto-flow grid for JavaScript masonry: items are placed greedily to fill gaps. Pair with JS to calculate grid-row-end per item.
GridValue reference
Static helpers for CSS Grid value functions. All return plain strings.
| Call | Output |
|---|---|
GridValue::fr(1) |
"1fr" |
GridValue::fr(2.5) |
"2.5fr" |
GridValue::minmax('200px', '1fr') |
"minmax(200px, 1fr)" |
GridValue::repeat(3, '1fr') |
"repeat(3, 1fr)" |
GridValue::repeat('auto-fill', '1fr') |
"repeat(auto-fill, 1fr)" |
GridValue::fitContent('300px') |
"fit-content(300px)" |
GridValue::Auto->value |
"auto" |
GridValue::MaxContent->value |
"max-content" |
GridValue::MinContent->value |
"min-content" |
GridArea reference
GridItem reference
GridTemplate reference
Flex Examples
Basic row with gap
Flexible cards with wrapping
Toolbar alignment
Responsive direction switch
Direction/wrap helpers and repeated gap calls
Flex Presets
The Flex facade provides one-liner factory methods for common Flexbox layouts.
Flex::row()
Flex::column()
Flex::cards()
Flex::sidebar()
FlexBuilder wrapping helpers
noWrap() is shorthand for wrap(FlexWrap::NoWrap).
Repeated gap(...) calls do not accumulate: the last call replaces the previous value.