Flexbox & Grid
Flex Basis
Utilities for controlling the initial size of flex items.
Quick reference
Class | Properties |
---|---|
basis-0 | flex-basis: 0px; |
basis-1 | flex-basis: 0.25rem; |
basis-2 | flex-basis: 0.5rem; |
basis-3 | flex-basis: 0.75rem; |
basis-4 | flex-basis: 1rem; |
basis-5 | flex-basis: 1.25rem; |
basis-6 | flex-basis: 1.5rem; |
basis-7 | flex-basis: 1.75rem; |
basis-8 | flex-basis: 2rem; |
basis-9 | flex-basis: 2.25rem; |
basis-10 | flex-basis: 2.5rem; |
basis-11 | flex-basis: 2.75rem; |
basis-12 | flex-basis: 3rem; |
basis-14 | flex-basis: 3.5rem; |
basis-16 | flex-basis: 4rem; |
basis-20 | flex-basis: 5rem; |
basis-24 | flex-basis: 6rem; |
basis-28 | flex-basis: 7rem; |
basis-32 | flex-basis: 8rem; |
basis-36 | flex-basis: 9rem; |
basis-40 | flex-basis: 10rem; |
basis-44 | flex-basis: 11rem; |
basis-48 | flex-basis: 12rem; |
basis-52 | flex-basis: 13rem; |
basis-56 | flex-basis: 14rem; |
basis-60 | flex-basis: 15rem; |
basis-64 | flex-basis: 16rem; |
basis-72 | flex-basis: 18rem; |
basis-80 | flex-basis: 20rem; |
basis-96 | flex-basis: 24rem; |
basis-auto | flex-basis: auto; |
basis-px | flex-basis: 1px; |
basis-0.5 | flex-basis: 0.125rem; |
basis-1.5 | flex-basis: 0.375rem; |
basis-2.5 | flex-basis: 0.625rem; |
basis-3.5 | flex-basis: 0.875rem; |
basis-1/2 | flex-basis: 50%; |
basis-1/3 | flex-basis: 33.333333%; |
basis-2/3 | flex-basis: 66.666667%; |
basis-1/4 | flex-basis: 25%; |
basis-2/4 | flex-basis: 50%; |
basis-3/4 | flex-basis: 75%; |
basis-1/5 | flex-basis: 20%; |
basis-2/5 | flex-basis: 40%; |
basis-3/5 | flex-basis: 60%; |
basis-4/5 | flex-basis: 80%; |
basis-1/6 | flex-basis: 16.666667%; |
basis-2/6 | flex-basis: 33.333333%; |
basis-3/6 | flex-basis: 50%; |
basis-4/6 | flex-basis: 66.666667%; |
basis-5/6 | flex-basis: 83.333333%; |
basis-1/12 | flex-basis: 8.333333%; |
basis-2/12 | flex-basis: 16.666667%; |
basis-3/12 | flex-basis: 25%; |
basis-4/12 | flex-basis: 33.333333%; |
basis-5/12 | flex-basis: 41.666667%; |
basis-6/12 | flex-basis: 50%; |
basis-7/12 | flex-basis: 58.333333%; |
basis-8/12 | flex-basis: 66.666667%; |
basis-9/12 | flex-basis: 75%; |
basis-10/12 | flex-basis: 83.333333%; |
basis-11/12 | flex-basis: 91.666667%; |
basis-full | flex-basis: 100%; |
Show all classes
Basic usage
Setting the flex basis
Use the basis-{size}
utilities to set the initial size of flex items.
<div class="flex flex-row">
<div class="basis-1/4">01</div>
<div class="basis-1/4">02</div>
<div class="basis-1/2">03</div>
</div>
Applying conditionally
Hover, focus, and other states
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:basis-1/2
to only apply the basis-1/2
utility on hover.
<div class="basis-1/3 hover:basis-1/2">
<!-- ... -->
</div>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
Breakpoints and media queries
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:basis-1/3
to apply the basis-1/3
utility at only medium screen sizes and above.
<div class="flex flex-row">
<div class="basis-1/4 md:basis-1/3">01</div>
<div class="basis-1/4 md:basis-1/3">02</div>
<div class="basis-1/2 md:basis-1/3">03</div>
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
Using custom values
Customizing your theme
The default flex basis scale is a combination of the default spacing scale as well as a set of percentage based values.
You can customize your spacing scale by editing theme.spacing
or theme.extend.spacing
in your tailwind.config.js
file.
tailwind.config.js
module.exports = { theme: { extend: { spacing: { '112': '28rem', '128': '32rem', } } }}
Alternatively, you can customize just the flex basis scale by editing theme.flexBasis
or theme.extend.flexBasis
in your tailwind.config.js
file.
tailwind.config.js
module.exports = { theme: { extend: { flexBasis: { '1/7': '14.2857143%', '2/7': '28.5714286%', '3/7': '42.8571429%', '4/7': '57.1428571%', '5/7': '71.4285714%', '6/7': '85.7142857%', } } }}
Learn more about customizing the default theme in the theme customization documentation.
Arbitrary values
If you need to use a one-off flex-basis
value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<div class="flex-basis-[14.2857143%]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.