Button
A component that can switch between a button and an anchor tag based on the href prop.
Usage
<script lang="ts">
import { Button } from 'uisv';
</script>
<Button
label="Button"
class="border px-4 h-8 border-surface-accented transition-all text-sm font-medium
hover:bg-surface-muted active:translate-y-0.5"
/>
<Button
icon="i-lucide:arrow-up"
class="border size-8 grid place-items-center border-surface-accented transition-all
hover:bg-surface-muted active:translate-y-0.5"
/>Loading state
Use loadingauto to automatically show a spinner while the onclick handler's
Promise is pending.
<Button label="Button" onclick={async_fn} />
<Button icon="i-lucide:arrow-up" onclick={async_fn} />Link
You can pass href to render as a link, as well as any anchor property.
<Button href="/components" label="Components" />
<Button href="https://github.com/ui-sv/uisv" icon="i-lucide:github" />API References
Props
| Prop | Type | Description |
|---|---|---|
|
| The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: |
|
| The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: --- |
|
| String version of the children snippet. Easier if you want to self close the button tag. Default: --- |
|
| Icon name to render with iconify syntax naming. Default: --- |
|
| Which position you want to display the icon. Default: --- |
|
| When you need a trailing icon. Default: --- |
|
| An optional prop that when passed converts the button into an anchor tag. Default: --- |
|
| Automatically set icon to a spinner icon. Default: |
|
| Default: --- |
Snippets
| Snippet | Props | Description |
|---|---|---|
| --- | When you need more than just text. |
| --- | An optional snippet when you want more than a trailing icon. |
| --- | An optional snippet when you want more than a leading icon. |
UI
| Key | Class | Data attrs |
|---|---|---|
|
| The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: |
|
| The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: --- |
|
| String version of the children snippet. Easier if you want to self close the button tag. Default: --- |
|
| Icon name to render with iconify syntax naming. Default: --- |
|
| Which position you want to display the icon. Default: --- |
|
| When you need a trailing icon. Default: --- |
|
| An optional prop that when passed converts the button into an anchor tag. Default: --- |
|
| Automatically set icon to a spinner icon. Default: |
|
| Default: --- |