@@ -128,20 +128,33 @@ export default class Clipboard extends React.Component {
128128 }
129129
130130 render ( ) {
131- const { id, title, className, style} = this . props ;
132- const copyIcon = < FontAwesomeIcon icon = { faCopy } /> ;
133- const copiedIcon = < FontAwesomeIcon icon = { faCheckCircle } /> ;
134- const btnIcon = this . state . copied ? copiedIcon : copyIcon ;
131+ const {
132+ id,
133+ title,
134+ className,
135+ style,
136+ copied_className,
137+ copied_style,
138+ children,
139+ copied_children,
140+ } = this . props ;
141+
142+ const isCopied = this . state . copied ;
143+
144+ const content = isCopied
145+ ? copied_children ?? < FontAwesomeIcon icon = { faCheckCircle } />
146+ : children ?? < FontAwesomeIcon icon = { faCopy } /> ;
135147
136148 return clipboardAPI ? (
137149 < LoadingElement
150+ elementType = { 'button' }
138151 id = { id }
139152 title = { title }
140- style = { style }
141- className = { className }
153+ style = { isCopied ? copied_style ?? style : style }
154+ className = { isCopied ? copied_className ?? className : className }
142155 onClick = { this . onClickHandler }
143156 >
144- < i > { btnIcon } </ i >
157+ { content }
145158 </ LoadingElement >
146159 ) : null ;
147160 }
@@ -160,6 +173,16 @@ Clipboard.propTypes = {
160173 */
161174 id : PropTypes . string ,
162175
176+ /**
177+ * The children of this component. By default copy icon
178+ */
179+ children : PropTypes . node ,
180+
181+ /**
182+ * The children of this component displayed while copying. By default checked icon
183+ */
184+ copied_children : PropTypes . node ,
185+
163186 /**
164187 * The id of target component containing text to copy to the clipboard.
165188 * The inner text of the `children` prop will be copied to the clipboard. If none, then the text from the
@@ -196,6 +219,15 @@ Clipboard.propTypes = {
196219 * The class name of the icon element
197220 */
198221 className : PropTypes . string ,
222+ /**
223+ * The icon's styles while copying
224+ */
225+ copied_style : PropTypes . object ,
226+
227+ /**
228+ * The class name of the icon element while copying
229+ */
230+ copied_className : PropTypes . string ,
199231
200232 /**
201233 * Dash-assigned callback that gets fired when the value changes.
0 commit comments