Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/levimcg/share-controls

A Web Component that adds native copy and paste and sharing controls to a web page
https://github.com/levimcg/share-controls

custom-elements progressive-enhancement webcomponent webcomponents

Last synced: 23 days ago
JSON representation

A Web Component that adds native copy and paste and sharing controls to a web page

Awesome Lists containing this project

README

        

# `` element
A Custom Element that adds progressively enhanced share buttons to your web page. This custom element was inspired by this [excellent article](https://set.studio/simplify-sharing-with-built-in-apis-and-progressive-enhancement/) on the [Set Studio](https://set.studio/) blog.

## Usage
Add the `` element to your page and provide a simple fallback.

```html

Copy and paste to share this article: {{ Your URL here }}


```

By default the URL that gets copied to the clipboard and/or shared via the native web share API is the current page URL, but you can also use the provided `url` attribute to specify a different URL if you need to.

```html

Copy and paste to share this article: {{ Your URL here }}


```

## Attributes

| Attribute | Description |
| -------------- | ----------------------------------------------------------------------------- |
| `url` | A string that is coppied to the clipboard and/or used by the native share API. Defaults to the current page's URL |
| `copy-button` | A string that is used for the copy button text. Defaults to "Copy" |
| `share-text` | A string that is use as the message by the native web share API. Defaults to the current page title |
| `share-button` | A string that is used for the share button text. Defaults to "Share" |

## To-dos

- [ ] ...