admin管理员组文章数量:1319953
I have InnerBlocks
which contain ButtonBlockAppender
.
I would like to add any className
to the ButtonBlockAppender
ButtonBlockAppender documentation says:
className
Type: String
Default: ""
A CSS class to be prepended to the default class of "button-block-appender".
So i tried to do this like this:
<InnerBlocks
renderAppender={() => (
<InnerBlocks.ButtonBlockAppender className={'TESTEDCLASSSTRING'} />
)}
/>
Unfortunately my class is not included. Generally nothing has changed.
The console is clear (no errors).
I have InnerBlocks
which contain ButtonBlockAppender
.
I would like to add any className
to the ButtonBlockAppender
ButtonBlockAppender documentation says:
className
Type: String
Default: ""
A CSS class to be prepended to the default class of "button-block-appender".
So i tried to do this like this:
<InnerBlocks
renderAppender={() => (
<InnerBlocks.ButtonBlockAppender className={'TESTEDCLASSSTRING'} />
)}
/>
Unfortunately my class is not included. Generally nothing has changed.
The console is clear (no errors).
Share Improve this question asked Oct 15, 2020 at 14:13 kanlukaszkanlukasz 5448 silver badges24 bronze badges1 Answer
Reset to default 2That documentation is for the base ButtonBlockAppender
component in the @wordpress/block-editor
package, and that component is exported with the name ButtonBlockerAppender
(note the "Blocker" vs "Block").
But your code is actually using InnerBlocks.ButtonBlockAppender
which is an enhanced version of that base ButtonBlockAppender
component, and as of writing, that enhanced version does not include the className
prop — check the source (from the last commit in April 2020) where you can see BaseButtonBlockAppender
is called without the className
prop, and that BaseButtonBlockAppender
is the one I've mentioned above (i.e. ButtonBlockerAppender
).
So if you want that className
prop, you can try one of these:
Clone the enhanced version (i.e.
InnerBlocks.ButtonBlockAppender
) and include thatclassName
prop, but it'll be up to you on how to clone it..Or don't use that enhanced version, and use the base one instead. E.g.
const { InnerBlocks, ButtonBlockerAppender } = wp.blockEditor; // or if you'd rather import: //import { InnerBlocks, ButtonBlockerAppender } from '@wordpress/block-editor'; // Then in the block edit(): <InnerBlocks renderAppender={() => ( <ButtonBlockerAppender className="your-custom-class" /> )} />
版权声明:本文标题:admin css - How to add a class to the <InnerBlocks.ButtonBlockAppender > element in a custom Gutenberg block 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742059091a2418474.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论