Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add togglerTemplate property to Tree #2005

Closed
mopsicus opened this issue May 3, 2021 · 4 comments
Closed

Add togglerTemplate property to Tree #2005

mopsicus opened this issue May 3, 2021 · 4 comments
Assignees
Labels
Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@mopsicus
Copy link

mopsicus commented May 3, 2021

Is there way to customize toggler icon in Tree, e.g. via fontawesome? Can't find it in templating docs :(
If I switch off prime-icons lib, toggler icon are disappears. So, it's a dependency and should be added to docs to dependencies part.

@mertsincan mertsincan changed the title Tree toggle icons Add togglerTemplate property to Tree May 5, 2021
@mertsincan mertsincan self-assigned this May 5, 2021
@mertsincan mertsincan added the Type: New Feature Issue contains a new feature or new component request label May 5, 2021
@mertsincan mertsincan added this to the 6.3.2 milestone May 5, 2021
@mertsincan
Copy link
Member

mertsincan commented May 5, 2021

Hi,

You can use togglerTemplate property for this;

type TreeTogglerTemplateType = React.ReactNode | ((node: TreeNode, options: TreeTogglerTemplateOptions) => React.ReactNode);

interface TreeFilterInputOptions {
    className: string;
    onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void;
    onChange(event: React.KeyboardEvent<HTMLInputElement>): void;
}

interface TreeTogglerTemplateOptions {
    onClick(e: React.SyntheticEvent): void;
    containerClassName: string;
    iconClassName: string;
    element: JSX.Element;
    props: TreeProps;
    expanded: boolean;
}

//
togglerTemplate?: TreeTogglerTemplateType;
<Tree togglerTemplate={(node, options) => <button className={options.containerClassName} onClick={options.onClick}><FaHome className={options.className} /></button>} ... />

Best Regards,

@mopsicus
Copy link
Author

mopsicus commented May 5, 2021

Cool! Thanks a lot 👍

@AfikGrinstein
Copy link
Contributor

Hi @mertsincan,
Does this property exist for TreeTable?

@melloware
Copy link
Member

@AfikGrinstein yes it exists its documented right here: https://primereact.org/tree/#api.Tree.props.togglerTemplate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

No branches or pull requests

4 participants