Reputation: 133
I am looking for some easy way to have something similar to what is available in angular-mdl for expandable search text field as below.. This will add a search button on click it will expand to text field.
<!-- Expandable Textfield -->
<form action="#">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable">
<label class="mdl-button mdl-js-button mdl-button--icon" for="sample6">
<i class="material-icons">search</i>
</label>
<div class="mdl-textfield__expandable-holder">
<input class="mdl-textfield__input" type="text" id="sample6">
<label class="mdl-textfield__label" for="sample-expandable">Expandable Input</label>
</div>
</div>
</form>
My requirement is to have such a search button in the Card title snapped to the right when user clicks it should expand to take input.. and I need to do it in Angular-Material.
Any inputs or help..! Thanks.
Upvotes: 6
Views: 25640
Reputation: 285
Seems like there are no clean 'native' angular material option for that, so I used one of the textfield options from 'material design lite' library - expandable search button gif-demo
Upvotes: 0
Reputation: 189
I was looking for some example of an expandable search in Angular with Material too, and found this code in Codepen, but not sure if it's exactly what you look for, it opens a full length input with a back button...
http://codepen.io/kyleledbetter/pen/gbQOaV
The HTML of the toolbar is something like this:
<md-toolbar ng-show="!showSearch">
<div class="md-toolbar-tools">
<md-button ng-click="toggleSidenav('left')" hide-gt-md aria-label="Menu">
<ng-md-icon icon="menu"></ng-md-icon>
</md-button>
<h3>
Dashboard
</h3>
<span flex></span>
<md-button aria-label="Search" ng-click="showSearch = !showSearch">
<ng-md-icon icon="search"></ng-md-icon>
</md-button>
<md-button aria-label="Open Settings" ng-click="showListBottomSheet($event)">
<ng-md-icon icon="more_vert"></ng-md-icon>
</md-button>
</div>
</md-toolbar>
<md-toolbar class="md-hue-1" ng-show="showSearch">
<div class="md-toolbar-tools">
<md-button ng-click="showSearch = !showSearch" aria-label="Back">
<ng-md-icon icon="arrow_back"></ng-md-icon>
</md-button>
<h3 flex="10">
Back
</h3>
<md-input-container md-theme="input" flex>
<label> </label>
<input ng-model="search.who" placeholder="enter search">
</md-input-container>
<md-button aria-label="Search" ng-click="showSearch = !showSearch">
<ng-md-icon icon="search"></ng-md-icon>
</md-button>
<md-button aria-label="Open Settings" ng-click="showListBottomSheet($event)">
<ng-md-icon icon="more_vert"></ng-md-icon>
</md-button>
</div>
</md-toolbar>
Upvotes: 6