[Tree] Node highlight colors #2724
Answered
by
qwadrox
DKPlugins
asked this question in
PrimeReact
-
Hi. I need to change the color of the line selection (p-highlight) depending on whether the node is fully or partially selected. How can I do this? |
Beta Was this translation helpful? Give feedback.
Answered by
qwadrox
Sep 26, 2024
Replies: 1 comment 3 replies
-
Hi @DKPlugins! I assumed you wanted to change the colors of the nodes when they're focused. On different level, different colors. .mytree.p-tree .p-tree-container .p-treenode:focus > .p-treenode-content {
box-shadow: inset 0 0 0 0.15rem green !important; /* Green */
}
/* Nesting */
.mytree.p-tree
.p-tree-container
.p-treenode
.p-treenode:focus
> .p-treenode-content {
box-shadow: inset 0 0 0 0.15rem orange !important; /* Orange */
} Example code: This approach uses the cascading nature of CSS, but there are many other ways, for instance:
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I see. Then you can apply inline styles or classes on the treeNode itself, as I said. When the selection changes, you can update the node array. I don't know exactly how the highlights or background colors should be on the different deps according to your requirements, but here is a sample, and you can play with it further:
https://stackblitz.com/edit/ymebpg?file=src%2FApp.jsx
Another way you might be able to achieve this is using the nodeTemplate:
There is an example in the documentation how to use templating: https://primereact.org/tree/#template
Here is another solution made by me using templating:
https://stackblitz.com/edit/c127qh?file=src%2Findex.css
For most scenarios, especially …