mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Replaces the native select element with a custom combobox implementation for improved accessibility and styling.
186 lines
3.5 KiB
SCSS
186 lines
3.5 KiB
SCSS
:host {
|
|
--border-color: color-mix(in srgb, var(--full-contrast) 20%, var(--page-background));
|
|
}
|
|
|
|
[ngCombobox] {
|
|
position: relative;
|
|
width: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 0.25rem;
|
|
}
|
|
|
|
.docs-select-input-container {
|
|
display: flex;
|
|
position: relative;
|
|
align-items: center;
|
|
border-radius: 0.25rem;
|
|
}
|
|
|
|
[ngComboboxInput] {
|
|
border-radius: 0.25rem;
|
|
}
|
|
|
|
[ngComboboxInput][readonly='true'] {
|
|
cursor: pointer;
|
|
padding: 0.7rem 1rem;
|
|
}
|
|
|
|
[ngCombobox]:focus-within [ngComboboxInput]:not(.docs-select-search-input) {
|
|
outline: 1.5px solid var(--vivid-pink);
|
|
box-shadow: 0 0 0 4px color-mix(in srgb, var(--vivid-pink) 25%, transparent);
|
|
}
|
|
|
|
.docs-select-arrow {
|
|
width: 24px;
|
|
height: 24px;
|
|
font-size: 20px;
|
|
display: grid;
|
|
place-items: center;
|
|
pointer-events: none;
|
|
padding: 0 0.5rem;
|
|
position: absolute;
|
|
right: 0;
|
|
opacity: 0.8;
|
|
transition: transform 0.2s ease;
|
|
}
|
|
|
|
[ngComboboxInput][aria-expanded='true'] + .docs-select-arrow {
|
|
transform: rotate(180deg);
|
|
}
|
|
|
|
[ngComboboxInput] {
|
|
width: 100%;
|
|
border: none;
|
|
outline: none;
|
|
font-size: 1rem;
|
|
padding: 0.7rem 1rem 0.7rem 2.5rem;
|
|
background-color: var(--septenary-contrast);
|
|
color: var(--primary-contrast);
|
|
}
|
|
|
|
.docs-select-dialog {
|
|
position: absolute;
|
|
left: auto;
|
|
right: auto;
|
|
top: auto;
|
|
bottom: auto;
|
|
padding: 0;
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 0.25rem;
|
|
background-color: var(--septenary-contrast);
|
|
color: inherit;
|
|
|
|
.docs-select-input-container {
|
|
border-radius: 0;
|
|
}
|
|
|
|
[ngCombobox],
|
|
.docs-select-input-container {
|
|
border: none;
|
|
}
|
|
|
|
[ngComboboxInput] {
|
|
border-bottom-left-radius: 0;
|
|
border-bottom-right-radius: 0;
|
|
}
|
|
|
|
[ngCombobox]:focus-within [ngComboboxInput] {
|
|
outline: none;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.docs-select-search-input:focus {
|
|
outline: none;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.docs-select-search-container {
|
|
border-bottom: 1px solid var(--border-color);
|
|
}
|
|
|
|
&::backdrop {
|
|
opacity: 0;
|
|
}
|
|
}
|
|
|
|
.docs-select-search-container {
|
|
position: relative;
|
|
display: flex;
|
|
align-items: center;
|
|
border-radius: 0;
|
|
}
|
|
|
|
.docs-select-search-icon {
|
|
width: 24px;
|
|
height: 24px;
|
|
font-size: 20px;
|
|
display: grid;
|
|
place-items: center;
|
|
pointer-events: none;
|
|
position: absolute;
|
|
padding: 0 0.5rem;
|
|
opacity: 0.8;
|
|
}
|
|
|
|
.docs-select-search-input {
|
|
width: 100%;
|
|
border: none;
|
|
outline: none;
|
|
font-size: 0.875rem;
|
|
padding: 0.5rem 0.75rem 0.5rem 2rem;
|
|
background-color: var(--septenary-contrast);
|
|
color: var(--primary-contrast);
|
|
}
|
|
|
|
.docs-select-no-results {
|
|
padding: 0.75rem;
|
|
text-align: center;
|
|
font-size: 0.875rem;
|
|
color: var(--primary-contrast);
|
|
opacity: 0.7;
|
|
}
|
|
|
|
.docs-select-listbox {
|
|
display: flex;
|
|
flex-direction: column;
|
|
max-height: 12rem;
|
|
overflow: auto;
|
|
padding: 0.25rem;
|
|
}
|
|
|
|
.docs-select-option {
|
|
display: flex;
|
|
cursor: pointer;
|
|
align-items: center;
|
|
padding: 0.5rem 0.75rem;
|
|
font-size: 0.875rem;
|
|
border-radius: 0.25rem;
|
|
|
|
&:hover {
|
|
background-color: color-mix(in srgb, var(--primary-contrast) 5%, transparent);
|
|
}
|
|
|
|
&[data-active='true'] {
|
|
outline-offset: -2px;
|
|
outline: 2px solid var(--vivid-pink);
|
|
}
|
|
|
|
&[aria-selected='true'] {
|
|
color: var(--vivid-pink);
|
|
background-color: color-mix(in srgb, var(--vivid-pink) 5%, transparent);
|
|
}
|
|
|
|
&:not([aria-selected='true']) .docs-select-check-icon {
|
|
display: none;
|
|
}
|
|
}
|
|
|
|
.docs-select-option-label {
|
|
flex: 1;
|
|
}
|
|
|
|
.docs-select-check-icon {
|
|
font-size: 0.9rem;
|
|
}
|