Sizing
Utilities for setting the width and height of an element at the same time.
Use size-{number}
or size-px
to set an element to a fixed width and height at the same time.
<div class="size-16 ...">size-16</div>
<div class="size-20 ...">size-20</div>
<div class="size-24 ...">size-24</div>
<div class="size-32 ...">size-32</div>
<div class="size-40 ...">size-40</div>
Use size-full
to set an element’s width and height to be 100% of the parent container’s width and height.
<div class="h-56 p-2 ...">
<div class="size-full ...">size-full</div>
</div>
The size-auto
utility can be useful if you need to remove an element’s assigned width and height under a specific condition, like at a particular breakpoint:
<div class="size-full md:size-auto">
<!-- ... -->
</div>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:size-full
to only apply the size-full
utility on hover.
<div class="size-48 hover:size-full">
<!-- ... -->
</div>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:size-full
to apply the size-full
utility at only medium screen sizes and above.
<div class="size-48 md:size-full">
<!-- ... -->
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind’s size scale is a combination of the default spacing scale as well as some additional values specific to sizing.
You can customize your spacing scale by editing theme.spacing
or theme.extend.spacing
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
spacing: {
'128': '32rem',
}
}
}
}
To customize size separately, use the theme.size
section of your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
size: {
'128': '32rem',
}
}
}
}
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off size
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="size-[32rem]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.