sickdyd / react-search-autocomplete

A search box that filters the provided array of objects
https://sickdyd.github.io/react-search-autocomplete
MIT License
222 stars 85 forks source link

I want to learn how i can create an global or reusable style for the component #74

Closed pedromaironi closed 2 years ago

pedromaironi commented 2 years ago
sickdyd commented 2 years ago

@pedromaironi

You can create an object like this in one of your files:

export const styling = {
    padding: "0px 16px",
    background: "none",
    outline: "none",
    border: "none",
    fontWeight: "500",
    fontSize: "0.9rem",
    width: "100%",
    color: "black",
    cursor: "text",
    backgroundColor: "white",
    borderRadius: "8px",
    height: "2rem",
    border: "1px solid #cfd6e4",
}

Then import it and pass it to the component:

import { styling } from 'path/to/yourfile`

<ReactSearchAutocomplete
  placeholder="Buscar..."
  items={people}
  onSearch={handleOnSearch}
  onHover={handleOnHover}
  onSelect={handleOnSelect}
  onFocus={handleOnFocus}
  showIcon={false}
  styling={styling}
/>
pedromaironi commented 1 year ago

Thank u, sorry for answer too late.