Swarm Design System Documentation

Select


A wrapper for an html <select> element with an optional <label> tag and helper text.



Snippet


Use this interactive snippet to try the component:


<div style={{width: 200}}>
    <FieldLabel htmlFor="swarm-select" >Swarm Select</FieldLabel>
    <Select
        value="A"
        id="swarm-select"
        name="swarm-select"
        onChange={(e) => alert(e.target.value)}
    >
        <option value="A">
            A
        </option>
        <option value="B">
            B
        </option>
        <option value="C">
            C
        </option>
        <option value="D">
            D
        </option>
    </Select>
</div>


Props



NameTypeRequired?DefaultDescription
disabled
booleanoptionalnoneWhether the select menu is disabled.
error
stringoptionalnoneWhether the select menu has errored.
id
stringoptionalnoneUnique identifier for select tag.
name
stringrequirednoneName of select menu form field.
requiredText
stringoptionalnoneCopy to be used for a required select field.


a11y



The following keyboard interactions are used to control the select component. You can also filter by typing letters, but this behavior varies by browser. Some will filter as you type, like autocomplete. Others will only sort by first letter. E.g., in a list of US States, hitting A then R may take you to Arizona, or it may take you to Alabama and then Rhode Island.


Keyboard interactions:

  • ↑/↓ ... navigate between menu options
  • Spacebar ... expand

See: https://webaim.org/techniques/keyboard/

Examples






Line of helper text to describe the input.

alert--smallalertannounce--smallannouncearchive--smallarchivearrow-left--smallarrow-leftarrow-right--smallarrow-rightaudio--smallaudiobadge--smallbadgeblock--smallblockbolt--smallboltcalendar--smallcalendar-check--smallcalendar-checkcalendar-cross--smallcalendar-crosscalendar-plus--smallcalendar-pluscalendarcamera--smallcameracheck--smallcheck-circle--smallcheck-circlecheckchevron-down--smallchevron-downchevron-left--smallchevron-leftchevron-right--smallchevron-rightchevron-up--smallchevron-upclock--smallclock-arrow--smallclock-arrowclockcog--smallcogconversation--smallconversationcopy--smallcopycreditcard--smallcreditcardcross--smallcross-circle--smallcross-circlecross-circled--smallcross-circledcrossdownload--smalldownloaddrinks--smalldrinksedit--smalleditexport--smallexportexternal-facebookexternal-facebookboxedexternal-flickrexternal-gmailexternal-instagramexternal-linkedinexternal-mediumexternal-messenger-outlined--smallexternal-messenger-outlinedexternal-outlookexternal-tumblrexternal-twitter-outlined--smallexternal-twitter-outlinedexternal-twitterexternal-yahooexternal-youtubefilter--smallfilterfolder--smallfolderglobe--smallglobegrid--smallgridgroups--smallgroupsheart--smallheart-outline--smallheart-outlinehearthide--smallhidehome--smallhomeinfo--smallinfoinvite--smallinvite-filled--smallinvite-filledinvitelaunch-new-window--smalllaunch-new-windowlink--smalllinklist--smalllistlocation-pin--smalllocation-pin-filled--smalllocation-pin-filledlocation-pin-slashed--smalllocation-pin-slashedlocation-pinlocation-services--smalllocation-serviceslock--smalllockmail--smallmailmeetup-m--smallmeetup-mmessages--smallmessagesmicrophone--smallmicrophoneminus--smallminusnotifications--smallnotifications-badged--smallnotifications-badgednotifications-mute--smallnotifications-mutenotificationsoverflow--smalloverflow-vertical--smalloverflow-verticaloverflowphoto-album--smallphoto-album-add--smallphoto-album-addphoto-albumplay--smallplayplus--smallplus-circle--smallplus-circleplusprofile--smallprofileprofiles--smallprofilesprojector--smallprojectorpulse--smallpulserefresh--smallrefreshreply--smallreplysearch--smallsearchsend--smallsendsent-messages--smallsent-messagesshow--smallshowsort-direction--smallsort-directionstar--smallstar-rounded--smallstar-roundedstartextblock--smalltextblockticket--smalltickettrash--smalltrashtune--smalltunetv--smalltvupdates--smallupdateswifi--smallwifi