carbon-components-svelte/tests/FilterableComboBox.test.svelte
2024-11-11 21:35:48 -08:00

19 lines
456 B
Svelte

<script lang="ts">
import { ComboBox } from "carbon-components-svelte";
function shouldFilterItem(item: { text: string }, value?: any) {
if (!value) return true;
return item.text.toLowerCase().includes(value.toLowerCase());
}
</script>
<ComboBox
titleText="Contact"
placeholder="Select contact method"
items={[
{ id: "0", text: "Slack" },
{ id: "1", text: "Email" },
{ id: "2", text: "Fax" },
]}
{shouldFilterItem}
/>