Add Dropdown to block using Traits
I'm not sure if you can change the block once you added it.... Maybe you should just have classes to add to the blocks, that you can change the color, size or something like that. You can take a look on the CSS composer for it. https://grapesjs.com/docs/api/css_composer.html#add
Read full answer below ↓Question
Hi @artf , I hope that you are well, I was wondering whether you could help me with some simple issue that I am having (I have recently started using GrapeJS. Issue: using a plugin create a block and within the traits section have a drop down that changes the type of block displayed. Here is my current plugin code which displays two blocks: I would like a dropdown to appear in the settings (traits) tab where I can select other options for content e.g: Simple Block ------------> Red ------------> Orange ------------> Yellow And then change the content accordingly as follows: Red: content: '<di...
Answers (3)
I'm not sure if you can change the block once you added it.... Maybe you should just have classes to add to the blocks, that you can change the color, size or something like that.
You can take a look on the CSS composer for it.
@Aiyush-G I think you should create a custom component with that trait which then changes the content, the block itself would just contain that component
Hi yes, this is what I was thinking, would you mind doing an example for me that changes the html content e.g. choosing red shows your chose red as a <p> tag and if you choose orange that is shows you chose orange and a <p>
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1822
[QUESTION] - Add style sector for specific Css rule
Hey @artf , COuld you give your help on this one? I want to disable the user to able to select the wrapper block (body) but I still want to...
Issue #544
Add select with optgroup
Hello @artf I have recently started using grapeJs and found it awesome. Can you please help me on How can I add dropdown(select) with optgr...
Issue #2093
Create Traits for navbar plugin
Hi Artf, i have two question: 1- i want to adding traits to Navbar component instead of default one and didnt know its type 2- i want to ad...
Issue #3721
Test drag and drop with Cypress
Hi @artf. I would like to run some test scenarios on GrapesJs using Cypress tool. However i am unable to simulate drag and drop mode using...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.