{"id":29483951,"url":"https://github.com/jerbaroo/threepenny-gui-flexbox","last_synced_at":"2026-07-01T00:31:56.822Z","repository":{"id":54371434,"uuid":"83576136","full_name":"jerbaroo/threepenny-gui-flexbox","owner":"jerbaroo","description":"Flexbox layouts for Threepenny-gui","archived":false,"fork":false,"pushed_at":"2021-02-22T19:14:05.000Z","size":40,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-06-04T20:02:40.328Z","etag":null,"topics":["css","flexbox","haskell","layout","threepenny-gui"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jerbaroo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-01T16:28:14.000Z","updated_at":"2021-04-21T21:49:54.000Z","dependencies_parsed_at":"2022-08-13T13:40:41.066Z","dependency_job_id":null,"html_url":"https://github.com/jerbaroo/threepenny-gui-flexbox","commit_stats":null,"previous_names":["barischj/threepenny-gui-flexbox"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jerbaroo/threepenny-gui-flexbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerbaroo%2Fthreepenny-gui-flexbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerbaroo%2Fthreepenny-gui-flexbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerbaroo%2Fthreepenny-gui-flexbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerbaroo%2Fthreepenny-gui-flexbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jerbaroo","download_url":"https://codeload.github.com/jerbaroo/threepenny-gui-flexbox/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerbaroo%2Fthreepenny-gui-flexbox/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34988712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","flexbox","haskell","layout","threepenny-gui"],"created_at":"2025-07-15T04:02:28.796Z","updated_at":"2026-07-01T00:31:56.788Z","avatar_url":"https://github.com/jerbaroo.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Threepenny-gui Flexbox\n\n[![CircleCI](https://circleci.com/gh/barischj/threepenny-gui-flexbox.svg?style=shield)](https://circleci.com/gh/barischj/threepenny-gui-flexbox) [![Hackage](https://img.shields.io/hackage/v/threepenny-gui-flexbox.svg)](http://hackage.haskell.org/package/threepenny-gui-flexbox) [![Stackage Nightly](https://www.stackage.org/package/threepenny-gui-flexbox/badge/nightly?.jpg)](http://stackage.org/nightly/package/threepenny-gui-flexbox) [![Stackage LTS](https://www.stackage.org/package/threepenny-gui-flexbox/badge/lts?.jpg)](http://stackage.org/lts/package/threepenny-gui-flexbox)\n\nFlexbox layouts for Threepenny-gui.\n\nThis library was written following the\nwonderful\n[A Complete Guide to Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox) and\nusing the equally wonderful [Clay](https://hackage.haskell.org/package/clay)\nlibrary as a CSS domain specific language.\n\n![](https://github.com/barischj/threepenny-gui-flexbox/blob/master/example.png)\n\n# Usage\n\n## Properties\n\nUltimately we just want to set Flexbox properties on elements, both parent and\nchild elements. In CSS these properties would look like `flex-grow: 1;`.\n\nWe collect Flexbox properties that apply to the parent element, things like\n`flex-direction`, in a `ParentProps` data type. Flexbox properties that apply to\nchild elements, things like `flex-grow`, are collected in a `ChildProps` data\ntype.\n  \nIf you want `ChildProps` with `flex-grow: 1;` you can just do:\n\n``` Haskell\nflexGrow 1\n```\n\nYou can define multiple properties using `(\u003c\u003e)`:\n\n``` Haskell\norder 1 \u003c\u003e flexGrow 1 \u003c\u003e flexShrink 2\n```\n\nSome properties like `flexGrow` simply take an `Int` but others take a value\nfrom the `Clay` library. Here's an example for `ParentProps`:\n\n``` Haskell\ndisplay Clay.Display.inlineFlex \u003c\u003e flexWrap Clay.Flexbox.nowrap\n```\n\nIf you just want `ParentProps` or `ChildProps` with default values:\n\n``` Haskell\nparentProps :: ParentProps\nchildProps  :: ChildProps\n```\n  \n## Setting Properties\n\nOnce you have your properties defined you'll want to apply them to elements. For\nthis you can use `setFlex` which can be used with Threepenny's reverse function\napplication operator `#`:\n\n``` Haskell\nUI.div # set UI.text \"foo\" # setFlex (flexGrow 1)\n```\n\nNote that `setFlex` will set any properties you don't specify explictly to the\ndefault values from `parentProps` or `childProps`. If that is undesirable (for\ninstance, in case you have already used `setFlex` elsewhere to set several\nproperties and only want to change a few of them), you can instead use\n`modifyFlex`, which leaves unspecified properties unchanged:\n\n``` Haskell\nmyRow = UI.div # setFlex (\n    flexDirection Clay.Flexbox.row\n    \u003c\u003e flexWrap Clay.Flexbox.wrap\n    \u003c\u003e justifyContent Clay.Flexbox.spaceBetween\n    \u003c\u003e alignItems Clay.Common.baseline\n  )\n\n-- Elsewhere:\nmyRow # modifyFlex (alignItems Clay.Common.center)\n```\n\nYou can also convert `ParentProps` or `ChildProps` to a `[(String, String)]`\nwhich\nis\n[how Threepenny expects CSS](http://hackage.haskell.org/package/threepenny-gui/docs/src/Graphics-UI-Threepenny-Core.html#style).\nThis can be done using `toStyle`:\n\n``` Haskell\nUI.div # set UI.style (toStyle $ order 1)\n```\n\n### 'flex'\n\nWe provide a utility function `flex` (and a few variants thereof) which takes\nboth parent and child elements and their respective `ParentProps` and\n`ChildProps`, applies the properties through `setFlex` to the respective\nelements and then returns the parent element with children attached.\n\nHere is a full example, which produces the above image of three orange text\nboxes in ratio 1:2:1. First done without `flex_p` and then with `flex_p`.\n`flex_p` is a variant of `flex` which applies default Flexbox properties to the\nparent element.\n\n``` Haskell\n-- |Example without 'flex_p'.\nexample :: Window -\u003e UI ()\nexample w = void $\n  getBody w # setFlex parentProps #+ [\n      foo # setFlex (flexGrow 1)\n    , foo # setFlex (flexGrow 2)\n    , foo # setFlex (flexGrow 1)\n    ]\n\n-- |Example with 'flex_p'.\nexample' :: Window -\u003e UI ()\nexample' w = void $\n  flex_p (getBody w) [\n      (foo, flexGrow 1)\n    , (foo, flexGrow 2)\n    , (foo, flexGrow 1)\n    ]\n\n-- | Simple coloured 'div'.\nfoo = UI.div # set UI.text \"foo\"\n             # set UI.style [(\"background-color\", \"#F89406\"),\n                             (\"margin\", \"8px\")]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerbaroo%2Fthreepenny-gui-flexbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjerbaroo%2Fthreepenny-gui-flexbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerbaroo%2Fthreepenny-gui-flexbox/lists"}