Tailwind and Gutenberg Blocks

Support General Tailwind and Gutenberg Blocks

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #29170
    Aaron KesslerAaron Kessler
    Participant

    I did some Meta Box Gutenberg Blocks with Tailwind classes in PHP template files. The downside of this approach is that on the WordPress-Backend, my Blocks are completely unstyled. What strategies can I use, to style them on the WordPress Backend also?

    #29184
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can enqueue the Tailwind CSS file when registering the block to load it in both backend and frontend. Get more details on the documentation
    https://docs.metabox.io/extensions/mb-blocks/#enqueue_style
    https://docs.metabox.io/extensions/mb-blocks/#enqueue_assets

    and refer to this topic https://support.metabox.io/topic/tailwindcss/

    #29190
    Aaron KesslerAaron Kessler
    Participant

    Thank you!
    The enqueue_block_editor_assets hook is what I am using now. Code Example:

    function _akdev_mbBlockScripts()
    {
        wp_enqueue_style(
          '_akdev-ctaBlock',
          get_template_directory_uri().'/inc/mb-block-templates/cta.css',
      );
    }
    add_action('enqueue_block_editor_assets', '_akdev_mbBlockScripts');
    
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.