Skip to content

Commit

Permalink
common: Document how to style the iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed Apr 17, 2022
1 parent 689cb58 commit 7dce3ed
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,51 @@ The attribute names are the same as the `data-` attributes shown on the
[giscus website][giscus], but written in lowercase with the `data-` prefix and
dashes removed.

### Changing the `<iframe>` styles

You can style the `<iframe>` in your CSS by selecting the web component, or the
`iframe` part specifically. For example:

```css
giscus-widget {
display: flex;
margin: auto;
max-width: 640px;
}
/* or... */
#comments {
/* ... */
}
/* or... */
#comments::part(iframe) {
/* ... */
}
/* etc. */
```

You can also make the widget scrollable by creating a parent container with a
limited height and `overflow: scroll`, for example:

```html
<div class="comments-container">
<giscus-widget
...
>
</giscus-widget>
</div>
```

```css
.comments-container {
max-height: 640px;
overflow-y: scroll;
}
```

Note that this only allows you to style the `<iframe>` element and
**not the iframe's contents**. If you want to style the contents, you need to
[use a custom theme][custom-theme].

### Notes

When you change the props/attributes of the React, Vue, and web components, they
Expand Down Expand Up @@ -136,6 +181,7 @@ Released under the [MIT](./LICENSE) license.
[skypack]: https://skypack.dev
[demo]: https://giscus-component.vercel.app
[advanced-usage]: https://github.com/giscus/giscus/blob/main/ADVANCED-USAGE.md
[custom-theme]: https://github.com/giscus/giscus/blob/main/ADVANCED-USAGE.md#data-theme
[web-vbadge]: https://img.shields.io/npm/v/giscus.svg
[react-vbadge]: https://img.shields.io/npm/v/@giscus/react.svg
[vue-vbadge]: https://img.shields.io/npm/v/@giscus/vue.svg
Expand Down

1 comment on commit 7dce3ed

@vercel
Copy link

@vercel vercel bot commented on 7dce3ed Apr 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

giscus-component – ./

giscus-component.vercel.app
giscus-component-git-main-giscus.vercel.app
giscus-component-giscus.vercel.app

Please sign in to comment.