Velvet Thunder

Select

Sizes

<DemoSpaceX>
  <VelvetSelect @size="sm" as |select|>
    <select.Option @value="first">First</select.Option>
    <select.Option @value="second">Second</select.Option>
    <select.Option @value="third">Third</select.Option>
  </VelvetSelect>
  <VelvetSelect @size="md" as |select|>
    <select.Option @value="first">First</select.Option>
    <select.Option @value="second">Second</select.Option>
    <select.Option @value="third">Third</select.Option>
  </VelvetSelect>
  <VelvetSelect @size="lg" as |select|>
    <select.Option @value="first">First</select.Option>
    <select.Option @value="second">Second</select.Option>
    <select.Option @value="third">Third</select.Option>
  </VelvetSelect>
</DemoSpaceX>

Selected

<VelvetSelect @selected="second" as |select|>
  <select.Option @value="first">First</select.Option>
  <select.Option @value="second">Second</select.Option>
  <select.Option @value="third">Third</select.Option>
</VelvetSelect>

Pill

<VelvetSelect @isPill={{true}} as |select|>
  <select.Option @value="first">First</select.Option>
  <select.Option @value="second">Second</select.Option>
  <select.Option @value="third">Third</select.Option>
</VelvetSelect>

Disabled

<VelvetSelect @isDisabled={{true}} as |select|>
  <select.Option @value="first">First</select.Option>
  <select.Option @value="second">Second</select.Option>
  <select.Option @value="third">Third</select.Option>
</VelvetSelect>

Invalid

<VelvetSelect @isInvalid={{true}} as |select|>
  <select.Option @value="first">First</select.Option>
  <select.Option @value="second">Second</select.Option>
  <select.Option @value="third">Third</select.Option>
</VelvetSelect>

Examples

Handle Change Events

Edit this demo

Use the @onChange argument to handle change events.

Selected:
<DemoSpaceY>
  <div>Selected: {{this.selected}}</div>
  <VelvetSelect
    @onChange={{this.onChange}}
    @placeholder="Select an Option"
    @selected={{this.selected}}
    as |select|
  >
    <select.Option @value="first">First</select.Option>
    <select.Option @value="second">Second</select.Option>
    <select.Option @value="third">Third</select.Option>
  </VelvetSelect>
</DemoSpaceY>

Testing

Use the velvetSelect test helper to select a specific value for a VelvetSelect component.

import { velvetSelect } from "@bagaar/velvet-thunder/test-support";

// Select by index:
await velvetSelect(".velvet-select", { index: 0 });

// Select by text:
await velvetSelect(".velvet-select", { text: "First" });

Signature

Element

HTMLSelectElement

Blocks

NameDescriptionType
:default *The options of the select.[{ Option: WithBoundArgs<typeof VelvetSelectOption, 'privateOnCreate' | 'privateOnDestroy' | 'privateSelected'>; }]
Blocks marked with * are required.

Arguments

NameDescriptionTypeDefault Value
@isDisabledIndicate if the select is disabled.booleanfalse
@isInvalidIndicate if the select is invalid.booleanfalse
@isPillIndicate if the select is pill shaped.booleanfalse
@onChangeHandle the select's `change` event.(selected: unknown, event: Event) => voidundefined
@placeholderThe placeholder of the select.string""
@selectedThe selected option of the select.unknownundefined
@sizeThe size of the select.'sm' | 'md' | 'lg'"md"
@variantThe appearance of the select.string | 'primary'"primary"
Arguments marked with * are required.

Option Signature

Element

HTMLOptionElement

Blocks

NameDescriptionType
:default *The label of the option.[]
Blocks marked with * are required.

Arguments

NameDescriptionTypeDefault Value
@value *The value of the option.unknownundefined
Arguments marked with * are required.
Radio Group
Spinner