Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set auto and fr grid template columns in Tailwind CSS?

Tags:

tailwind-css

I need to apply this line of CSS to my layout:

grid-template-columns: auto 1fr;

Is this something you can't do with Tailwind CSS?

like image 279
Evanss Avatar asked Oct 29 '25 21:10

Evanss


1 Answers

You can extend the utilities using your Tailwind CSS config:

module.exports = {
  theme: {
    extend: {
      gridTemplateColumns: {
        'my-columns': 'auto 1fr'
      }
    }
  }
};
<div class="grid grid-cols-my-columns">
  
</div>

Or you can use arbitrary values if you're only using this layout in one place:

<div class="grid grid-cols-[auto_1fr]">

</div>

There's more details in the documentation.

like image 151
HorusKol Avatar answered Nov 02 '25 17:11

HorusKol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!