How To Make A Search Function In Bubble.io
In this Bubble.io tutorial video we show to user the Search element to give your users the ability to search a specific field of a data type in your Bubble database.
Unlock the power of search: Learn how to create a dynamic contacts search box in Bubble that filters results as you type!
Master Bubble workflows: Discover how to navigate to profile pages seamlessly when users select search results.
Dive deep into search box functionality and explore advanced techniques for searching multiple fields at once!
Creating a Search Function in Bubble.io
I'm working in my Bubble app and I'm making a contacts page. At the moment I've only got five contacts, but when that number grows I will probably be looking to add in a search. This is one way to go about it using Bubble's default search box.
Setting Up the Search Box
If I go into the editor and look for search, this acts a lot like an input field but with some other bonuses. I can update the placeholder and then out of these choices I want it to be dynamic to be able to search through my Bubble app and my contacts. I define the list of options to contacts and then I'm going to show, I'm gonna have it search the name.
Limitations of the Default Search Box
This is one of the limitations and why there'll be a follow-up video showing another way to approach doing a search because I can only search one field here. But in another video, I'll show how to search more than one field. For now, we'll go with name and then I'll leave that one unchecked because I don't want free entry of text into the box.
Testing the Search Functionality
So that should work. Go onto preview. Now if I type in Tony I get, or even the beginnings of Tony, I get Tony. If I click on it nothing happens. So let's build a workflow now for if I click on Tony I want to be able to go to Tony's profile because this is a search box in my header and that would make sense as what to do.
Building the Workflow
I go for when an element's input is changed and it selects the search box because when I select one of the data entries that I have in context, when I select it, it changes the data in the input. So that's why I've gone with input's value is changed. Then I can do navigate and I have a really rough profile page.
Sending Data to the Profile Page
To send the data to send Tony's data or whichever contact is selected I go this search box value. So the value is a data type over typed text which is useful if you want your search box to be able to take a value that has found no results and create a result. That will be in another video, but for now we just want value because that value is of type contact.
Testing the Complete Functionality
Let's give it a refresh. Tony and now I click on Tony. It's a random photo of Unsplash for a video about profile pictures, but you can see I've gone to a page in the URL you can see that it is a page of that is profile in my Bubble editor and then this is the unique ID for Tony's entry.
Limitations of This Approach
Some flaws in this to point out and reasons why you might want to consider a different approach is if I go back this does not filter this, it doesn't allow me to do that very easily. Also, it means also it limits me to only searching one search field and that can cause all sorts of problems that should be quite simple.
Example of Limitations
For example, if you have a field of first name and a different field of last name, the default built-in search box here will only let you search one of those fields. Now a way around that is that when you use a registers you have a field called first name, a field called last name, and a field called full name and you take those details and you combine them together with a space in the middle for that third field.
Workarounds and Future Improvements
But yeah, and then you can choose it here, but it's not perfect because then every time a user updates like their first name or their last name you have to have either a back-end trigger, a workflow, or some sort of workflow that you create on the front end to ensure that if they update their last name the full name also gets updated. So it's not ideal, but those are a few pointers of workarounds and in a future video I'll be showing how to create a search box that both filters the content here and allows you to search more than one field at a time.
Can't find what you're looking for?
Search our 300+ Bubble tutorial videos. Start learning no code today!
Flexible Pricing Plans to Fit Your No-Code Journey
Choose the plan that aligns with your goals and start building your startup today.
Have questions?
We have answers!
Find answers to common questions about our membership plans, programs, and more.
Both plans offer full access to our learning resources, community, and support. The Annual plan provides a significant discount (over 15%) compared to paying monthly, and it allows you to lock in your rate for a full year.
Absolutely! You can easily upgrade or downgrade your membership plan at any time by logging into your account and selecting the desired plan. Any unused portion of your current plan will be prorated and applied to your new plan.
As a Planet No Code member, you'll receive a discount on our Bubble coaching sessions. Monthly members receive a 10% discount, while Annual members receive a 17.5% discount. To redeem your discount, simply log into your account and book a coaching session through our platform.
Our 8-week intensive mentorship program is designed to provide personalized guidance and support to help you accelerate your startup journey. You'll be matched with a startup expert who will work with you one-on-one to set goals, overcome challenges, and make rapid progress.
To apply for the Mastery Program, simply click the "Request Invitation" button on our pricing page and fill out the application form. Our team will review your application and schedule a call with you to discuss your goals and determine if the program is a good fit for your needs.
We accept all major credit cards, including Visa, Mastercard, American Express, and Discover.
While we don't offer a free trial, we do provide a 14-day money-back guarantee. If you're not completely satisfied with your membership within the first 14 days, simply contact our support team, and we'll issue a full refund.
If you decide that Planet No Code isn't the right fit for you, you can cancel your membership at any time by logging into your account and navigating to the subscription management page. Click the "Cancel Membership" button, and your membership will be terminated at the end of your current billing cycle.