Halloween Sale 15% off Ends in See the plans
PHP

Table Block Styles: Lined Rows and Hover Highlight

Adds two table styles: "Lined" with thin row dividers and no outer borders, and "Hover rows" that highlights the row under the mouse for easier reading.

Don’t have WPIDE yet? Install it on your site

Code

add_action( 'init', function () {
    register_block_style( 'core/table', array(
        'name'         => 'wpide-lined',
        'label'        => 'Lined',
        'inline_style' => '.wp-block-table.is-style-wpide-lined td,.wp-block-table.is-style-wpide-lined th{border:0;border-bottom:1px solid rgba(0,0,0,.12);padding:.7em .5em;}.wp-block-table.is-style-wpide-lined thead{border-bottom:2px solid currentColor;}',
    ) );

    register_block_style( 'core/table', array(
        'name'         => 'wpide-hover-rows',
        'label'        => 'Hover rows',
        'inline_style' => '.wp-block-table.is-style-wpide-hover-rows tbody tr{transition:background-color .15s ease;}.wp-block-table.is-style-wpide-hover-rows tbody tr:hover{background-color:rgba(0,0,0,.05);}',
    ) );
} );

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.