Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlove committed Jun 17, 2021
1 parent 71efcd8 commit 1805ebf
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@ or via jsDeliver:

## Usage

Usage examples can be found at https://signified.github.io/clipboard.

```javascript
clipboard(selectors, options, callback(clipboard, element));
```

### `selectors` (required)
### `selectors` (string | required)

A DOMString containing one or more selectors to match against.
A string containing one or more selectors to match against. For example, `'pre'` will match every `<pre>` element.

### `options` (optional)
### `options` (object | optional)

An object representing configuration options.
An object representing optional configuration options.

```javascript
{
Expand All @@ -53,24 +55,14 @@ An object representing configuration options.
// 'beforeend': Inside the `element`, after its last child.
// 'afterend': After the `element`.
position: 'beforebegin'
// The HTML to use when creating the clipboard.
// The HTML to use when creating the `clipboard`.
template: '<div class="clipboard"><button class="clipboard-button" type="button">Copy</button></div>'
}
```

### `callback` (optional)

A callback function with parameters representing the `clipboard` and the selected `element` for each `selectors`.

### Examples

See the below examples in action here: https://signified.github.io/clipboard.
### `callback` (function | optional)

Add a clipboard button to every `<pre>...</pre>` with default styling:

```javascript
clipboard('pre');
```
A callback function with parameters representing, for each `selectors`, the `clipboard` and the selected `element`.

## Contributing

Expand Down

0 comments on commit 1805ebf

Please sign in to comment.