# Unstyled Web Components

[Find the docs here](https://hesxenon.gitlab.io/unstyled-web-components/)

A repository of custom elements that _don't_ use the
shadow dom and can thusly be easily styled.
For guides just open the `index.html` in the respective components folders.

## Requirements

- A Baseline2023 compatible browser
- support for position anchors (can be polyfilled with `@oddbird/css-anchor-positioning`)

## Usage

### In Browser

load uwc by adding this to your htmls `<head>`:

```html
<!-- defer is necessary if you serve some uwc component along with the full html -->
<script
  defer
  src={`https://unpkg.com/unstyled-web-components@${version}/dist/index.js`}
></script>

<!-- default styling, i.e. the "user agent stylesheet". I'd recommend including this. -->
<link
  rel="stylesheet"
  href={`https://unpkg.com/unstyled-web-components@${version}/dist/index.css`}
/>
```

### With a bundler

Include an ambient import as close to your entrypoint as possible. Depending on
your final configuration you should not forget to externalize this dependency.

```typescript
import "unstyled-web-components";
```

## Integrating with React

Integration with react proves somewhat tricky because of the synthetic event bus react uses.

See [this blog post](https://gideonpyzer.dev/blog/2018/12/29/event-propagation-react-synthetic-events-vs-native-events/) for details.

Other than that it should work fine as long as you don't try to `.preventDefault` and such.

Do note however that there is no such thing as _defaultValue_ available since react obviously doesn't
wrap the uwc elements as it does the native elements so setting default values will probably need
a wrapper that utilizes refs.
