react-component / react-component/tree
Customize Checkbox Icon
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 490
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 5
Description
Since we have the ability to change switcher icons and node icons it would be nice to change out the checkbox icons with our own components.
I'm able to fake this by hiding the checkbox element and providing my own icon to the node, e.g. (using Material UI icons)
.rc-tree li span.rc-tree-checkbox {
display: none;
}
then passing in
<TreeNode icon={(props: InternalTreeNodeProps) => {
if (props.halfChecked) {
return <IndeterminateCheckbox />
} else if (props.checked) {
return <CheckBox />
}
return <CheckBoxOutlineBlank />
}} />
This works but prevents us from being able to use custom icons for directories vs leaves, etc.
Ideally it would work identical to the switcherIcon prop:
<Tree
checkboxIcon={(props: InternalTreeNodeProps) => {
if (props.halfChecked) {
return <IndeterminateCheckbox />
} else if (props.checked) {
return <CheckBox />
}
return <CheckBoxOutlineBlank />
}}
switcherIcon={(props: InternalTreeNodeProps) => {
const { expanded, isLeaf } = props
if (isLeaf) return null
return expanded ? <ChevronRight /> : <ExpandMore />
}}
/>
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing switcherIcon prop on Tree and TreeNode, then inspect how checkbox rendering currently works. Add an equivalent checkboxIcon customization path that receives the node state shown in the issue, while preserving directory-versus-leaf icons; verify the behavior with the repository's existing tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100