npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-mat-search-bar

v12.0.1

Published

The component creates a search-icon which expands a search-field on click. See the demo for the effect: ![NgMatSearchBar demo](https://raw.githubusercontent.com/tommueller/ng-mat-search-bar/master/docs/demo.gif)

Downloads

19,182

Readme

NgMatSearchBar

The component creates a search-icon which expands a search-field on click. See the demo for the effect: NgMatSearchBar demo

Installation

Install the dependency via npm:

npm install ng-mat-search-bar --save

or yarn

yarn add ng-mat-search-bar

and import the module into your apps app.module.ts like this:

import { NgMatSearchBarModule } from 'ng-mat-search-bar';

...

@NgModule({
  ...,
  imports: [
    ...,
    NgMatSearchBarModule
  ],
  ...
})

Also make sure that in your app.module.ts you import the BrowserAnimationsModule, otherwise the animations will not work!

You also need to add Material Icons webfont by adding

<link
  href="https://fonts.googleapis.com/icon?family=Material+Icons"
  rel="stylesheet"
/>

to your index.html.

Usage

You can use the component with its selector:

<mat-search-bar></mat-search-bar>

Events

You can subscribe to the different events the component is outputting:

  • onBlur: fired when the search-field looses focus
  • onClose: fired when the user closes the searchfield by clicking the close-button
  • onEnter: fired when user presses enter-button in search-field
  • onFocus: fired when user focuses the search-field
  • onOpen: fired when the searchbar is shown

Methods and properties

It also offers two public methods to open / close the searchbar:

  • open(): opens the searchbar
  • close(): closes the searchbar

and a property:

  • searchVisible: which holds the current visibility state of the search-input

Reactive forms

You can use it with ReactiveFormsModule, by passing a FormControl as input: e.g

...
<mat-search-bar [formControl]="control"></mat-search-bar>
...

and in .ts file:

  ...@Component({})...
    control: FormControl = new FormControl('');
  ...

Autocomplete

You also can use it combined with Angular Materials autocomplete (https://material.angular.io/components/autocomplete/overview). Just use it as described in the Angular docs and use the mat-search-bar as the input for it. Also you can check the app.component.html/.ts for example code: https://github.com/tommueller/ng-mat-search-bar/blob/master/src/app/

Contributions

Please don't hesitate to file an issue or send in a PR if you have any improvements or found bugs.