CSS Grid container with column, row, gap and auto-flow control.
All layout attributes accept either a plain value (backward compatible) or a
responsive map like %{base: 1, md: 3} for per-breakpoint control.
Examples
<%!-- 3-column grid with gap --%>
<.grid cols={3} gap={4}>
<.card>A</.card>
<.card>B</.card>
<.card>C</.card>
</.grid>
<%!-- Responsive columns: 1 on mobile, 2 from md, 4 from lg --%>
<.grid cols={%{base: 1, md: 2, lg: 4}} gap={%{base: 2, md: 4}}>
<.card>A</.card>
<.card>B</.card>
<.card>C</.card>
<.card>D</.card>
</.grid>
<%!-- 12-column layout grid --%>
<.grid cols={12} gap={4}>
<div class="col-span-8">Main</div>
<div class="col-span-4">Sidebar</div>
</.grid>
<%!-- Dense auto-flow --%>
<.grid cols={4} gap={3} flow={:dense}>
<%= for item <- @items do %>
<.card>{item.title}</.card>
<% end %>
</.grid>
Summary
Functions
Renders a CSS Grid container.
Functions
Renders a CSS Grid container.
Attributes
cols(:any) - Number of columns (1–12) →grid-cols-N. Accepts integer or responsive map. Defaults tonil.rows(:any) - Number of rows (1–6) →grid-rows-N. Accepts integer or responsive map. Defaults tonil.gap(:any) - Uniform gap (0–12) →gap-N. Accepts integer or responsive map. Defaults tonil.gap_x(:any) - Horizontal gap →gap-x-N. Accepts integer or responsive map. Defaults tonil.gap_y(:any) - Vertical gap →gap-y-N. Accepts integer or responsive map. Defaults tonil.flow(:any) - Grid auto-flow direction. Accepts atom or responsive map. Defaults tonil.align(:any) - align-items value. Accepts atom or responsive map. Defaults tonil.justify(:any) - justify-items value. Accepts atom or responsive map. Defaults tonil.class(:string) - Additional CSS classes merged via cn/1. Defaults tonil.- Global attributes are accepted. HTML attributes forwarded to the root element.
Slots
inner_block(required) - Grid children.