Copy Button
Copy content is a very common feature to help user copy content easier.
<msc-copy-button />
provides the whole feature including UI & interaction.
With <msc-copy-button />
, developers could adopt copy feature to web page easier.
Check the following examples and input something to see what can <msc-copy-button />
do ?
Basic Usage
<msc-copy-button />
is a web component. All we need to do is put the required script into your HTML document. Then follow <msc-copy-button />
's html structure and everything will be all set.
Required Script
Structure
Put <msc-copy-button />
into HTML document. It will have different functions and looks with attribute mutation.
Otherwise, developers could also choose remoteconfig to fetch config for <msc-copy-button />
.
JavaScript Instantiation
<msc-copy-button />
could also use JavaScript to create DOM element. Here comes some examples.
Style Customization
Developers could apply styles to decorate <msc-copy-button />
's looking.
Attributes
<msc-copy-button />
supports some attributes to let it become more convenience & useful.
copycontent
Set content for copy. Default is ""(empty string). <msc-copy-button />
will throw error when empty content.
Property
Property Name | Type | Description |
---|---|---|
copycontent
|
String | Getter / Setter content for copy. Default is "" (empty string). |
Events
Event Signature | Description |
---|---|
msc-copy-button-success
|
Fired when copy success. Developers can gather information through event.detail.content . |
msc-copy-button-fail
|
Fired when copy fail. Developers can gather information through event.detail.message . |