admin管理员组文章数量:1401604
I'm using react show more text controller in my spfx webpart using react. i need to replace showMore and showLess string link with ExpandMore and ExpandLess material ui icons in my webpart.is there any method for this?
<ShowMoreText
/* Default options */
lines={2}
more="Show More"
less="Show less"
anchorClass=""
onClick={this.executeOnClick}
expanded={false}
>
{item["description"]}
</ShowMoreText>
I refered this
I'm using react show more text controller in my spfx webpart using react. i need to replace showMore and showLess string link with ExpandMore and ExpandLess material ui icons in my webpart.is there any method for this?
<ShowMoreText
/* Default options */
lines={2}
more="Show More"
less="Show less"
anchorClass=""
onClick={this.executeOnClick}
expanded={false}
>
{item["description"]}
</ShowMoreText>
I refered this https://npmjs./package/react-show-more-text
Share Improve this question edited Mar 23, 2020 at 5:45 keikai 15.2k10 gold badges55 silver badges72 bronze badges asked Mar 23, 2020 at 5:18 Bini JacobBini Jacob 531 silver badge6 bronze badges 3- npmjs./package/react-show-more-text i referred this – Bini Jacob Commented Mar 23, 2020 at 5:22
- <ShowMoreText /* Default options */ lines={2} more='Show More' less='Show less' anchorClass='' onClick={this.executeOnClick} expanded={false} > {item["description"]} </ShowMoreText> i need the following material icons in show and less string props – Bini Jacob Commented Mar 23, 2020 at 5:23
- is there any method to add icon in more='Show More' less='Show less' – Bini Jacob Commented Mar 23, 2020 at 5:29
1 Answer
Reset to default 5Method
Pass the <Icon />
directly to related props would work fine.
<ShowMoreText
more={<ExpandMore />}
less={<ExpandLess />}
...
/>
Demo
Source
import React, { useState } from "react";
import "./styles.css";
import ShowMoreText from "react-show-more-text";
import ExpandLess from "@material-ui/icons/ExpandLess";
import ExpandMore from "@material-ui/icons/ExpandMore";
export default function App() {
const [expand, setExpand] = useState(false);
const onClick = () => {
setExpand(!expand);
};
const text = "12313131313131311";
return (
<div className="App">
<ShowMoreText
lines={2}
more={<ExpandMore />}
less={<ExpandLess />}
onClick={onClick}
expanded={expand}
width={30}
>
{text}
</ShowMoreText>
</div>
);
}
本文标签: javascriptHow to customize reactshowmore more or less text to MaterialUI IconsStack Overflow
版权声明:本文标题:javascript - How to customize react-show-more more or less text to Material-UI Icons - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744272252a2598239.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论