Updating the viewport with searhresults from the searchbar

Alright. Another question.
I have created a search module with an input. When you type in aomething in that input and press send in console log it wil present you with an array of posts that have that term inside them. How would you go and make it so that the viewport is updated with those results?

And the if you create a module e.g search. Then you could use it by placing in the code. Can you also add conditional classes to these code snippets?

Maybe then I could make it so that when the send button is clicked the hidden search module becomes active? ( im using the word module because I can net come up with the word what it is supposed to be :/)