
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
tailwindcss-grid-area
Advanced tools
Add support for Grid areas within TailwindCSS
This plugin adds two new utilities for TailwindCSS to work with grid areas - grid-areas-[<areas>]
and grid-area-[<area>]
(or grid-area/<named-area>
)
<div class="grid grid-cols-5 grid-rows-3 bg-yellow-100">
<div class="p-10 bg-blue-300 grid-area-auto"></div>
<div class="p-10 bg-red-300 grid-area-[2/2/span_2/span_3]"></div>
</div>
Result:
Generated CSS:
.grid-area-auto {
grid-area: auto;
}
.grid-area-\[2\/2\/span_2\/span_3\] {
grid-area: 2/2/span 2/span 3;
}
<div class="grid grid-areas-['sidebar_center_left'_'sidebar_footer_footer']">
<div class="p-10 bg-blue-300 grid-area/left"></div>
<div class="p-10 bg-yellow-300 grid-area/center"></div>
<div class="p-10 bg-red-300 grid-area/sidebar"></div>
<div class="p-10 bg-green-300 grid-area/footer"></div>
</div>
Result:
Generated CSS:
.grid-area\/left {
grid-area: left;
}
.grid-area\/center {
grid-area: center;
}
.grid-area\/sidebar {
grid-area: sidebar;
}
.grid-area\/footer {
grid-area: footer;
}
.grid-areas-\[\'sidebar_center_left\'_\'sidebar_footer_footer\'\] {
grid-template-areas: 'sidebar center left' 'sidebar footer footer';
}
npm i tailwindcss-grid-area
Require plugin within plugins
section of tailwind.config.js
// tailwind.config.js
module.exports = {
// ...
plugins: [
require('tailwindcss-grid-area'),
],
}
Plugin provides some default utilities for grid-area
- same syntax as for global values for grid-area
CSS property
Utility | Generated CSS |
---|---|
grid-area , grid-area-auto | grid-area: auto |
grid-area-inherit | grid-area: inherit |
grid-area-initial | grid-area: initial |
grid-area-revert | grid-area: revert |
grid-area-layer | grid-area: revert-layer |
grid-area-unset | grid-area: unset |
There are no default properties for grid-areas
(as it is purely user-configured setting). However if you wish to use custom defined utility register it under gridAreas
key
// tailwind.config.js
module.exports = {
// ...
theme: {
extend: {
gridAreas: {
app: "'header header' 'sidebar main' 'sidebar footer'",
},
},
},
}
<div class="grid grid-areas-app"></div>
More about grid-template-areas
you may find on MDN
Same valid for grid-area
utility but key name is gridArea
// tailwind.config.js
module.exports = {
// ...
theme: {
extend: {
gridArea: {
custom: '1 / 1 / span 2 / 3',
},
},
},
}
<div class="grid-area-custom"></div>
When working with arbitrary values remember that Tailwind does NOT recognize spaces - use underscore _
instead
<div class="grid-area-[1_/_1_/_span_2_/_3]"></div>
<!-- Or -->
<div class="grid-area-[1/1/span_2/3]"></div>
When working with named grid areas you may use Tailwind labels instead of arbitrary variants
<div class="grid-area/header"></div>
<!-- Same as -->
<div class="grid-area-[header]"></div>
Open-source under MIT license
FAQs
Add support for Grid areas within TailwindCSS
The npm package tailwindcss-grid-area receives a total of 69 weekly downloads. As such, tailwindcss-grid-area popularity was classified as not popular.
We found that tailwindcss-grid-area demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.