UNPKG

1.02 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = hideVisually;
5/**
6 * CSS to hide content visually but remain accessible to screen readers.
7 * from [HTML5 Boilerplate](https://github.com/h5bp/html5-boilerplate/blob/9a176f57af1cfe8ec70300da4621fb9b07e5fa31/src/css/main.css#L121)
8 *
9 * @example
10 * // Styles as object usage
11 * const styles = {
12 * ...hideVisually(),
13 * }
14 *
15 * // styled-components usage
16 * const div = styled.div`
17 * ${hideVisually()};
18 * `
19 *
20 * // CSS as JS Output
21 *
22 * 'div': {
23 * 'border': '0',
24 * 'clip': 'rect(0 0 0 0)',
25 * 'height': '1px',
26 * 'margin': '-1px',
27 * 'overflow': 'hidden',
28 * 'padding': '0',
29 * 'position': 'absolute',
30 * 'whiteSpace': 'nowrap',
31 * 'width': '1px',
32 * }
33 */
34function hideVisually() {
35 return {
36 border: '0',
37 clip: 'rect(0 0 0 0)',
38 height: '1px',
39 margin: '-1px',
40 overflow: 'hidden',
41 padding: '0',
42 position: 'absolute',
43 whiteSpace: 'nowrap',
44 width: '1px'
45 };
46}
47module.exports = exports.default;
\No newline at end of file