logo-icon
STWUI

Dropdown


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

   let visible = false;

	function closeDropdown() {
		console.log('do something');
		visible = false;
	}

	function toggleDropdown() {
		visible = !visible;
	}
</script>

<Dropdown bind:visible={visible1}>
	<Button slot="trigger" type="primary" on:click={toggleDropdown1}>Toggle Dropdown</Button>
	<Dropdown.Items slot="items">
		<Dropdown.Items.Item on:click={closeDropdown1} label="Item 1">
			<Dropdown.Items.Item.Icon slot="icon" data={trash} />
		</Dropdown.Items.Item>
		<Dropdown.Items.Item on:click={closeDropdown1} label="Item 2">
			<Dropdown.Items.Item.Icon slot="extra" data={trash} />
		</Dropdown.Items.Item>
		<Dropdown.Items.Item on:click={closeDropdown1} label="Notifications">
			<Badge type="info" slot="extra">+99</Badge>
		</Dropdown.Items.Item>
		<Dropdown.Items.Divider />
		<Button type="danger" class="w-full justify-between">
			<Button.Leading slot="leading" data={home} />
			Home
			<Button.Trailing slot="trailing" data={home} />
		</Button>
	</Dropdown.Items>
</Dropdown>

Dropdown Props

visible boolean false

Dropdown Slots

trigger
items <Dropdown.Items slot="items" />

Dropdown.Items Props

placement 'left' | 'right' left

Dropdown.Items Slots

default <Dropdown.Items.Item />

Dropdown.Items.Item Props

label string

Dropdown.Items.Item Slots

icon <Dropdown.Items.Item.Icon slot="icon" />
extra

Dropdown.Items.Item.Icon Props

data string (IconData)
viewBox string 0 0 24 24
size string 24px
width string 24px
height string 24px
color string currentColor
stroke string | undefined
fill string currentColor