Autocomplete Search Field
This tutorial shows how to simulate an autocomplete search field using Conditional Interactions and Expressions. Use this foundation to create a more complex search component or an entire application.
→ Download a ready .uxp file for this tutorial.
Setting up the Design
- Select Input under Forms... from the Quick Tools and click anywhere on the canvas to create an input element.
- Select Icon from Quick Tools and click inside the input element to add an icon.
- Use Search icons in the Properties Panel to find a search icon (or any icon you prefer). Change the icon's dimensions to 53 wide x 53 high. Select the icon and search field and press
Alt
"Y"
to align it to the middle. Place the icon in the far right corner at your discretion.
Creating the search results elements
- Select Rectangle from the Quick Tools or press
"R"
on your keyboard and click below the search field. - Change the rectangle's dimensions to 498 wide x 47 high in the Properties Panel.
- Select Text from the Quick Tools or press
"T"
on your keyboard and click inside the rectangle. - Select the text element and rectangle and press
Alt
"X"
, and thenAlt
"W"
. This will align the text element to the top center of the rectangle shape. - Select the Rectangle under Pages & Layers. Change the Fill to #FFFFFF in the Properties Panel.
- Rename the Rectangle in Pages & Layers to 'bg 1.'
- Select the text element under Pages & Layers and rename it 'TEXT 1.'
- Select bg 1 and TEXT 1 in Pages & Layers by holding
"Shift"
and clicking each one. With both selected, pressCtrl
"G"
to group the elements. Rename this group to 'search results 1.' - Select search results 1 in Pages & Layers, and press
Ctrl
"D"
twice to create two duplicates. - Rename the duplicate groups 'search results 2' and 'search results 3.'
- Also, rename the text and rectangle elements: 'TEXT 2' and 'bg 2' in search results 2, and 'TEXT 3' and 'bg 3' in search results 3.
- Select Box from the Quick Tools or press
"B"
on your keyboard and click below the search field and above the first search results element. - Change the new box element's dimensions to 495 wide x 27 high in the Properties Panel and change the Fill to #D3ACFF with an opacity of 50%.
- Double-click inside the box to activate text and type 'BLOG.' Under TYPOGRAPHY in the Properties Panel, align the text left.
- Select the three search results groups and the box, and press
Alt
"X"
to center align the elements, thenCtrl
"G"
to group them. Rename this group to 'Search Results.' - Hold
Ctrl
and click the Search Results and Input. PressAlt
"X"
to center align the elements. Change Gap Vertical in the Properties Panel to 12. - Hide the Search Results group by clicking the eye icon in Pages & Layers.
Styling the search results
- Select search results 1 in Pages & Layers.
- Click Interactions + at the top of the Properties Panel.
- Under Trigger, select Mouse Over.
- Under Action, click More..., and select Color.
- Select bg 1 from the Element dropdown.
- Under Change color to edit the color properties of Fill to, e.g. #E6EFF7
- Click Add to save the interaction.
- Click New interaction.
- Under Trigger, select Mouse Leave.
- Under Action, select More..., and select Color.
- Select bg 1 from the Element dropdown.
- Under Change color to edit the color properties of Fill to, e.g. #FFFFFF
- Click Add to save the interaction.
- With search results 1 still selected press
Ctrl
"Shift"
"C"
to copy the interactions. Select search results 2 in Pages & Layers and pressCtrl
"Shift"
"V"
to paste the interactions. Repeat for search results 3. - Go into the two Interactions for search results 1 & 2 and change the Element dropdown to bg 2 and bg 3, respectively.
Showing/hiding Search Results
- Select the Input element in Pages & Layers.
- Click Interactions + at the top of the Properties Panel.
- Under Trigger, select Value Change.
- Under Condition, select Content of element, then Input from the second dropdown and
"Is not empty"
below that. - Click Add condition to save.
- Under Action, select Show.
- Select Search Results from the Element dropdown.
- Click Add to save the interaction.
- Click New interaction.
- Under Trigger, select Value Change.
- Under Condition, select Content of element, then Input from the second dropdown and
"Is empty"
below that. - Under Action, click Hide.
- Select Search Results from the Element dropdown.
- Click Add to save the interaction.
Autocomplete Search Results
The following interactions will simulate the autocomplete functionality.
- Select the Input element in Pages & Layers.
- Click Interactions + at the top of the Properties Panel.
- Under Trigger, select Value Change.
- Under Action, click More..., and select Set Content.
- Select TEXT 1 from the Element dropdown.
- Under Set content as select Expression. In the input field type:
concat("Beautiful Interior Designs"," ",capitalize('Input'), "s")
7. Click Add to save the interaction.
- Click New interaction.
- Under Trigger, select Value Change.
- Under Action, click More..., and select Set Content.
- Select TEXT 2 from the Element dropdown.
- Under Set content as select Expression. In the input field type:
concat("Council of Fashion", " ",capitalize(concat('Input',"s")), " of America")
Click Add to save the interaction.
- Click New interaction.
- Under Trigger, select Value Change.
- Under Action, click More..., and select Set Content.
- Select TEXT 3 from the Element dropdown.
- Under Set content as select Expression. In the input field type:
concat(upperCase('Input'), " ","IDEAS BLOG")
Click Add to save the interaction.
You now have a functional autocomplete prototype. Feel free to change the search results to meet your prototyping requirements.