Kombai Logo

Tailwind CSS Hyphens

The hyphens CSS property controls how text is split across lines, primarily affecting the word-breaking behavior of long words within content blocks. Using this property, you can decide whether to prohibit hyphenation (none), allow manual hyphenation via soft hyphens (manual), or automatically enable hyphenation based on language and browser capabilities (auto). Tailwind CSS incorporates utilities for managing these hyphenation settings seamlessly. Whether you're building responsive designs or focusing on accessibility and readability, Tailwind's hyphens utilities provide flexible options to manage word-breaking in your applications.

In this guide, you will learn about adding hyphenation control, how to make them state- and breakpoint-specific, and more.

ClassPropertiesExample
hyphens-nonehyphens: none;<div className="hyphens-none"></div>
hyphens-manualhyphens: manual;<div className="hyphens-manual"></div>
hyphens-autohyphens: auto;<div className="hyphens-auto"></div>

Overview of Hyphens

Tailwind CSS offers three utility classes to configure hyphenation behavior. These reflect the CSS values of the same name: none, manual, and auto. Below is an explanation of each along with a usage snippet.

Disabling the Hyphens

The hyphens-none class disables hyphenation entirely, ensuring words remain unbroken on line wraps, even when too long to fit.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Manual Hyphenation

Use hyphens-manual to enable manual hyphenation. If the content contains soft hyphens (&shy;), those words will break appropriately at the designated points.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Automatic Hyphenation

The hyphens-auto utility lets the browser handle hyphenation automatically based on language and context.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

States and Responsiveness

Beyond basic hyphenation settings, Tailwind allows conditional application of hyphenation utilities. You can style based on states (e.g., hover, focus) or responsive breakpoints using Tailwind's built-in modifiers.

Hover and Focus States

You can apply different hyphenation styles dynamically based on user interaction, such as when hovering over or focusing on an element.

Dynamic Hover Behavior

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Focus-Based Hyphenation

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Breakpoint Modifiers

Responsive design is crucial for modern web applications. By combining breakpoint modifiers, you can define hyphenation behavior across different screen sizes.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Real World Examples

Product Reviews with Multiple Language Support

This component displays customer reviews in multiple languages, using appropriate hyphenation for better text wrapping and readability.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Technical Documentation Sidebar

This component shows a technical documentation sidebar with proper hyphenation for long technical terms.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Scientific Article Preview

This component displays scientific article previews with proper hyphenation for scientific terms.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Chemical Compound Cards

This component displays chemical compound information with proper hyphenation for chemical names.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Mathematical Theorem Cards

This component displays mathematical theorems with proper hyphenation for mathematical terms.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Best Practices

Maintain Design Consistency

When applying hyphenation utilities like hyphens-none, hyphens-auto, or hyphens-manual in Tailwind CSS, consistency is crucial for maintaining a polished design. For example, ensure uniform hyphenation rules across all interactive and static text elements within the same section of your application. A frequently inconsistent use of these classes may result in discrepancies, such as text breaking inconsistencies between components.

You can achieve consistency by abstracting text styling with hyphens into reusable Tailwind utility classes or components.

Leverage Utility Combinations

Tailwind CSS encourages composability, allowing developers to chain utilities for more nuanced designs. Combining hyphens with spacing, typography, and alignment utilities can enhance readability and responsiveness. For instance, integrate line-height, text-justify, and padding utilities alongside hyphens-auto for fluid layouts.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Accessibility Considerations

Enhance Readability and Navigability

Hyphenation utilities improve content clarity, especially for users navigating long-form text or multilingual content. When applied thoughtfully, these utilities increase the fluidity of content flow, making it easier for assistive technologies like screen readers to parse and vocalize text.

Support Accessible Interactive Elements

Interactive elements, such as tooltips or modal descriptions, benefit from hyphenation. This ensures that toggled content adapts smoothly without breaking or distorting its structure, even when descriptive text becomes lengthy.