-
-
Notifications
You must be signed in to change notification settings - Fork 284
/
Copy path_SmuiElement.svelte
38 lines (31 loc) · 1.16 KB
/
_SmuiElement.svelte
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
38
<!--
When a component takes a `tag` prop, it means it also takes a `component` prop
and that `SmuiElement` is the default component.
Note: not all SMUI components can take a `component` or `tag` prop.
-->
<div>
<Button tag="div" bind:this={DivButton as Button<undefined, 'div'>}
><Label>I'm a <div /> Button</Label></Button
>
<Button tag="span"><Label>I'm a <span /> Button</Label></Button>
<Button tag="strong"><Label>I'm a <strong /> Button</Label></Button>
<Button tag="em"><Label>I'm a <em /> Button</Label></Button>
</div>
<div>
<SmuiElement tag="em"
>I'm rendered as a HTML <code>em</code> element!</SmuiElement
>
</div>
<script lang="ts">
import { SmuiElement } from '@smui/common';
import Button, { Label } from '@smui/button';
import { onMount } from 'svelte';
// When you change the tag, you can use the generic type argument to get the
// right element from `getElement`. The first arg for Button is "href".
let DivButton: Button<undefined, 'div'>;
let DivButtonElement: HTMLDivElement;
onMount(() => {
DivButtonElement = DivButton.getElement();
console.log(DivButtonElement);
});
</script>