summaryrefslogtreecommitdiff
path: root/examples/component/packages/my-component/README.md
blob: 41a53a6f050f50b503d734c1fb0469d6a71a096f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Example `@example/my-component`

This is an example package, exported as `@example/my-component`. It consists of two Astro components, **Button** and **Heading**.

### Button

The **Button** component generates a `<button>` with a default **type** of **button**.

```astro
---
import * as Component from '@example/my-component'
---
<Component.Button>Plain Button</Component.Button>
```

```html
<!-- generated html -->
<button type="button">Plain Button</button>
```

### Heading

The **Heading** component generates an `<h>` tag with a default **role** of **heading** and a **level** attribute that gets written to **aria-level**.

```astro
---
import * as Component from '@example/my-component'
---
<Component.Heading>Heading</Component.Heading>
<Component.Heading level="2">Subheading</Component.Heading>
```

```html
<!-- generated html -->
<h role="heading" aria-level="1">Plain Button</h>
<h role="heading" aria-level="2">Subheading</h>
```