gradio/ui/packages/form/src/Dropdown.svelte

31 lines
764 B
Svelte
Raw Normal View History

2022-03-03 00:42:43 +08:00
<script lang="ts">
import { createEventDispatcher } from "svelte";
import { Block, BlockTitle } from "@gradio/atoms";
2022-03-03 00:42:43 +08:00
export let label: string;
export let value: string | undefined = undefined;
export let choices: Array<string>;
export let style: string = "";
export let disabled: boolean = false;
export let form_position: "first" | "last" | "mid" | "single" = "single";
2022-03-03 00:42:43 +08:00
const dispatch = createEventDispatcher<{ change: string }>();
$: dispatch("change", value);
2022-03-03 00:42:43 +08:00
</script>
<Block {form_position}>
<label>
<BlockTitle>{label}</BlockTitle>
<select
class="gr-box gr-input w-full disabled:cursor-not-allowed"
bind:value
{disabled}
>
2022-03-03 00:42:43 +08:00
{#each choices as choice, i}
<option>{choice}</option>
2022-03-03 00:42:43 +08:00
{/each}
</select>
</label>
</Block>