package miaou-core
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6
doc/miaou_widgets_layout/Miaou_widgets_layout/Responsive/index.html
Module Miaou_widgets_layout.ResponsiveSource
Responsive layout selection by terminal width.
A small utility for choosing between several layouts based on the current terminal width. The layouts themselves are values of any type — typically a Flex_layout.t or Grid_layout.t, but any type is fine.
Order breakpoints by ascending max_width. pick walks the list and returns the first layout whose max_width is greater than or equal to the current width; if none match (the terminal is wider than every breakpoint), default is returned.
Typical usage:
let layout =
Responsive.pick
~width:size.cols
~default:wide_layout
[
{ max_width = 60; layout = narrow_layout };
{ max_width = 120; layout = medium_layout };
]
in
...A single layout choice keyed by an inclusive maximum width.
Pick the layout matching the current width.
Walks breakpoints in order. Returns the layout of the first entry whose max_width >= width. If no entry matches, returns default.
Tip: order breakpoints from narrowest to widest so the narrow case "wins" first, matching CSS's mobile-first ordering.