Text fields within the system have a standard size and a compact size. Our fields are outlined and become activated with our primary color using the rules we set up in our affordances. These components have several elements, not all of which are required.
Pikachu
Squirtle
Charmander
What's your favorite Pokémon?
<div class="ray-dropdown">
<div class="ray-dropdown__wrapper">
<select class="ray-dropdown__input" id="test">
<option value="Pikachu">Pikachu</option>
<option value="Squirtle">Squirtle</option>
<option value="Squirtle">Charmander</option>
</select>
</div>
<label class="ray-dropdown__label" for="test">
What's your favorite Pokémon?
</label>
</div>
Show less code
icons With placeholder
Choose pokemon?
Slowpoke
Pikachu
Squirtle
Charmander
Sonichu
Pokemon
<div class="ray-dropdown">
<div class="ray-dropdown__wrapper">
<select class="ray-dropdown__input" id="test-placeholder" value="">
<option value="" data-ray-placeholder>
Choose pokemon?
</option>
<option value="Slowpoke">Slowpoke</option>
<option value="Pikachu">Pikachu</option>
<option value="Squirtle">Squirtle</option>
<option value="Charmander" disabled>
Charmander
</option>
<option value="Sonichu">Sonichu</option>
</select>
</div>
<label class="ray-dropdown__label" for="test-placeholder">
Pokemon
</label>
</div>
Show less code
Pikachu
Squirtle
Charmander
What's your favorite Pokémon?
<div class="ray-dropdown ray-dropdown--compact">
<div class="ray-dropdown__wrapper">
<select class="ray-dropdown__input" id="test-compact">
<option value="Pikachu">Pikachu</option>
<option value="Squirtle">Squirtle</option>
<option value="Squirtle">Charmander</option>
</select>
</div>
<label class="ray-dropdown__label" for="test-compact">
What's your favorite Pokémon?
</label>
</div>
Show less code
Pikachu
Charmander
Squirtle
Meowt
Wobbuffet
Magikarp
Slowpoke
Sonichu
Pokemon
<div class="ray-dropdown">
<div class="ray-dropdown__wrapper">
<select class="ray-dropdown__input" id="test-optgroups" value="">
<optgroup label="Ash">
<option value="Pikachu">Pikachu</option>
<option value="Charmander">Charmander</option>
<option value="Squirtle">Squirtle</option>
</optgroup>
<optgroup label="R Team">
<option value="Meowt">Meowt</option>
<option value="Wobbuffet">Wobbuffet</option>
<option value="Magikarp">Magikarp</option>
</optgroup>
<optgroup label="Others" disabled>
<option value="Slowpoke">Slowpoke</option>
<option value="Sonichu">Sonichu</option>
</optgroup>
</select>
</div>
<label class="ray-dropdown__label" for="test-optgroups">
Pokemon
</label>
</div>
Show less code
Pikachu
Squirtle
Charmander
What's your favorite Pokémon?
Is anything wrong?
<div class="ray-dropdown ray-dropdown--error">
<div class="ray-dropdown__wrapper">
<select class="ray-dropdown__input" id="test-error">
<option value="Pikachu">Pikachu</option>
<option value="Squirtle">Squirtle</option>
<option value="Squirtle">Charmander</option>
</select>
<label class="ray-dropdown__label" for="test-error">
What's your favorite Pokémon?
</label>
</div>
</div>
<span class="ray-dropdown__hint">Is anything wrong?</span>
Show less code
😜
Choose pokemon?
Slowpoke
Pikachu
Squirtle
Charmander
Sonichu
Pokemon
<div class="ray-dropdown ray-dropdown--with-icon-start">
<div class="ray-dropdown__icon--start">😜</div>
<div class="ray-dropdown__wrapper">
<select
class="ray-dropdown__input"
id="test-icon"
required
aria-required="true"
>
<option value="" data-ray-placeholder>
Choose pokemon?
</option>
<option value="Slowpoke">Slowpoke</option>
<option disabled data-ray-separator />
<option value="Pikachu">Pikachu</option>
<option value="Squirtle">Squirtle</option>
<option value="Charmander">Charmander</option>
<option value="Sonichu">Sonichu</option>
</select>
</div>
<label class="ray-dropdown__label" for="test-icon">
Pokemon
</label>
</div>
Show less code
icons Dropdown (RTL)
Pikachu
Squirtle
Charmander
What's your favorite Pokémon?
<div dir="rtl">
<div class="ray-dropdown">
<div class="ray-dropdown__wrapper">
<select class="ray-dropdown__input" id="rtl-test">
<option value="Pikachu">Pikachu</option>
<option value="Squirtle">Squirtle</option>
<option value="Squirtle">Charmander</option>
</select>
</div>
<label class="ray-dropdown__label" for="rtl-test">
What's your favorite Pokémon?
</label>
</div>
</div>
Show less code
icons With Placeholder (RTL)
Choose pokemon?
Slowpoke
Pikachu
Squirtle
Charmander
Sonichu
Pokemon
<div dir="rtl">
<div class="ray-dropdown">
<div class="ray-dropdown__wrapper">
<select class="ray-dropdown__input" id="rtl-test-placeholder" value="">
<option value="" data-ray-placeholder>
Choose pokemon?
</option>
<option value="Slowpoke">Slowpoke</option>
<option disabled data-ray-separator />
<option value="Pikachu">Pikachu</option>
<option value="Squirtle">Squirtle</option>
<option value="Charmander" disabled>
Charmander
</option>
<option value="Sonichu">Sonichu</option>
</select>
</div>
<label class="ray-dropdown__label" for="rtl-test-placeholder">
Pokemon
</label>
</div>
</div>
Show less code
icons Compact (RTL)
Pikachu
Squirtle
Charmander
What's your favorite Pokémon?
<div dir="rtl">
<div class="ray-dropdown ray-dropdown--compact">
<div class="ray-dropdown__wrapper">
<select class="ray-dropdown__input" id="rtl-test-compact">
<option value="Pikachu">Pikachu</option>
<option value="Squirtle">Squirtle</option>
<option value="Squirtle">Charmander</option>
</select>
</div>
<label class="ray-dropdown__label" for="rtl-test-compact">
What's your favorite Pokémon?
</label>
</div>
</div>
Show less code
icons Optgroups (RTL)
Pikachu
Charmander
Squirtle
Meowt
Wobbuffet
Magikarp
Slowpoke
Sonichu
Pokemon
<div dir="rtl">
<div class="ray-dropdown">
<div class="ray-dropdown__wrapper">
<select class="ray-dropdown__input" id="rtl-test-groups" value="">
<optgroup label="Ash">
<option value="Pikachu">Pikachu</option>
<option value="Charmander">Charmander</option>
<option value="Squirtle">Squirtle</option>
</optgroup>
<optgroup label="R Team">
<option value="Meowt">Meowt</option>
<option value="Wobbuffet">Wobbuffet</option>
<option value="Magikarp">Magikarp</option>
</optgroup>
<optgroup label="Others" disabled>
<option value="Slowpoke">Slowpoke</option>
<option value="Sonichu">Sonichu</option>
</optgroup>
</select>
</div>
<label class="ray-dropdown__label" for="rtl-test-groups">
Pokemon
</label>
</div>
</div>
Show less code
icons Error (RTL)
Pikachu
Squirtle
Charmander
What's your favorite Pokémon?
Is anything wrong?
<div dir="rtl">
<div class="ray-dropdown ray-dropdown--error">
<div class="ray-dropdown__wrapper">
<select class="ray-dropdown__input" id="rtl-test-error">
<option value="Pikachu">Pikachu</option>
<option value="Squirtle">Squirtle</option>
<option value="Squirtle">Charmander</option>
</select>
</div>
<label class="ray-dropdown__label" for="rtl-test-error">
What's your favorite Pokémon?
</label>
</div>
<span class="ray-dropdown__hint">Is anything wrong?</span>
</div>
Show less code
icons With Icon (RTL)
😜
Choose pokemon?
Slowpoke
Pikachu
Squirtle
Charmander
Sonichu
Pokemon
<div dir="rtl">
<div class="ray-dropdown ray-dropdown--with-icon-start">
<div class="ray-dropdown__icon--start">😜</div>
<div class="ray-dropdown__wrapper">
<select
class="ray-dropdown__input"
id="rtl-test-icon"
required
aria-required="true"
>
<option value="" data-ray-placeholder>
Choose pokemon?
</option>
<option value="Slowpoke">Slowpoke</option>
<option disabled data-ray-separator />
<option value="Pikachu">Pikachu</option>
<option value="Squirtle">Squirtle</option>
<option value="Charmander">Charmander</option>
<option value="Sonichu">Sonichu</option>
</select>
</div>
<label class="ray-dropdown__label" for="rtl-test-icon">
Pokemon
</label>
</div>
</div>
Show less code
icons JavaScript API
import { Dropdown } from '@wework/ray-core' ;
Dropdown. createAll ( ) ;
const dropdown = Dropdown. create ( document. querySelector ( '.ray-dropdown' ) ) ;
dropdown. set ( 'Charmander' ) ;
dropdown. destroy ( ) ;
dropdown. open ( ) ;
Method Params Description Dropdown.createAll
HTMLElement:Object
create all instances in document Dropdown.create
HTMLElement:Object
create an instance Dropdown.prototype.destroy
destroy the instance Dropdown.prototype.set
value:string
sets the value of the instance Dropdown.prototype.clear
clear the value of the instance Dropdown.prototype.enable
makes instance enabled (active) Dropdown.prototype.disable
makes instance disabled (inactive) Dropdown.prototype.open
opens dropdown list programmatically
Use these modifiers with .ray-dropdown
class.
Selector Description .ray-dropdown--compact
Selector for applying compact dropdown styles .ray-dropdown--error
Selector for applying error styles .ray-dropdown--simple
Selector for applying removing styles when Dropdown is in prepend section