logo-icon
Button
Basic


svelte
<script lang="ts">
	import { Button } from 'stwui';
</script>

<Button on:click={() => console.log("I've been clicked!")}>Default button</Button>
<Button type="primary">I am primary</Button>
<Button type="danger">I am scary</Button>
<Button type="ghost">Boo I am a ghost</Button>
<Button type="link">I am a link</Button>
Loading


svelte
<script lang="ts">
	import { Button } from 'stwui';
</script>

<Button loading>Default button</Button>
<Button type="primary" loading>I am primary</Button>
<Button type="danger" loading>I am scary</Button>
<Button type="ghost" loading>Boo I am a ghost</Button>
<Button type="link" loading>I am a link</Button>
Disabled


svelte
<script lang="ts">
	import { Button } from 'stwui';
</script>

<Button disabled>Default button</Button>
<Button type="primary" disabled>I am primary</Button>
<Button type="danger" disabled>I am scary</Button>
<Button type="ghost" disabled>Boo I am a ghost</Button>
<Button type="link" disabled>I am a link</Button>
Leading & Trailing


svelte
<script lang="ts">
	import { Button } from 'stwui';
</script>

<Button>
	<Button.Leading slot="leading">
		<Button.Leading.Icon icon="paid" />
	</Button.Leading>
	Default Button
</Button>

<Button>
   Default Button
	<Button.Trailing slot="trailing">
		<Button.Trailing.Icon icon="paid" />
	</Button.Trailing>
</Button>
Shape


svelte
<script lang="ts">
	import { Button } from 'stwui';
</script>

<Button shape="circle" on:click={toggleLoading} {loading}>
	<Button.Icon slot="icon" icon="paid" />
</Button>

<Button type="primary" shape="square">I am primary</Button>

<Button type="danger" shape="rounded">I am scary</Button>

<Button type="ghost">Boo I am a ghost</Button>

<Button type="link">I am a link</Button>
Swap Icon


svelte
<script lang="ts">
	import { Button, Swap } from 'stwui';

   let loading = false;

   function toggleLoading() {
      loading = !loading;
   }
</script>

<Button shape="circle" on:click={toggleLoading}>
   <Swap slot="icon" {loading}>
      <Icon slot="on" icon="menu" />
      <Icon slot="off" icon="close" />
   </Swap>
</Button>

<Button type="primary">
   <Button.Leading slot="leading">
      <Swap {loading}>
         <Icon slot="on" icon="menu" />
         <Icon slot="off" icon="close" />
      </Swap>
   </Button.Leading>
   I am primary
</Button>
Sizes

Button Props

disabled boolean false
htmlType 'button' | 'submit' | 'reset' button
loading boolean false
defaultLoading boolean true
type 'default'| 'primary' | 'danger' | 'ghost' | 'link' | 'text' | 'dark' | undefined
shape 'square' | 'circle' | 'rounded' | 'pill' rounded
size 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'fab' md

Button Slots

leading <Button.Leading slot="leading" />
icon <Button.Icon slot="icon" />
default
trailing <Button.Trailing slot="trailing" />

Button.Leading Slots

icon <Button.Leading.Icon slot="icon" />
default

Button.Leading.Icon Props

Button.Icon Props

Button.Trailing Slots

icon <Button.Leading.Icon slot="icon" />
default

Button.Trailing.Icon Props