Ngx focus control

Library to provide tools to work with focus and focusable elements to improve user interfaces and accessibility.

npm versionCircleCICoverage StatusGitHub issuesnpm bundle sizeNPMdemostack blitzGitter
logo
Angular library to provide tools to work with focus and focusable elements to improve user interfaces and accessibility.
npm install ngx-focus-control --save

Focus if directive

This directive focuses the element when condition bidding changes to True or blurs the element when condition bidding changes to False. Instead of primitive value, you can also pass observable, which focuses element when observable emits True and blur element when observable emits False.


The first example shows input, that should be focused or blurred based on the condition provided. You can change the condition with a button click. The second example shows input, the focused state is determined by a given observable. You can emit True or False with a button click.


Code

<input type="text" placeholder="Input 16" class="input" id="input-16" [fuIf]="condition">
<input type="text" placeholder="Input 17" class="input" id="input-17" [fuIf]="observable$">