Balance Text
WordPress plugin: adds a Balance toggle to the native Typography panel on every block. Applies CSS text-wrap: balance via a single className. One editor.BlockEdit filter, composes with any block style variation.
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/diffyweb/wp-balance-text/archive/refs/heads/main.zipReadme
wp-balance-text
A tiny WordPress plugin that adds a Balance toggle to the native Typography panel on every block. Applies CSS text-wrap: balance via a single className.
What it does
Two ways to apply CSS text-wrap: balance to your content:
- Per-block toggle. Slots a one-click control into the editor's native Typography panel — same panel that holds Size, Font, Drop cap, Fit text, etc. Click
+in the panel header → enable Balance on the selected block. - Site-wide defaults. Settings → Balance Text: pick block types that should be balanced by default. Out of the box, headings H1–H6 are on (matching the common convention). Optional: Paragraph, Quote, Pullquote, Verse. A "Settings" link also appears next to Activate/Deactivate on the Plugins screen.
Result: headlines and short paragraphs stop stranding a single word on the last line. Per-block toggles compose cleanly with the site-wide defaults — they're additive opt-in, not overrides.
How it works
- One
editor.BlockEditfilter, fires for every block type. No per-block-type registration. - Storage is a
text-balancetoken pushed onto the block's existingclassNameattribute. No custom attributes, no migrations, no lock-in. - CSS is enqueued via
wp_enqueue_block_assetsso the editor preview matches the front-end. - Composes with any
is-style-*block style variation already applied.
Files
wp-balance-text.php # plugin header, enqueues, Settings API, dynamic <style> emitter
assets/editor.js # the Typography-panel toggle (one editor.BlockEdit filter)
assets/style.css # .text-balance + .balance-text utility classes
That's the whole plugin.
Installation
- Clone or download into
/wp-content/plugins/wp-balance-text/. - Activate via the Plugins screen (or
wp plugin activate wp-balance-text). - Open any block in the editor → Typography panel → click the
+menu → enable Balance.
Requirements
- WordPress 6.4+ (for the stable
ToolsPanelItemslot; gracefully falls back to the experimental version on older builds). - PHP 7.4+.
- Modern browser for the
text-wrap: balancerule itself (Chrome 114+, Edge 114+, Firefox 121+, Safari 17.5+). Older browsers ignore the rule and fall back to default wrapping — no breakage.
License
GPL-2.0-or-later. See LICENSE.