/
githubmirror
/
ionic-framework
Обзор
Документация
Войти
/
githubmirror
/
ionic-framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
core/src/components/radio/radio.scss
297 строк
6 KB
Shane
fix(checkbox,radio,toggle): add missing keyboard focus indicators (#31295)
01 авг 2026, 00:57
Не верифицирован
01 авг 2026, 00:57
2f9c0b7
Код
Авторство
О чём код?
@import "./radio.vars.scss"; // Radio // -------------------------------------------------- :host { /** * @prop --color: Color of the radio * @prop --color-checked: Color of the checked radio * @prop --border-radius: Border radius of the radio * @prop --inner-border-radius: Border radius of the inner checked radio */ --inner-border-radius: 50%; display: inline-block; position: relative; max-width: 100%; min-height: inherit; cursor: pointer; user-select: none; z-index: $z-index-item-input; box-sizing: border-box; } :host(.radio-disabled) { pointer-events: none; } .radio-icon { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; contain: layout size style; } .radio-icon, .radio-inner { box-sizing: border-box; } input { @include visually-hidden(); } // Hide the native focus ring since we draw our own focus indicator. :host(:focus) { outline: none; } :host(.in-item) { flex: 1 1 0; width: 100%; height: 100%; } /** * Radio can be slotted * in components such as item and * toolbar which is why we do not * limit the below behavior to just ion-item. */ :host([slot="start"]), :host([slot="end"]) { // Reset the flex property when the radio // is slotted to avoid growing the element larger // than its content. flex: initial; width: auto; } // Radio: Keyboard Focus // --------------------------------------------- :host(.ion-focused) .radio-icon::after { @include border-radius(var(--inner-border-radius)); display: block; position: absolute; width: 36px; height: 36px; background: $radio-background-color-focused; content: ""; opacity: 0.2; } // Radio Wrapper // -------------------------------------------------- .radio-wrapper { display: flex; position: relative; flex-grow: 1; align-items: center; justify-content: space-between; height: inherit; min-height: inherit; cursor: inherit; } // Radio Label // ---------------------------------------------------------------- .label-text-wrapper { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; } :host(.in-item) .label-text-wrapper { @include margin($radio-item-label-margin-top, null, $radio-item-label-margin-bottom, null); } :host(.in-item.radio-label-placement-stacked) .label-text-wrapper { @include margin($radio-item-label-margin-top, null, $form-control-label-margin, null); } :host(.in-item.radio-label-placement-stacked) .native-wrapper { @include margin(null, null, $radio-item-label-margin-bottom, null); } /** * If no label text is placed into the slot * then the element should be hidden otherwise * there will be additional margins added. */ .label-text-wrapper-hidden { display: none; } // Radio Native Wrapper // ---------------------------------------------------------------- .native-wrapper { display: flex; align-items: center; } // Radio Justify // -------------------------------------------------- :host(.radio-justify-space-between) .radio-wrapper { justify-content: space-between; } :host(.radio-justify-start) .radio-wrapper { justify-content: start; } :host(.radio-justify-end) .radio-wrapper { justify-content: end; } // Radio Align // -------------------------------------------------- :host(.radio-alignment-start) .radio-wrapper { align-items: start; } :host(.radio-alignment-center) .radio-wrapper { align-items: center; } // Justify Content & Align Items // --------------------------------------------- // The radio should be displayed as block when either justify // or alignment is set; otherwise, these properties will have no // visible effect. :host(.radio-justify-space-between), :host(.radio-justify-start), :host(.radio-justify-end), :host(.radio-alignment-start), :host(.radio-alignment-center) { display: block; } // Radio Label Placement - Start // ---------------------------------------------------------------- /** * Label is on the left of the radio in LTR and * on the right in RTL. */ :host(.radio-label-placement-start) .radio-wrapper { flex-direction: row; } :host(.radio-label-placement-start) .label-text-wrapper { /** * The margin between the label and * the radio should be on the end * when the label sits at the start. */ @include margin(null, $form-control-label-margin, null, 0); } // Radio Label Placement - End // ---------------------------------------------------------------- /** * Label is on the right of the radio in LTR and * on the left in RTL. */ :host(.radio-label-placement-end) .radio-wrapper { flex-direction: row-reverse; } /** * The margin between the label and * the radio should be on the start * when the label sits at the end. */ :host(.radio-label-placement-end) .label-text-wrapper { @include margin(null, 0, null, $form-control-label-margin); } // Radio Label Placement - Fixed // ---------------------------------------------------------------- :host(.radio-label-placement-fixed) .label-text-wrapper { /** * The margin between the label and * the radio should be on the end * when the label sits at the start. */ @include margin(null, $form-control-label-margin, null, 0); } /** * Label is on the left of the radio in LTR and * on the right in RTL. Label also has a fixed width. */ :host(.radio-label-placement-fixed) .label-text-wrapper { flex: 0 0 100px; width: 100px; min-width: 100px; } // Radio Label Placement - Stacked // ---------------------------------------------------------------- /** * Label is on top of the radio. */ :host(.radio-label-placement-stacked) .radio-wrapper { flex-direction: column; } :host(.radio-label-placement-stacked) .label-text-wrapper { @include transform(scale(#{$form-control-label-stacked-scale})); /** * The margin between the label and * the radio should be on the bottom * when the label sits on top. */ @include margin(null, 0, $form-control-label-margin, 0); /** * Label text should not extend * beyond the bounds of the radio. */ max-width: calc(100% / #{$form-control-label-stacked-scale}); } :host(.radio-label-placement-stacked.radio-alignment-start) .label-text-wrapper { @include transform-origin(start, top); } :host(.radio-label-placement-stacked.radio-alignment-center) .label-text-wrapper { @include transform-origin(center, top); }