Top / Right / Bottom / Left
Utilities for controlling the placement of positioned elements.
Show all classes
Use the utilities to set the horizontal or vertical position of a .
Using negative values
To use a negative top/right/bottom/left value, prefix the class name with a dash to convert it to a negative value.
<div class="relative h-32 w-32 ...">
<div class="absolute h-14 w-14 -left-4 -top-4 ..."></div>
</div>
For more control, you can also use the LTR and RTL modifiers to conditionally apply specific styles depending on the current text direction.
Hover, focus, and other states
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:top-6
to only apply the top-6
utility on hover.
<div class="top-4 hover:top-6">
<!-- ... -->
For a complete list of all available state modifiers, check out the 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:top-6
to apply the top-6
utility at only medium screen sizes and above.
To learn more, check out the documentation on , Dark Mode and .
Customizing your theme
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: {
spacing: {
}
}
}
}
Alternatively, you can customize just the top/right/bottom/left/inset scale by editing theme.inset
or theme.extend.inset
in your tailwind.config.js
file.
tailwind.config.js
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off top/right/bottom/left
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="top-[3px]">
<!-- ... -->
</div>