{"componentChunkName":"component---src-templates-blog-js","path":"/blog/how-to-use-tailwind-css-flex/","result":{"data":{"site":{"siteMetadata":{"title":"Resources to help developers | Contrast | Devwares"}},"mdx":{"id":"764e2b4e-8e45-5f20-82a6-20a9b92a9044","excerpt":"Tailwind flex Building responsive and flexible user interfaces is crucial in frontend development. Flexbox is an essential tool for this purpose, and Tailwind…","body":"var _excluded = [\"components\"];\nfunction _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }\nfunction _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }\nfunction _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }\n/* @jsxRuntime classic */\n/* @jsx mdx */\n\nvar _frontmatter = {\n  \"title\": \"How to use Tailwind CSS Flex\",\n  \"lastUpdated\": \"8 May 2024\",\n  \"date\": \"2021-01-10T02:16:04+01:00\",\n  \"metaTitle\": \"How to use Tailwind Flex\",\n  \"metaDescription\": \"Flexbox is a powerful CSS layout module, and when combined with Tailwind CSS, it becomes even more convenient and efficient. By utilizing Tailwind CSS flex utilities, you can easily create flexible and responsive layouts for your projects.\",\n  \"type\": \"blog\",\n  \"author\": \"Emmanuel Chinonso\",\n  \"role\": \"Technical Writer/Web developer\",\n  \"authorImage\": \"/blog/author/author_emmanuel.jpg\",\n  \"image\": \"./_/images/how-to-use-tailwind-css-flex.png\",\n  \"tags\": [\"tailwindcss\", \"css\", \"Programming\"],\n  \"previousTitle\": \"How to Install Tailwind CSS in Vue.js\",\n  \"previousPath\": \"how-to-install-tailwind-css-in-vuejs\",\n  \"nextTitle\": \"How to use Tailwind CSS in HTML\",\n  \"nextPath\": \"how-to-use-tailwind-css-in-HTML\",\n  \"blogtype\": \"tailwindcss\",\n  \"canonicalUrl\": \"https://windframe.dev/blog/how-to-use-tailwind-css-flex\"\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n    props = _objectWithoutProperties(_ref, _excluded);\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"h1\", null, \"Tailwind flex\"), mdx(\"p\", null, \"Building responsive and flexible user interfaces is crucial in frontend development. Flexbox is an essential tool for this purpose, and Tailwind CSS flex simplifies its usage, allowing you to create complex layouts effortlessly.\"), mdx(\"h2\", null, \"Table of content\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"What is Flexbox ?\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"How to Use Tailwind CSS Flex\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Flex Containers\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Flex Items\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Modifying Flex Direction\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Controlling Flex Item Alignment\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Adjusting Flex Item Sizing\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Wrapping Flex Items\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Conclusion\")), mdx(\"h2\", null, \"What is Flexbox ?\"), mdx(\"p\", null, \"Flexbox, short for flexible box, is a layout mode in CSS that makes it easy to create flexible and responsive layouts. It consists of two main components: flex containers and flex items. It's perfect for building navigation bars, footers, and other components that need to adapt to different screen sizes.\"), mdx(\"h2\", null, \"How to Use Tailwind CSS Flex\"), mdx(\"p\", null, \"Using \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://windframe.dev/tailwind/classes/tailwind-flex\"\n  }, \"Tailwind CSS flex\"), \" is incredibly easy. Here are the basic classes you need to get started:\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"flex\"), \" - enables flexbox layout\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://windframe.dev/classes/flex/flex-wrap\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"flex-wrap\")), \" - wraps flex items to a new line\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"justify-center\"), \" - centers flex items horizontally\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"justify-space-between\"), \" - distributes flex items evenly\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"items-center\"), \" - centers flex items vertically\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"self-center\"), \" - centers a single flex item\")), mdx(\"h2\", null, \"Flex Containers\"), mdx(\"p\", null, \"A flex container holds multiple flex items and defines the main axis and cross axis of the flex layout. To create a Tailwind flex container, simply apply the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://windframe.dev/classes/flex/flex-1\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"flex\")), \" class to an element. By default, the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-direction\"), \" property is set to \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"row\"), \", which means the flex items will be arranged horizontally.\"), mdx(\"p\", null, \"Here's an example of creating a flex container:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"flex\\\">\\n  <!-- Flex items go here -->\\n</div>\\n\")), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"rounded-t-lg flex gap-2 text-white text-center bg-indigo-100 font-bold m-10\"\n  }, mdx(\"div\", {\n    className: \" bg-indigo-500 rounded my-5 mx-3 py-3 px-3\"\n  }, \"A\"), mdx(\"div\", {\n    className: \" bg-indigo-500 rounded my-5 mx-3 py-3 px-3\"\n  }, \"B\"), mdx(\"div\", {\n    className: \" bg-indigo-500 rounded my-5 mx-3 py-3 px-3\"\n  }, \"C\")), mdx(\"h2\", null, \"Flex Items\"), mdx(\"p\", null, \"Flex items are the individual elements within a flex container. They can be manipulated and positioned within the container using flex utilities. By default, flex items will be arranged in the order they appear in the HTML markup.\"), mdx(\"p\", null, \"Here's an example of creating flex items within a flex container:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"flex\\\">\\n  <div class=\\\"flex-item\\\">Item 1</div>\\n  <div class=\\\"flex-item\\\">Item 2</div>\\n  <div class=\\\"flex-item\\\">Item 3</div>\\n</div>\\n\")), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"rounded-t-lg flex gap-2 text-white text-center justify-center items-center bg-indigo-100 font-bold m-10\"\n  }, mdx(\"div\", {\n    className: \"flex-1 bg-indigo-500 rounded my-3 mx-3\"\n  }, \"Item 1\"), mdx(\"div\", {\n    className: \"flex-1 bg-indigo-500 rounded my-3 mx-3 \"\n  }, \"Item 2\"), mdx(\"div\", {\n    className: \"flex-1 bg-indigo-500 rounded my-3 mx-3\"\n  }, \"Item 3\")), mdx(\"h2\", null, \"Modifying Flex Direction\"), mdx(\"p\", null, \"The \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://windframe.dev/tailwind/classes/tailwind-flex-direction\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"flex-direction\")), \" utility allows you to specify the direction in which flex items are arranged within the flex container. By default, the direction is set to \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"row\"), \", which arranges the items horizontally. However, you can easily change it to \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"column\"), \" to arrange the items vertically.\"), mdx(\"h2\", null, \"Tailwind flex row\"), mdx(\"p\", null, \"You can use the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://windframe.dev/classes/flex-direction/flex-row\"\n  }, \"Tailwind flex row\"), \" class to position flex items horizontally in the same direction as the text. It is one of the classes of Tailwind flex-direction utilities.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"flex flex-row ...\\\">\\n  <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n    A\\n  </div>\\n  <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n    B\\n  </div>\\n  <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n    C\\n  </div>\\n</div>\\n\")), mdx(\"p\", null, \"The code above represents the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-row\"), \" class\"), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"relative rounded-t-xl overflow-auto p-8 bg-indigo-100\"\n  }, mdx(\"div\", {\n    className: \"flex flex-row gap-4 font-mono text-white font-extrabold leading-6\"\n  }, mdx(\"div\", {\n    className: \"w-14 h-14 rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"A\"), mdx(\"div\", {\n    className: \"w-14 h-14 rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"B\"), mdx(\"div\", {\n    className: \"w-14 h-14 rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"C\"))), mdx(\"h2\", null, \"Tailwind Flex row reverse\"), mdx(\"p\", null, \"This \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://windframe.dev/classes/flex-direction/flex-row-reverse\"\n  }, \"Tailwind flex row reverses\"), \" class positions the flex item horizontally in the opposite direction of the text:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"\\n  <div class=\\\"flex flex-row-reverse.....\\\">\\n    <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n      1\\n    </div>\\n    <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n      2\\n    </div>\\n    <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n      3\\n    </div>\\n    <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n      4\\n    </div>\\n  </div>\\n</div>\\n\")), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"relative rounded-xl overflow-auto p-8\"\n  }, mdx(\"div\", {\n    className: \"flex flex-row-reverse font-extrabold text-white text-center gap-3\"\n  }, mdx(\"div\", {\n    className: \"bg-indigo-500 w-14 h-14 rounded-lg flex items-center justify-center shadow-lg\"\n  }, \"1\"), mdx(\"div\", {\n    className: \"bg-indigo-500 w-14 h-14 rounded-lg flex items-center justify-center shadow-lg\"\n  }, \"2\"), mdx(\"div\", {\n    className: \"bg-indigo-500 w-14 h-14 rounded-lg flex items-center justify-center shadow-lg\"\n  }, \"3\"), mdx(\"div\", {\n    className: \"bg-indigo-500 w-14 h-14 rounded-lg flex items-center justify-center shadow-lg\"\n  }, \"4\"))), mdx(\"h2\", null, \"Tailwind Flex column\"), mdx(\"p\", null, \"The \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://windframe.dev/classes/flex-direction/flex-col\"\n  }, \"tailwind flex column\"), \" is one of the flex-direction classes and its function is to position items vertically on the screen. You can see an example of the code below and its resulting image.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"  <div class=\\\"flex flex-col ...\\\">\\n    <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n      A\\n    </div>\\n    <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n      B\\n    </div>\\n    <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n      C\\n    </div>\\n  </div>\\n</div>\\n\")), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"relative rounded-t-xl overflow-auto p-8 bg-indigo-100\"\n  }, mdx(\"div\", {\n    className: \"flex flex-col gap-4 font-mono text-white font-extrabold leading-6\"\n  }, mdx(\"div\", {\n    className: \"w-14 h-14 rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"A\"), mdx(\"div\", {\n    className: \"w-14 h-14 rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"B\"), mdx(\"div\", {\n    className: \"w-14 h-14 rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"C\"))), mdx(\"h2\", null, \"Tailwind Flex Column Reverse\"), mdx(\"p\", null, \"Another important property of the Tailwind flex column is the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://windframe.dev/classes/flex-direction/flex-col-reverse\"\n  }, \"Tailwind flex column reverse\"), \". This uses the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".flex-col-reverse\"), \" class to position flex items vertically in the opposite direction on the screen.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"flex flex-col-reverse...\\\">\\n  <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n    A\\n  </div>\\n  <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n    B\\n  </div>\\n  <div class=\\\"flex items-center justify-center bg-indigo-500...\\\">\\n    C\\n  </div>\\n</div>\\n\")), mdx(\"p\", null, \"The code abvove shows the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-col-reverse\"), \" class.\"), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"relative rounded-t-xl overflow-auto p-8 bg-indigo-100\"\n  }, mdx(\"div\", {\n    className: \"flex flex-col-reverse gap-4 font-mono text-white font-extrabold leading-6\"\n  }, mdx(\"div\", {\n    className: \"w-14 h-14 rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"A\"), mdx(\"div\", {\n    className: \"w-14 h-14 rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"B\"), mdx(\"div\", {\n    className: \"w-14 h-14 rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"C\"))), mdx(\"h2\", null, \"Controlling Flex Item Alignment\"), mdx(\"p\", null, \"Tailwind CSS provides utilities to control the alignment of flex items along both the main axis and the cross axis. The \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"justify-*\"), \" utilities control the alignment along the main axis, while the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"items-*\"), \" utilities control the alignment along the cross axis.\"), mdx(\"p\", null, \"Here's an example of controlling flex item alignment:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"flex justify-center items-center\\\">\\n  <!-- Flex items are centered both horizontally and vertically -->\\n</div>\\n\")), mdx(\"h2\", null, \"Adjusting Flex Item Sizing\"), mdx(\"p\", null, \"You can adjust the sizing of flex items using utilities such as \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-grow\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-shrink\"), \", and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-auto\"), \". These utilities allow you to control how flex items grow, shrink, or automatically adjust their size to fill the available space. These are the classes.\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://windframe.dev/classes/flex/flex-auto\"\n  }, \"Tailwind Flex Auto\")), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://windframe.dev/classes/flex/flex-grow\"\n  }, \"Tailwind Flex Grow\")), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://windframe.dev/classes/flex/flex-shrink\"\n  }, \"Tailwind Flex Shrink\"))), mdx(\"h2\", null, \"Tailwind Flex-Auto\"), mdx(\"p\", null, \"The Tailwind \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-auto\"), \" class shows how much an item will grow relative to the content of the flexible items. Here, the initial size is ignored, and it grows and shrinks according to its need.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"flex...\\\">\\n  <div class=\\\"flex-none...\\\">A</div>\\n  <div class=\\\"flex-auto...\\\">\\n    B\\n  </div>\\n  <div class=\\\"flex-auto...\\\">C</div>\\n</div>\\n\")), mdx(\"p\", null, \"In the code above, we demonstrated how to use the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-auto\"), \" class in Tailwind CSS.\"), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"relative rounded-t-xl overflow-auto p-8 bg-indigo-100\"\n  }, mdx(\"div\", {\n    className: \"mt-2 flex gap-4 text-white text-sm font-bold font-mono leading-6 rounded-lg\"\n  }, mdx(\"div\", {\n    className: \"p-4 flex-none w-14 h-14 rounded-lg flex items-center justify-center bg-indigo-300 shadow-lg\"\n  }, \"A\"), mdx(\"div\", {\n    className: \"p-4 flex-auto w-64 rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"B\"), mdx(\"div\", {\n    className: \"p-4 flex-auto w-32 rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"C\"))), mdx(\"h2\", null, \"Tailwind Flex Grow\"), mdx(\"p\", null, \"The \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://windframe.dev/tailwind/classes/tailwind-flex-grow\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"flex-grow\")), \" utility controls the ability of a flex item to grow and take up additional space if available. By default, it is set to 0, meaning the flex item will not grow. You can adjust the value to control the growability of a flex item.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"flex...\\\">\\n  <div class=\\\"flex-none... \\\">\\n    A\\n  </div>\\n  <div class=\\\"flex-grow...\\\">B</div>\\n  <div class=\\\"flex-none...\\\">\\n    C\\n  </div>\\n</div>\\n\")), mdx(\"p\", null, \"The code above shows \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-grow\"), \" class.\"), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"relative rounded-t-xl overflow-auto p-8 bg-indigo-100\"\n  }, mdx(\"div\", {\n    className: \"flex gap-4 text-white  font-extrabold font-mono leading-6 rounded-lg\"\n  }, mdx(\"div\", {\n    className: \"w-14 h-14 flex-none rounded-lg flex items-center justify-center bg-indigo-300 \"\n  }, \"A\"), mdx(\"div\", {\n    className: \"p-4 rounded-lg flex-grow items-center justify-center bg-indigo-500 shadow-lg text-center\"\n  }, \"B\"), mdx(\"div\", {\n    className: \"p-4 w-14 h-14 flex-none rounded-lg flex items-center justify-center bg-indigo-400\"\n  }, \"C\"))), mdx(\"h2\", null, \"Tailwind Flex Shrink\"), mdx(\"p\", null, \"The \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://windframe.dev/tailwind/classes/tailwind-flex-shrink\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"flex-shrink\")), \" utility controls the ability of a flex item to shrink if necessary. By default, it is set to 1, meaning the flex item can shrink to fit the available space.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"flex...\\\">\\n  <div class=\\\"flex...\\\">A</div>\\n  <div class=\\\"flex-shrink...\\\">B</div>\\n  <div class=\\\"flex...\\\">C</div>\\n</div>\\n\")), mdx(\"p\", null, \"The code above shows \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-shrink\"), \" class.\"), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"relative rounded-t-xl overflow-auto p-8 bg-indigo-100\"\n  }, mdx(\"div\", {\n    className: \"flex gap-4 text-white  font-extrabold font-mono leading-6 rounded-lg\"\n  }, mdx(\"div\", {\n    className: \"w-14 h-14 flex-none rounded-lg flex items-center justify-center bg-indigo-300 \"\n  }, \"A\"), mdx(\"div\", {\n    className: \"p-4 flex-shrink rounded-lg text-center items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"B\"), mdx(\"div\", {\n    className: \"p-4 w-14 h-14 flex-shrink rounded-lg flex items-center justify-center bg-indigo-400\"\n  }, \"C\"))), mdx(\"h2\", null, \"Wrapping Flex Items\"), mdx(\"p\", null, \"By default, flex items will try to fit in a single line within the flex container. However, you can enable wrapping using the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://windframe.dev/tailwind/classes/tailwind-flex-wrap\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"flex-wrap\")), \" utility. These are the classes used to achieve this\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://windframe.dev/classes/flex/flex-wrap\"\n  }, \"Tailwind Flex Wrap\")), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Tailwind Flex Wrap-reverse\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://windframe.dev/classes/flex/flex-nonwrap\"\n  }, \"Tailwind Flex No-Wrap\"))), mdx(\"h2\", null, \"Tailwind Flex Wrap\"), mdx(\"p\", null, \"Tailwind Flex Wrap class makes it possible for flex items to wrap onto multiple lines if needed, instead of being forced into a single line.\"), mdx(\"p\", null, \"Here's an example of wrapping flex items:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"flex flex-wrap\\\">\\n  <!-- Flex items wrap onto multiple lines if needed -->\\n</div>\\n\")), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"\\n  <div\\n    class=\\\"flex flex-wrap...\\\"\\n  >\\n    <div class=\\\"flex...\\\">\\n      A\\n    </div>\\n    <div class=\\\"flex...\\\">\\n      B\\n    </div>\\n    <div class=\\\"flex...\\\">\\n      C\\n    </div>\\n  </div>\\n</div>\\n\")), mdx(\"p\", null, \"The code above represents the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-wrap\"), \" class.\"), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"relative rounded-t-xl overflow-auto p-8 bg-indigo-100\"\n  }, mdx(\"div\", {\n    className: \"flex flex-wrap gap-4 font-mono text-white text-sm font-extrabold leading-6 rounded-lg\"\n  }, mdx(\"div\", {\n    className: \"p-4 w-full rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"A\"), mdx(\"div\", {\n    className: \"p-4 w-full rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"B\"), mdx(\"div\", {\n    className: \"p-4 w-full rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"C\"))), mdx(\"h2\", null, \"Tailwind Flex Wrap Reverse\"), mdx(\"p\", null, \"Flex wrap reverse is a utility class that reverses the wrap flex items.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"\\n  <div\\n    class=\\\"flex flex-wrap-reverse...\\\"\\n  >\\n    <div class=\\\"flex...\\\">\\n      A\\n    </div>\\n    <div class=\\\"flex...\\\">\\n      B\\n    </div>\\n    <div class=\\\"flex...\\\">\\n      C\\n    </div>\\n  </div>\\n</div>\\n\")), mdx(\"p\", null, \"The code above represents the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"flex-wrap-reverse\"), \" class.\"), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"relative rounded-t-xl overflow-auto p-8 bg-indigo-100\"\n  }, mdx(\"div\", {\n    className: \"flex flex-wrap-reverse gap-4 font-mono text-white text-sm font-extrabold leading-6 rounded-lg\"\n  }, mdx(\"div\", {\n    className: \"p-4 w-full rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"A\"), mdx(\"div\", {\n    className: \"p-4 w-full rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"B\"), mdx(\"div\", {\n    className: \"p-4 w-full rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"C\"))), mdx(\"h2\", null, \"Tailwind CSS Flex-no-wrap\"), mdx(\"p\", null, \"This Tailwind class doesn't allow flex items to wrap. This makes these flex items overflow the container. It doesn't regulate flex items to a box.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"flex flex-nowrap...\\\">\\n  <div class=\\\"flex...\\\">\\n    A\\n  </div>\\n  <div class=\\\"flex...\\\">\\n    B\\n  </div>\\n  <div class=\\\"flex...\\\">\\n    C\\n  </div>\\n</div>\\n\")), mdx(\"p\", null, \"The code above represents the flex-nonwrap class.\"), mdx(\"h3\", null, \"Preview\"), mdx(\"div\", {\n    className: \"relative rounded-t-xl overflow-auto p-8 bg-indigo-100\"\n  }, mdx(\"div\", {\n    className: \"flex flex-nowrap gap-4 font-mono text-white text-sm font-bold leading-6 rounded-lg\"\n  }, mdx(\"div\", {\n    className: \"p-4 w-full rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"A\"), mdx(\"div\", {\n    className: \"p-4 w-full rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"B\"), mdx(\"div\", {\n    className: \"p-4 w-full rounded-lg flex items-center justify-center bg-indigo-500 shadow-lg\"\n  }, \"C\"))), mdx(\"h2\", null, \"Conclusion\"), mdx(\"p\", null, \"Tailwind css Flex makes it easy to create flexible and responsive layouts with just a few classes. By mastering the basics of flexbox and using Tailwind CSS Flex, you can build complex user interfaces with ease.\"));\n}\n;\nMDXContent.isMDXComponent = true;","frontmatter":{"title":"How to use Tailwind CSS Flex","date":"January 10, 2021","image":{"childImageSharp":{"fluid":{"base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAACR0lEQVQoz2O4e+30m+e3507v37B2xc9vH/7//z65r+PA/j2rbt12WLHRc+0WjzUg5Llmi+uqzWGbdt149/7i6zennr10X7OF4f2D8/8/PpzW3XBk3+b/fz/9//9/+tQJB/bvBjLaTpy1W77ea+1WiGa31ZsD1m+//Prtm+8/Tjx/6bRyI8ObN89+fH07fVJXd2fL9cvn/v/7AmTv27MdqPnJ5y8BG7a7rt7sCbF87VaghprDJw89eZa5+xBI86u7Z3+/uz9/aicnB7uBiuyVQztnz5y6c+eW/2DQcOw00PE+67YBdUKMcFy50WrZOpdVm4BchrePr31+dbuzvtjaVD/ESGHv5ObJPa17dmz8//8XUPPCKzdCNu2sOXoqa88hIMrZeyR/31GgRyB+YXj6+PaLJzfKirKiQ3wS7LXn1+W11lVs37ru///fQM3LL18Daq47eqr04PHC/UcL9h2tPXo6ZtseiF8Yfr++8fn5zYSYOFtr69pYj8SoMGc3n5s3Lv//9/3H54+Tj52M3b6v+cTZ0E07vdZugdjpCbYWZPPE7qao8GANFWVbazMnOysDAwM9PYP6+obLVy/v3LEzfd1WlzVb/dZtAyp1X70ZGD0QBNVsamwoJymirCCjJC+lLC+trqKgqSyrqqlf3djZN3O658qN7mBtHjANyIjBQF1JTlpCUVZSQVZSUU5KRVFWRlo8PiigIDPPpa3Lc9NuDxw6QZoL06OE+HllJcWkJURkJEWB+kWF+OtKcicfPOi4cpMnDm0QBAClA3j4WL/6awAAAABJRU5ErkJggg==","aspectRatio":1.7730496453900708,"src":"/static/47940fb26682a8e2a9760a8b8cfd469e/a4bdf/how-to-use-tailwind-css-flex.png","srcSet":"/static/47940fb26682a8e2a9760a8b8cfd469e/84249/how-to-use-tailwind-css-flex.png 250w,\n/static/47940fb26682a8e2a9760a8b8cfd469e/a4bdf/how-to-use-tailwind-css-flex.png 384w","sizes":"(max-width: 384px) 100vw, 384px"}}},"imageExternal":null,"lastUpdated":"8 May 2024","author":"Emmanuel Chinonso","role":"Technical Writer/Web developer","authorImage":"/blog/author/author_emmanuel.jpg","metaTitle":"How to use Tailwind Flex","metaDescription":"Flexbox is a powerful CSS layout module, and when combined with Tailwind CSS, it becomes even more convenient and efficient. By utilizing Tailwind CSS flex utilities, you can easily create flexible and responsive layouts for your projects.","previousTitle":"How to Install Tailwind CSS in Vue.js","previousPath":"how-to-install-tailwind-css-in-vuejs","nextTitle":"How to use Tailwind CSS in HTML","nextPath":"how-to-use-tailwind-css-in-HTML","blogtype":"tailwindcss"},"fields":{"slug":"/how-to-use-tailwind-css-flex/"}},"previous":null,"next":null},"pageContext":{"id":"764e2b4e-8e45-5f20-82a6-20a9b92a9044"}},"staticQueryHashes":["2619113677","2619113677","2619113677","2619113677","2619113677","2619113677","3309287076","3706406642","3706406642","4045616534","4045616534","956403285","956403285"]}