Search code examples
reactjsreact-bootstrapfont-awesome-5react-bootstrap-table

to have font awesome search icon in react-bootstrap-table2-toolkit searchbar


using react-bootstrap-table2 for table and search together as below

<ToolkitProvider
          bootstrap4
          keyField='id'
          data={data}
          columns={columns}
          search
      >
          {props=>(
              <>
                  <SearchBar {...props.searchProps} placeholder='Start typing'/>
                  <br/>
                  <BootstrapTable condensed bordered
                                    id='bootstrap-tr'
                                    {...props.baseProps} 
                                    noDataIndication={() => 'There is no data to display'} 
                                    loading={loading} 
                                    overlay={overlayFactory({ spinner: true })} 
                                    pagination={paginationFactory(options)}
                                    // rowClasses={rowClasses}
                                    // expandRow={expandRow}
                                    />
              </>
          )}
      </ToolkitProvider>

search bar looks like this

enter image description here

i am using FontAwesome-5 icons and want to add fa-search icon to the react-bootstrap-table2-toolkit SearchBar, like below

enter image description here

any suggestions on this


Solution

  • got this resolved by added the below styling to the fa-search icon

    css
    #{yourid} {
        position: absolute;
        width: 2.375rem;
        /*height: 2.375rem;*/
        line-height: 2.375rem;
        text-align: center;
        color: #7B7B7B;
    }
    
    js file
    <i className='fas fa-search' id='filtersubmit' style={{fontSize:'15px'}}/>
    <SearchBar {...props.searchProps} placeholder=''/>