Skip to main content
Brand and assets
Build
Monitor and contribute
/
Component library
  • All components
  • Buttons & actions
  • Forms & inputs
    • Checkbox
    • ChoiceGroup
    • CurrencyInput
    • DateInput
    • FileInputZone
    • Filters
    • Form
    • MaskedTextInput
    • PasswordInput
    • Pill
    • Pill
    • Radio
    • SearchInput
    • SegmentedSlider
    • Select
    • Switch
    • TextArea
    • TextInput
  • Layout & containers
  • Overlays
  • Feedback & status
  • Data display
  • Typography
  • Accessibility
  • Contrib
  • Deprecated
  • Forms & inputs
  • SearchInput

SearchInput

Captures a search query, with an icon for the search state and a button to clear it.

Health
Component health
Source
View on Github
Design
View Figma
Storybook
View in Storybook
Playground
No Example
Accessibility

partially-compliant

Platform
Universal
Accessibility issues
the reset button misses an aria-label attribute
  • Overview
  • Props
  • Figma

Usage​

This is a particular TextInput to capture a search query from the user. There is a side icon to indicate the search action or progress. There is a reset button to clear the input.

Basic Usage​

Progress​

You can give feedback to the user by showing a progress indicator.

Reset Button​

You can add a reset button to clear the input.

Smallest Size​

By default, the size of the SearchInput is md, which is 46px in height. You can align it to the small button size by specifying the sm size.

Accessibility​

You need to provide a label, a placeholder or an aria-label, so the field has an accessible name. A renderPlaceholder cannot be read as text, so it always comes with a label or an aria-label.

RAWeb 1.1 criterion 11.1 never accepts a placeholder as a label: it is not exposed as one, and it disappears as soon as the user types. Two tests apply to a search field, and they ask different things:

  • 11.1.1 wants an accessible name, which a label, an aria-label or a title all provide.
  • 11.1.3 wants that name readable on screen when it is not visible, which only a title or text sitting next to the field provides. An aria-label alone does not close it.

So without a visible label, SearchInput copies the placeholder into the title attribute. That covers 11.1.3 on its own, and the RGAA requires the two to be identical when both are set, which holds here by construction. Nothing to pass, and the hover tooltip is the only visible change.

Pass an aria-label on top when the placeholder lists what can be typed rather than naming the field. It becomes the accessible name, so a screen reader announces the purpose then the expected input, and criterion 11.2 is then judged on it rather than on the title:

<SearchInput aria-label="Search for an employee" placeholder="Name, email, employee ID" />

label and aria-label cannot be combined, since the aria-label would replace the visible label as the accessible name. A visible label also drops the title, which would only repeat it.

Playground​

Loading...
tip
This component is universal, its usage is the same in murray and murray/mobile.

SearchInput props

NameTypeDefault ValueDescriptionUsage count
aria-describedbystringundefinedId of an element outside the input that also describes it, such as an error shared by several inputs
aria-labelstringundefinedAccessibility label, only necessary when not associated with a label Accessible name of the field, used when there is no `label`
aria-requiredbooleanundefinedOverrides `aria-required` set by `required`, to mark the input as mandatory without the asterisk
autoFocusbooleanundefinedIf true, focuses the input on componentDidMount.The default value is false.
cursorCursorundefinedEnforce a cursor type
defaultValuestringundefinedUncontrolled default value.
disabledbooleanundefinedDisable input
enterKeyHint
6 possibilities"search""done""go""next""send"undefined
errorReactNodeContents of `InputErrorNext` component, if not set, error is not rendered.
focusedbooleanundefinedShow focus styles even when the input isn't focused, e.g. while a readonly input's picker is open
groupLabelReactNodeName of the group the input belongs to, such as the date its day field is part of. VoiceOver and TalkBack don't announce it when focus lands on the input, so on native it ends the input's accessible name, after `label`. Ignored without a `label`.
helpTextReactNodeContents of `InputHelpTextNext` component, if not set, description is not rendered.
iconVisual
336 possibilities"Card""Menu""Accessible""AlanBlobHappy""AlanBlobHey""AlanBlobNoMouth""AlanBlobOpenMouth""AlanBlobSleeping""AlanLogo""Album""Alert""AlertAlt""Ambulance""AmbulanceSiren""Apple""AppleFilled""ArrowBottomLeft""ArrowBottomRight""ArrowDouble""ArrowDown""ArrowDownAlt""ArrowDropdown""ArrowDropright""ArrowDropup""ArrowLeft""ArrowLeftAlt""ArrowRight""ArrowRightAlt""ArrowTopLeft""ArrowTopRight""ArrowUp""ArrowUpAlt""ArrowUpDown""ArrowsLeftRight""Baby""BabyBottle""Back10""BadgeHeart""Bag""Bandaid""Bank""Bell""BellRinging""Bike""Bills""BirthdayCake""Block""BlurHeavy""BlurLight""BookHeart""Books""BooksAlt""BoxAdd""BoxArrowTopRight""Brain""Bubble""BubbleHeart""BubbleWithDots""Bus""Calculator""Calendar""CalendarClock""Camera""Cards""Carrot""ChatAdd""ChatAddFilled""ChatBubble""ChatDots""Check""CheckAlt""CheckboxActive""CheckboxInactive""Child""Children""Close""CloseAlt""CloudDownload""CloudUpload""Coffee""Company""Copy""Cross""DashboardMenuRight""DashboardMenuRightFilled""Devices""DockToBottom""DockToRight""Doctor""DoctorBag""Document""DocumentHeart""DotMenu""DoubleCheck""Driving""Drop""Dumbbells""Ear""Email""Enterprise""Euro""ExclamationMark""ExitFullscreen""ExternalLink""Eye""EyeOff""EyeOffStroke""FaceId""Facebook""FatArrowRight""FeatherPen""Female""FileUnknown""Filter""Finger""Flag""Flash""FlashDouble""FlashNo""FlashOutline""FlashYes""FlipCamera""Foot""Forward10""FrameProfile""FrameSearch""Fullscreen""Gender""Gift""GiftMind""Glasses""Globe""GlobeEarth""Graph""GraphicEq""Hand""HangUp""Heart""HeartAdd""HeartCheck""HeartStroke""HeartStrokeAdd""Home""HomeHeart""HomeMap""Hospital""HospitalMap""Hourglass""Intercom""Journal""Key""Keyboard""Label""LaptopHealth""Leaves""Levers""Lifebuoy""LightBulb""Link""Linkedin""List""Location""Lock""LockOpen""Lotus""MagnifyingGlass""Mail""Male""Map""MapLocation""Masterclass""MedicalChat""MedicalChatHeart""Medium""MenuDot""Mic""MicOff""Microscope""MindCard""MindInbox""MinusAlt""MobilePhone""Moon""MoonSleepy""MusicOff""MusicOffSingle""MusicOn""MusicOnSingle""NearMe""NewPost""NoFlash""NoSmoking""None""NoteAdd""Notion""PanelLeft""PanelLeftDashed""Paperclip""Paperplane""Pause""Payfit""PeachFilled""Pencil""People""PeopleTwo""PersonAdd""PersonRemove""Phone""PhoneHangUp""PhonePlus""Picture""Piggy""Pill""Pills""Play""Plus""PlusAlt""PrevenirLogo""Printer""Profile""ProfileSettings""Psychology""Quotes""RaisingHands""React""Refresh""Reply""Rotate""RotateBox""RoundedArrowDown""RoundedArrowLeft""RoundedArrowRight""RoundedArrowUp""RoundedCheck""RoundedCross""RoundedEmpty""RoundedExclamationMark""RoundedFull""RoundedHalf""RoundedHelp""RoundedHelpLine""RoundedInfo""RoundedInfoLine""RoundedLess""RoundedPlay""RoundedPlus""RoundedQuarter""RoundedThreeQuarters""RoundedWarning""Ruler""RulerFilled""Save""Scale""ScanBarcode""Screenshare""ScreenshareStop""Seringe""Settings""Share""ShareAndroid""ShareIos""ShareScreen""Shield""ShieldCog""ShieldHeart""Snowflake""SocialFb""SocialFbLine""SocialGoogle""SocialLinkedin""SocialLinkedinLine""SocialTwitter""SocialTwitterLine""Sparkles""Spiral""SplitLeft""SplitRight""SsoGoogle""SsoPsc""Star""Stethoscope""StoreBasket""StrawberryFilled""Subtitles""Subway""Sun""Swipe""Target""ThumbDownStroke""ThumbUpStroke""ThumbsDown""ThumbsUp""Tick""Time""TimeSimple""Tooth""ToothBrace""TouchId""TpCard""Tram""Transmission""TransportationBus""TransportationTrain""Trash""TreeGraph""TriangularExclamationMark""TurtleShell""Twitter""Umbrella""UmbrellaHeart""Undo""VideoCall""VideoHeart""VideoHorizontal""VideoHorizontalOutlined""VideoOff""VideoOn""VideoPlural""VideoVertical""VolumeOff""VolumeOn""VolumeUp""Walking""Wallet""Warning""WarningAlt""Wind""Work""WorkHeart""World""Wrench""X""ZoomIn""ZoomOut"nullundefined
idstringundefinedID of the input. Will use a generated id by default
label
80 possibilitiesundefinednullstringnumberbigintfalsetrueReactElement<unknown, stringJSXElementConstructor<any>>Iterable<ReactNode>ReactPortalPromise<AwaitedReactNode>string & ReactElement<unknown, stringJSXElementConstructor<any>>string & Iterable<ReactNode>string & ReactPortalstring & Promise<AwaitedReactNode>number & ReactElement<unknown, stringJSXElementConstructor<any>>number & Iterable<ReactNode>number & ReactPortalnumber & Promise<AwaitedReactNode>bigint & ReactElement<unknown, stringJSXElementConstructor<any>>bigint & Iterable<ReactNode>bigint & ReactPortalbigint & Promise<AwaitedReactNode>false & ReactElement<unknown, stringJSXElementConstructor<any>>false & Iterable<ReactNode>false & ReactPortalfalse & Promise<AwaitedReactNode>true & ReactElement<unknown, stringJSXElementConstructor<any>>true & Iterable<ReactNode>true & ReactPortaltrue & Promise<AwaitedReactNode>ReactElement<unknown, stringJSXElementConstructor<any>> & stringReactElement<unknown, stringJSXElementConstructor<any>> & numberReactElement<unknown, stringJSXElementConstructor<any>> & bigintReactElement<unknown, stringJSXElementConstructor<any>> & falseReactElement<unknown, stringJSXElementConstructor<any>> & trueReactElement<unknown, stringJSXElementConstructor<any>> & Iterable<ReactNode>ReactElement<unknown, stringJSXElementConstructor<any>> & ReactPortalReactElement<unknown, stringJSXElementConstructor<any>> & Promise<AwaitedReactNode>Iterable<ReactNode> & stringIterable<ReactNode> & numberIterable<ReactNode> & bigintIterable<ReactNode> & falseIterable<ReactNode> & trueIterable<ReactNode> & ReactElement<unknown, stringJSXElementConstructor<any>>Iterable<ReactNode> & ReactPortalIterable<ReactNode> & Promise<AwaitedReactNode>ReactPortal & stringReactPortal & numberReactPortal & bigintReactPortal & falseReactPortal & trueReactPortal & ReactElement<unknown, stringJSXElementConstructor<any>>ReactPortal & Iterable<ReactNode>ReactPortal & Promise<AwaitedReactNode>Promise<AwaitedReactNode> & stringPromise<AwaitedReactNode> & numberPromise<AwaitedReactNode> & bigintPromise<AwaitedReactNode> & falsePromise<AwaitedReactNode> & truePromise<AwaitedReactNode> & ReactElement<unknown, stringJSXElementConstructor<any>>Promise<AwaitedReactNode> & Iterable<ReactNode>Promise<AwaitedReactNode> & ReactPortal
Contents of `InputLabelNext` component, if not set, label is not rendered.
labelRightSectionReactNodeAdds a component to the right of the input at the label level. Useful for password strength.
maxstringnumberundefined@platform web
maxLengthnumberundefinedMaximum string length that the user can enter in UTF-16 code units
minstringnumberundefined@platform web
minLengthnumberundefinedMaximum string length that the user can enter in UTF-16 code units @platform web
namestringundefinedHtml input name @platform web
onChange((value: string) => void)undefinedTrigger when input value is changing
onPress
2 possibilities((event: GestureResponderEvent) => void)undefined
onReset((e: GestureResponderEvent) => void)undefined
placeholderstringundefined
prefixPointerEvents
5 possibilities"none""auto""box-none""box-only"undefined
Sets pointer-events styles on the `prefix` element, `none` by default
progressbooleanundefined
readonlybooleanundefinedMake input readonly
render
2 possibilities((elements: { input: ReactNode; prefix?: ReactNode; suffix?: ReactNode; }, pseudoState: PseudoState) => ReactNode)undefined
Fully control how input, prefix and suffix are rendererd
renderPlaceholder
2 possibilities((() => ReactNode) & (() => ReactNode)) | ((() => ReactNode) & (() => ReactNode))undefined
To render a custom placeholder view when the field is empty
requiredbooleanundefinedDetermines whether the input should have `aria-required` attribute Adds required attribute to the input and a red asterisk on the right side of label, `false` by default
size"sm""md"undefined
stepstringnumberundefined@platform web
suffixReactNodeContent section rendered on the right side of the input
suffixPointerEvents
5 possibilities"none""auto""box-none""box-only"undefined
Sets pointer-events styles on the `suffix` element, `none` by default
sxPositionPropsundefinedPositioning properties
titlestringundefinedHtml input title @platform web
typeHTMLInputTypeAttributeundefinedHTML input type @platform web
valuestringundefinedControl the input.

Undocumented props

NameTypeDefault ValueDescriptionUsage count
autoCompleteany
autoCorrectany
clearButtonModeany
data-1p-ignoreany
data-lpignoreany
onBlurany
onFocusany
onKeyPressany
onSubmitEditingany
refany
returnKeyTypeany
testIDany

Style API​

Use sx for one-off adjustments. It accepts these style keys:

alignSelfanimationaspectRatiobottomcursordisplayendflexflexBasisflexGrowflexShrinkheightinsetinsetInlineinsetInlineEndinsetInlineStartleftmarginmarginBottommarginHorizontalmarginInlinemarginInlineEndmarginInlineStartmarginLeftmarginRightmarginTopmarginVerticalmatrixmaxHeightmaxWidthminHeightminWidthopacityperspectivepositionrightrotaterotateXrotateYrotateZscalescaleXscaleYskewXskewYstarttoptransformtransformOriginwidthxyzIndex

Each can be overridden per breakpoint with:

$lg$ltLg$ltMd$ltSm$ltVs$ltXl$ltXxl$md$sm$vs$xl$xs$xxl
Edit this page
Previous
Radio
Next
SegmentedSlider
  • Usage
    • Basic Usage
    • Progress
    • Reset Button
    • Smallest Size
  • Accessibility
  • Playground