question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to fill background color of a node

See original GitHub issue

I would like to fill node background with another color other than white, however seems like not able to. Here is what I did.

<SortableTree
            treeData={this.state.treeData}
            onChange={treeData => this.setState({ treeData })}
	    canDrag = {false}
	    getNodeKey = {({node})=> node.id}
            generateNodeProps={(({ node, path, treeIndex}) => {
		return ({
		    title: (
			<div style={{height:'100%', width:'100%', backgroundColor:'cyan'}} >
                        <Checkbox
			      label= {node.name}
			    />
                        </div>),})}}
/>

and this is how it looks. (I want color fill all the node background) image

Please let me know how to resolve it.

thank you so much.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
asilberschneidercommented, Oct 12, 2021

Hi, the reason behind that is that props returned from generateNodeProps are applied to the whole node “row” container, and not the node contents. If you look closely, you may notice that the background color applied via the style prop is “shining through” at the rounded edges of the drag handle and the node contents rectangles (only).

You could work around this by either creating a custom nodeContentRenderer (see node-renderer-default.js for the default renderer), or by defining CSS classes which target the node content element.

Example for the latter:

JSX prop generateNodeProps={ () => ({ className: 'red-node' }) }

CSS class

.red-node .rst__rowContents {
  background-color: red;
}
0reactions
Punith13commented, Oct 12, 2021

Hi, I am having the same issue, using background / backgroundColor doesn’t have any effect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get and set node background color : backgroundColor « Style «
Get and set node background color : backgroundColor « Style « JavaScript Tutorial.
Read more >
fillcolor | Graphviz
fillcolor. Color used to fill the background of a node or cluster. type: color | colorList, default: lightgrey (nodes) , black (clusters).
Read more >
Using Nodelists to Change Background Color of Page
You are passing a single node to color() but then trying to iterate over it with a for() call. You are using getElementsByTagName()...
Read more >
Tikz background color of node multilayer - TeX
Normal node behavior is to have no background color. Try adding fill=white to the small square. – Alain Merigot. Sep 27, 2019 at...
Read more >
How to change the node background color and picture when ...
How to change the node background color and picture when click node? ... var color = "#302e2f3d"; if (shape) { shape.fill = GO(go....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found