# KptGrid / KptCol / KptFlex (@konce-pt/angular/grid) Angular ergonomics over the `@konce-pt/grid` stylesheet. The directives set nothing but inline custom properties - they neither add nor remove classes, and the layout is computed by the native CSS engine. Import: `import { KptGrid, KptCol, KptFlex } from '@konce-pt/angular/grid';` Shorthand: `import { KPT_GRID_IMPORTS } from '@konce-pt/angular/grid';` -> `imports: [...KPT_GRID_IMPORTS]` Requires the stylesheet: `import '@konce-pt/grid';` (Angular CLI: `angular.json` -> `styles[]`). ## Breakpoints (mobile-first) `sm` >= 640px, `md` >= 768px, `lg` >= 1024px, `xl` >= 1280px, `2xl` >= 1536px. A value applies from its breakpoint upward until the next one overrides it: `[kptCol]="12" [kptColLg]="5"` gives 12 on mobile, `sm` and `md`, and 5 only from `lg` up. ## KptGrid - selector `[kptGrid]`, `kpt-grid` Host class: `kpt-grid`. - `columns`: number - the column count (12 by default, from CSS). Variants: `columnsSm`, `columnsMd`, `columnsLg`, `columnsXl`, `columns2xl`. - `gap`: string - the gap on both axes, e.g. `'1.5rem'`, `'var(--kpt-space-6)'`. - `gapX`, `gapY`: string - the gap on one axis, overriding `gap`. - `container`: boolean - container query mode (see below). ## KptCol - selector `[kptCol]`, `[kptColSm]` ... `[kptColSelf]` - `kptCol`: number | string - the span, the mobile-first base. - `kptColSm`, `kptColMd`, `kptColLg`, `kptColXl`, `kptCol2xl` - per-breakpoint overrides. - `kptColStart`: number - the grid line the column starts at (1-based); this is how offsets are done. - `kptColOrder`: number - the visual order. It does not change the DOM: screen readers and keyboard navigation follow the DOM, so do not use it to move interactive content around. - `kptColSelf`: string - `align-self` (`start`, `end`, `center`, `stretch`, `baseline`). ## KptFlex - selector `[kptFlex]` Host class: `kpt-flex`. The same variables and breakpoints as the grid, in one dimension. - `direction`: 'row' | 'row-reverse' | 'column' | 'column-reverse' (+ `directionMd`, `directionLg`) - `wrap`: 'wrap' | 'nowrap' | 'wrap-reverse' - `justify`, `align` (+ `justifyMd`, `alignMd`): `start` | `end` | `center` | `stretch` | `baseline` | `space-between` | `space-around` | `space-evenly` - `gap`, `gapX`, `gapY`: string - `container`: boolean Values with no matching input are supplied with utility classes from `@konce-pt/grid`: `kpt-grow-1`, `kpt-shrink-0`, `kpt-order-first`, `kpt-self-end`, `kpt-gap-6`. ## Container mode (`container`) The children's spans react to the width of THIS grid instead of the window - a card in a narrow sidebar lays itself out in a single column even though the viewport is wide. A CSS limitation, not a package one: `@container` queries the nearest ancestor container, so an element cannot query its own. What is responsive are the child's variables (span, start, order, self); the column count and the gaps still follow the viewport. ## Examples
Card
Card
Card
Sidebar
Content
start 4, span 6
second in the DOM
first in the DOM
Left Right
## Custom properties The grid: `--kpt-grid-columns`, `--kpt-gap`, `--kpt-gap-x`, `--kpt-gap-y`, `--kpt-justify`, `--kpt-align`, `--kpt-content`, `--kpt-flex-direction`, `--kpt-flex-wrap`. The child: `--kpt-col`, `--kpt-col-start`, `--kpt-order`, `--kpt-self`, `--kpt-flex`, `--kpt-grow`, `--kpt-shrink`. Each one has per-breakpoint variants: `--kpt-col` -> `--kpt-col-md`.