The DlGrid block component places named slots into a responsive grid.
Features
- #️⃣ column and row setup
- 🏷️ one cell per slot, with optional column and row placement
- 📐 alignment and justification of the content inside each cell
- 🧩 theme-friendly visual adjustments
- ⚠️ extensive error reporter
Usage
Use ::dl-grid as a block component defining the grid with grid-cols and, when you need a fixed row count, grid-rows.
Each cell is a named slot. The name is #item-{n}, starting at 1. Slots are ordered by that number, so #item-10 stays after #item-2. Append a position to place the cell on the grid. The slot body is normal Markdown and can include other content components.
Result:
Grid item 1
Grid item 2
Grid item 3
Class generation
grid-cols and grid-rows accept lg:grid-cols-1 through lg:grid-cols-12, and the same range for rows. Other values are not generated.
If you need grid classes at another breakpoint, such as md:grid-cols-3, add them in your CSS (for example with @apply) so Tailwind can detect them and include in the final bundle.
With custom item content alignment
Each item is a vertical flex container that fills its cell.
| align / justify | justify class applied | align class applied |
|---|---|---|
start |
|
|
center |
|
|
end |
|
|
Both align and justify accept start, center, and end. Like this:
With custom item positions
The position is part of the slot name, after |. The numbers are grid lines: the start line, then the end line. Two numbers place the item across columns. Four numbers place it across columns and then rows.
| slot | placement |
|---|---|
#item-1|1-3 | Columns only, from line 1 to line 3. |
#item-1|1-3-1-2 | Columns from line 1 to line 3, and rows from line 1 to 2. |
Placement applies from the large breakpoint. Smaller screens keep a single column.
Result:
Grid item 1
Grid item 2
Props
Here are the properties you can use with the DlGrid component. Each property should be set on an individual component instance; they do not affect the global configuration. More about defining properties in MDC components you can read here.
| name | type | default | description |
|---|---|---|---|
lazy | boolean | true | Whether to lazy load the component. |
gridCols | '{breakpoint}:grid-cols-${n}' | 'lg:grid-cols-2' | Grid columns at the large breakpoint. Smaller screens use a single column. |
gridRows | '{breakpoint}:grid-rows-${n}' | undefined | Grid rows at the large breakpoint. Omit it and the row count follows the items. |
align | 'start' | 'center' | 'end' | 'start' | Cross-axis alignment of the content inside each item. |
justify | 'start' | 'center' | 'end' | 'start' | Main-axis justification of the content inside each item. |
Slots
| name | description |
|---|---|
#item-{n}|{c-c}-{r-r}? | One grid cell, |
ui | Dedicated slot for defining the component’s |
Styling
Styling from Markdown
Every DocLayer component can be styled directly within your Markdown file using dedicated slot/property configuration. This allows you to customize the appearance of the component's markup elements without modifying global styles. More about components styling you can read here.
Below you'll find the default set of Tailwind classes for the component's dedicated markup elements. base is the grid, item is each cell.
