요소를 화면에서 감추되, 스크린 리더에서 읽힐 수 있도록 하는 믹스인입니다.
a11y-hidden($focus-visible:bool, $focus-state-class:string)
.a11yHidden {
@include a11y-hidden();
}
위 예시 코드는 아래의 CSS로 컴파일 되어 출력됩니다.
.a11yHidden {
overflow: hidden;
position: absolute;
clip: rect(0, 0, 0, 0);
clip-path: circle(0);
width: 1px;
height: 1px;
margin: -1px;
border: 0;
padding: 0;
white-space: nowrap;
}
.a11yHidden {
@include a11y-hidden(true);
}
위 예시 코드는 아래의 CSS로 컴파일 되어 출력됩니다.
.a11yHidden {
overflow: hidden;
position: absolute;
clip: rect(0, 0, 0, 0);
clip-path: circle(0);
width: 1px;
height: 1px;
margin: -1px;
border: 0;
padding: 0;
white-space: nowrap;
}
.a11yHidden--focus:focus {
overflow: visible;
position: static;
clip: auto;
width: auto;
height: auto;
margin: 0;
white-space: normal;
}
@mixin a11y-hidden($focus-visible: false, $focus-state-class: 'focus') {
overflow: hidden;
position: absolute;
clip: rect(0, 0, 0, 0);
clip-path: circle(0);
width: 1px;
height: 1px;
margin: -1px;
border: 0;
padding: 0;
white-space: nowrap;
@if $focus-visible {
&#{'--' + $focus-state-class}:focus {
overflow: visible;
position: static;
clip: auto;
width: auto;
height: auto;
margin: 0;
white-space: normal;
}
}
}
믹스인에 사용된 Sass의 빌트인 모듈은 다음과 같습니다.