# Widgets

A club's list of unavailable players on your site: two lines of HTML, no account, no key. The widget loads in the background, updates itself and can't break your page's layout.

## Quickstart

Put the element where the widget should appear, and the script once anywhere on the page:

```html
<sidelined-widget team="zug"></sidelined-widget>
<script async src="https://embed.sidelined.ch/v1.js"></script>
```

That's it. The `team` is the club's slug from the table below.

## Playground

Try the variants and themes live on https://developers.sidelined.ch/widgets.
## Options

| Attribute | Values | Default |
|---|---|---|
| `team` | a club's slug (required) | |
| `variant` | `list` (players, reason, expected return) or `badge` (the count and names) | `list` |
| `theme` | `light`, `dark` or `auto` (follows the reader's setting) | `auto` |
| `limit` | how many players the list shows before "+N more", 1–20 | `5` |

Change an attribute later (for example with JavaScript) and the widget redraws.

## Clubs

| Slug | Club |
|---|---|
| `biel` | EHC Biel-Bienne |
| `kloten` | EHC Kloten |
| `zug` | EV Zug |
| `fribourg` | Fribourg-Gottéron |
| `geneve` | Genève-Servette HC |
| `ajoie` | HC Ajoie |
| `ambri` | HC Ambrì-Piotta |
| `davos` | HC Davos |
| `lugano` | HC Lugano |
| `lausanne` | Lausanne HC |
| `bern` | SC Bern |
| `langnau` | SCL Tigers |
| `rapperswil` | SCRJ Lakers |
| `zsc` | ZSC Lions |
`GET https://api.sidelined.ch/v1/teams` returns the same list.

## Without JavaScript: the iframe

Some content management systems remove scripts. The same widget works as an iframe:

```html
<iframe src="https://embed.sidelined.ch/zug?variant=list&limit=5"
        title="EV Zug: who's out" width="100%" height="420" style="border:0"></iframe>
```

The iframe can't size itself to its content, so give it a height: about 80 px per player plus 120 px, or 140 px for the badge.

## Content Security Policy

If your site restricts where scripts and requests may go, allow `embed.sidelined.ch`:

```
script-src https://embed.sidelined.ch;
connect-src https://embed.sidelined.ch;
img-src https://sidelined.ch;
frame-src https://embed.sidelined.ch;   (only for the iframe)
```

## Attribution

Every widget shows the sources and "Data: sidelined.ch" with a link to the club's page. It's part of the widget and can't be switched off; hiding it breaks the [terms of use](/terms).

## Privacy

The widget sets no cookies, loads nothing from third parties and doesn't track your readers. sidelined.ch counts how often widgets are shown per website (the site's host name only), to know where they're used.

## How it works

The script defines the `<sidelined-widget>` element. For each one, it loads the finished widget (HTML with its own styles) from `embed.sidelined.ch/{team}.html` into the element's Shadow DOM, so your page's CSS and the widget's can't interfere. The script is under 1 KB. Breaking changes get a new address (`/v2.js`); `v1.js` stays as it is.

## Questions

**How fresh is it?** The sources are read every 15 to 30 minutes; widgets are cached for a minute.

**Can I style it?** Choose `light`, `dark` or `auto`. For a fully custom design, use the [API](/api).

**Is it free for commercial sites?** Yes, with the attribution in place. See the [terms](/terms).
