UNPKG

@uifabric/utilities

Version:

Fluent UI React utilities for building components.

25 lines 1.14 kB
import { getWindow } from './dom/getWindow'; export var IsFocusVisibleClassName = 'ms-Fabric--isFocusVisible'; export var IsFocusHiddenClassName = 'ms-Fabric--isFocusHidden'; /** * Sets the visibility of focus styling. * * By default, focus styles (the box surrounding a focused Button, for example) only show up when navigational * keypresses occur (through Tab, arrows, PgUp/PgDn, Home and End), and are hidden when mouse interactions occur. * This API provides an imperative way to turn them on/off. * * A use case might be when you have a keypress like ctrl-f6 navigate to a particular region on the page, * and want focus to show up. * * @param enabled - whether to remove or add focus * @param target - optional target */ export function setFocusVisibility(enabled, target) { var win = target ? getWindow(target) : getWindow(); if (win) { var classList = win.document.body.classList; classList.add(enabled ? IsFocusVisibleClassName : IsFocusHiddenClassName); classList.remove(enabled ? IsFocusHiddenClassName : IsFocusVisibleClassName); } } //# sourceMappingURL=setFocusVisibility.js.map