Refine list from algolia on button click

can we refine/filter lists from algolia on button click that is present on the page?

@rahul.kumar depending on your set up you should be able to! Which frontend libraries are you using? I’d be happy to throw together some example code for you.

Hi @michael.king
Thanks for the reply, I am using reactjs

@michael.king also adding to that one more query is can we select multiple facets for the same attribute as right now what is happening is when I select the second one first one is reset and showing only second one selected.

can we pass something like this refine([‘SP’, ‘FG’]), but I tried this way it is not working as expected

Using the hook version of the library and useRefinementList, you should be able to do what you are looking for.

Example:

<InstantSearch ...>
  ...
  {/* Pass the attribute with the button or dynamically set the attribute */}
  <CustomRefinementBtn attribute="brand" />
  ...
</InstantSearch> 
function CustomRefinementBtn(props) {
  // If passing via props
  const { items, refine } = useRefinementList(props);
  // If dynamically
  // const { items, refine } = useRefinementList({ attribute: 'brand' })
  function onRefine() {
    refine("...")
  }
}

You could trigger the functionality with an onClick method on a button element for example.

thanks a lot @michael.king, it really helps