Primitives
Handle focus for a group of elements.
<div
ngpRovingFocusGroup
ngpRovingFocusGroupOrientation="horizontal"
ngpRovingFocusGroupWrap="true"
ngpRovingFocusGroupHomeEnd="true"
>
<button type="button" ngpButton ngpRovingFocusItem>
<ng-icon name="heroDocument" />
</button>
<button type="button" ngpButton ngpRovingFocusItem>
<ng-icon name="heroFolder" />
</button>
<div class="divider"></div>
<button type="button" ngpButton ngpRovingFocusItem>
<ng-icon name="heroBars3BottomLeft" />
</button>
<button type="button" ngpButton ngpRovingFocusItem>
<ng-icon name="heroBars3" />
</button>
<button type="button" ngpButton ngpRovingFocusItem>
<ng-icon name="heroBars3BottomRight" />
</button>
<div class="divider"></div>
<button type="button" ngpButton ngpRovingFocusItem>
<ng-icon name="heroCog6Tooth" />
</button>
</div>
Import the Roving Focus primitives from ng-primitives/roving-focus
.
import { NgpRovingFocusGroup, NgpRovingFocusItem } from 'ng-primitives/roving-focus';
Assemble the roving focus directives in your template.
<div ngpRovingFocusGroup>
<button ngpRovingFocusItem>Item 1</button>
<button ngpRovingFocusItem>Item 2</button>
<button ngpRovingFocusItem>Item 3</button>
</div>
The following directives are available to import from the ng-primitives/roving-focus
package:
Apply the ngpRovingFocusGroup
directive to an element to manage focus for a group of child elements.
[ngpRovingFocusGroup]
ngpRovingFocusGroup
Define the orientation of the roving focus group.
Define whether the focus should wrap around the group.
Define whether the focus should move to the first or last element when pressing the Home or End key.
Define whether the roving focus group is disabled.
Apply the ngpRovingFocusItem
directive to an element within a roving focus group to automatically manage focus.
[ngpRovingFocusItem]
ngpRovingFocusItem
Define whether the roving focus item is disabled.
Adheres to the WAI-ARIA Keyboard Interface Practices.
Copyright © 2025 Angular Primitives