Applying style to checkbox field

81 views
Skip to first unread message

JAIN RAJESH

unread,
Sep 5, 2022, 6:48:46 AM9/5/22
to Blockly
Hello team,

I have replaced the default tick character on the checkbox field with a large circle by changing Blockly.FieldCheckbox.CHECK_CHAR = '\u2713' to Blockly.FieldCheckbox.CHECK_CHAR = '\uD83D\uDD34';

See attched image: Now I want to change the color of this CHECK_CHAR to Red. I read in one post that it can be done by applying CSS to the class 
blocklyCheckbox. I tried but could not succeed. Can anyone please help with example codes.

Thank you in advance.

Kumaar
Capture.PNG

Neil Fraser

unread,
Sep 5, 2022, 6:56:55 AM9/5/22
to blo...@googlegroups.com
Note that the element you are styling is SVG, not HTML.  So CSS properties like 'color' and such don't work.  Try this:

.blocklyCheckbox {fill: red !important}


--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/463fa871-5f7f-459a-ab80-98125a441d24n%40googlegroups.com.


--

JAIN RAJESH

unread,
Sep 5, 2022, 7:43:05 AM9/5/22
to Blockly
Thank you Neil for your prompt response.

It worked:)

You are great!

Kumaar

JAIN RAJESH

unread,
Sep 5, 2022, 7:48:24 AM9/5/22
to Blockly
Also, can I change the background color of the square containing the circle from blue to, say, white. I have attached the image with red circles.
Capture.PNG

Neil Fraser

unread,
Sep 5, 2022, 12:01:07 PM9/5/22
to blo...@googlegroups.com
Try:
.blocklyFieldRect {fill-opacity: 1}

But this targets all the light-coloured rectangles in Blockly, not just the checkboxes.



JAIN RAJESH

unread,
Sep 5, 2022, 2:14:33 PM9/5/22
to Blockly
Thank you once again! This too worked. though I shall not apply this as it affects all other blocks too.

Kumaar

Reply all
Reply to author
Forward
0 new messages