最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

block editor - How to override Gutenberg admin CSS

programmeradmin0浏览0评论

I need advice how to modify Gutenberg's core CSS.

What's my problem: the outlines and block labels disappear and I want them fixed, visible on every block all the time, not only in focus. I've found GB gets his styles from something called wp-admin/load-styles.php which basically got me nowhere. All the styles merge via that load-styles.php file. I don't know where to look for that class for the outline.

Additionally, most CSS files I found wherever are x4 - minified and and alternative for RTL.

Which file and which version of it should I modify? Or maybe there is another approach?

I need advice how to modify Gutenberg's core CSS.

What's my problem: the outlines and block labels disappear and I want them fixed, visible on every block all the time, not only in focus. I've found GB gets his styles from something called wp-admin/load-styles.php which basically got me nowhere. All the styles merge via that load-styles.php file. I don't know where to look for that class for the outline.

Additionally, most CSS files I found wherever are x4 - minified and and alternative for RTL.

Which file and which version of it should I modify? Or maybe there is another approach?

Share Improve this question edited May 3, 2019 at 21:05 norman.lol 3,2413 gold badges30 silver badges35 bronze badges asked May 3, 2019 at 20:38 polish bastardpolish bastard 472 silver badges5 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 5

To override Gutenberg's styles you need to add your own stylesheet. So hook into enqueue_block_editor_assets and then add your own stylesheet in which you target the selectors you wanna override. In the following example I placed a stylesheet in a custom theme's assets/ folder.

functions.php:

// Add backend styles for Gutenberg.
add_action('enqueue_block_editor_assets', 'gutenberg_editor_assets');

function gutenberg_editor_assets() {
  // Load the theme styles within Gutenberg.
  wp_enqueue_style('my-gutenberg-editor-styles', get_theme_file_uri('/assets/gutenberg-editor-styles.css'), FALSE);
}

assets/gutenberg-editor-styles.css:

.editor-post-title__input {
  border: 1px solid black;
}

Source: Creating theme editor styles for Gutenberg

发布评论

评论列表(0)

  1. 暂无评论