feat: add tailwind support for blocks#696
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Tailwind CSS support to the WordPress block editor by registering an editor stylesheet via add_editor_style() when Tailwind is enabled. Mirrors the existing frontend Tailwind handling already present in register_assets/enqueue_assets.
Changes:
- New
add_editor_styles()method onAssetsthat callsadd_editor_style()withassets/build/css/frontend/tailwind.csswhen$tailwind_enabledis true. - Hooks the new method on
after_setup_themefromregister_hooks().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aryanjasala
left a comment
There was a problem hiding this comment.
Please check the failing PHP Lint job
| */ | ||
| public function add_editor_styles(): void { | ||
| if ( $this->tailwind_enabled ) { | ||
| add_editor_style( $this->assets_dir . '/css/frontend/tailwind.css' ); |
There was a problem hiding this comment.
Any reason for using add_editor_style on after_theme_setup instead of using wp_enqueue_style on enqueue_block_editor_assets?
https://developer.wordpress.org/block-editor/how-to-guides/enqueueing-assets-in-the-editor/
There was a problem hiding this comment.
The docs say: Editor-specific stylesheets should almost always be added with add_editor_style() or wp_enqueue_block_style().
Both do similar things. What do you recommend
Description
This PR adds tailwind styling supports to the gutenberg editor.
Technical Details
add_editor_style()call is added with thecss/frontend/tailwind.csspath iftailwind_enabledis true.