Typography

Text Indent

Utilities for controlling the amount of empty space shown before text in a block.

Quick reference

Class
Properties
indent-0text-indent: 0px;
indent-pxtext-indent: 1px;
indent-0.5text-indent: 0.125rem;
indent-1text-indent: 0.25rem;
indent-1.5text-indent: 0.375rem;
indent-2text-indent: 0.5rem;
indent-2.5text-indent: 0.625rem;
indent-3text-indent: 0.75rem;
indent-3.5text-indent: 0.875rem;
indent-4text-indent: 1rem;
indent-5text-indent: 1.25rem;
indent-6text-indent: 1.5rem;
indent-7text-indent: 1.75rem;
indent-8text-indent: 2rem;
indent-9text-indent: 2.25rem;
indent-10text-indent: 2.5rem;
indent-11text-indent: 2.75rem;
indent-12text-indent: 3rem;
indent-14text-indent: 3.5rem;
indent-16text-indent: 4rem;
indent-20text-indent: 5rem;
indent-24text-indent: 6rem;
indent-28text-indent: 7rem;
indent-32text-indent: 8rem;
indent-36text-indent: 9rem;
indent-40text-indent: 10rem;
indent-44text-indent: 11rem;
indent-48text-indent: 12rem;
indent-52text-indent: 13rem;
indent-56text-indent: 14rem;
indent-60text-indent: 15rem;
indent-64text-indent: 16rem;
indent-72text-indent: 18rem;
indent-80text-indent: 20rem;
indent-96text-indent: 24rem;

Show all classes

Basic usage

Adding a text indent

Use the indent-{width} utilities to set the amount of empty space (indentation) that’s shown before text in a block.

Text Indent - 图1

  1. <p class="indent-8">
  2. So I started to walk into the water. I won't lie to you boys, I was
  3. terrified. But I pressed on, and as I made my way past the breakers
  4. a strange calm came over me. I don't know if it was divine intervention
  5. or the kinship of all living things but I tell you Jerry at that moment,
  6. I <em>was</em> a marine biologist.
  7. </p>

Using negative values

To use a negative text indent value, prefix the class name with a dash to convert it to a negative value.

  1. <div class="-indent-8">
  2. So I started to walk into the water. I won't lie to...
  3. </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:indent-8 to only apply the indent-8 utility on hover.

  1. <div class="indent-4 hover:indent-8">
  2. <!-- ... -->
  3. </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:indent-8 to apply the indent-8 utility at only medium screen sizes and above.

  1. <div class="indent-4 md:indent-8">
  2. <!-- ... -->
  3. </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 text indent scale is based on the default spacing scale. You can customize your spacing scale by editing theme.spacing or theme.extend.spacing in your tailwind.config.js file.

tailwind.config.js

  1. module.exports = { theme: { extend: { spacing: { '128': '32rem', } } }}

Alternatively, you can customize just the text indent scale by editing theme.textIndent or theme.extend.textIndent in your tailwind.config.js file.

tailwind.config.js

  1. module.exports = { theme: { extend: { textIndent: { '128': '32rem', } } }}

Learn more about customizing the default theme in the theme customization documentation.

Arbitrary values

If you need to use a one-off text-indent 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.

  1. <div class="indent-[50%]">
  2. <!-- ... -->
  3. </div>

Learn more about arbitrary value support in the arbitrary values documentation.