@ionic/core
Version:
Base components for Ionic
381 lines (347 loc) • 12.3 kB
CSS
/**
* Convert a font size to a dynamic font size.
* Fonts that participate in Dynamic Type should use
* dynamic font sizes.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param unit (optional) - The unit to convert to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* a maximum font size.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* a minimum font size.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* maximum and minimum font sizes.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
* @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* A heuristic that applies CSS to tablet
* viewports.
*
* Usage:
* @include tablet-viewport() {
* :host {
* background-color: green;
* }
* }
*/
/**
* A heuristic that applies CSS to mobile
* viewports (i.e. phones, not tablets).
*
* Usage:
* @include mobile-viewport() {
* :host {
* background-color: blue;
* }
* }
*/
:host {
/**
* @prop --background: Background color of the input boxes
*
* @prop --border-radius: Border radius of the input boxes
*
* @prop --border-width: Border width of the input boxes
* @prop --border-color: Border color of the input boxes
*
* @prop --color: Text color of the input
*
* @prop --margin-top: Top margin of the input group
* @prop --margin-end: Right margin if direction is left-to-right, and left margin if direction is right-to-left of the input group
* @prop --margin-bottom: Bottom margin of the input group
* @prop --margin-start: Left margin if direction is left-to-right, and right margin if direction is right-to-left of the input group
*
* @prop --padding-top: Top padding of the input group
* @prop --padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the input group
* @prop --padding-bottom: Bottom padding of the input group
* @prop --padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the input group
*
* @prop --height: Height of input boxes
* @prop --width: Width of input boxes
* @prop --min-width: Minimum width of input boxes
*
* @prop --separator-color: Color of the separator between boxes
* @prop --separator-width: Width of the separator between boxes
* @prop --separator-height: Height of the separator between boxes
* @prop --separator-border-radius: Border radius of the separator between boxes
*
* @prop --highlight-color-focused: The color of the highlight on the input when focused
* @prop --highlight-color-valid: The color of the highlight on the input when valid
* @prop --highlight-color-invalid: The color of the highlight on the input when invalid
*/
--margin-top: 0;
--margin-end: 0;
--margin-bottom: 0;
--margin-start: 0;
--padding-top: 16px;
--padding-end: 0;
--padding-bottom: 16px;
--padding-start: 0;
--color: initial;
--min-width: 40px;
--separator-width: 8px;
--separator-height: var(--separator-width);
--separator-border-radius: 999px;
--separator-color: var(--ion-color-step-150, var(--ion-background-color-step-150, #d9d9d9));
--highlight-color-focused: var(--ion-color-primary, #0054e9);
--highlight-color-valid: var(--ion-color-success, #2dd55b);
--highlight-color-invalid: var(--ion-color-danger, #c5000f);
/**
* This is a private API that is used to switch
* out the highlight color based on the state
* of the component without having to write
* different selectors for different fill variants.
*/
--highlight-color: var(--highlight-color-focused);
display: block;
position: relative;
font-size: 0.875rem;
}
.input-otp-group {
-webkit-margin-start: var(--margin-start);
margin-inline-start: var(--margin-start);
-webkit-margin-end: var(--margin-end);
margin-inline-end: var(--margin-end);
margin-top: var(--margin-top);
margin-bottom: var(--margin-bottom);
-webkit-padding-start: var(--padding-start);
padding-inline-start: var(--padding-start);
-webkit-padding-end: var(--padding-end);
padding-inline-end: var(--padding-end);
padding-top: var(--padding-top);
padding-bottom: var(--padding-bottom);
display: flex;
align-items: center;
justify-content: center;
}
.native-wrapper {
display: flex;
align-items: center;
justify-content: center;
min-width: var(--min-width);
}
.native-input {
border-radius: var(--border-radius);
width: var(--width);
min-width: inherit;
height: var(--height);
border-width: var(--border-width);
border-style: solid;
border-color: var(--border-color);
background: var(--background);
color: var(--color);
font-size: inherit;
text-align: center;
appearance: none;
}
:host(.has-focus) .native-input {
caret-color: var(--highlight-color);
}
.input-otp-description {
color: var(--ion-color-step-700, var(--ion-text-color-step-300, #4d4d4d));
font-size: 0.75rem;
line-height: 1.25rem;
text-align: center;
}
.input-otp-description-hidden {
display: none;
}
.input-otp-separator {
border-radius: var(--separator-border-radius);
flex-shrink: 0;
width: var(--separator-width);
height: var(--separator-height);
background: var(--separator-color);
}
:host(.input-otp-size-small) {
--width: 40px;
--height: 40px;
}
:host(.input-otp-size-small) .input-otp-group {
gap: 8px;
}
:host(.input-otp-size-medium) {
--width: 48px;
--height: 48px;
}
:host(.input-otp-size-large) {
--width: 56px;
--height: 56px;
}
:host(.input-otp-size-medium) .input-otp-group,
:host(.input-otp-size-large) .input-otp-group {
gap: 12px;
}
:host(.input-otp-shape-round) {
--border-radius: 16px;
}
:host(.input-otp-shape-soft) {
--border-radius: 8px;
}
:host(.input-otp-shape-rectangular) {
--border-radius: 0;
}
:host(.input-otp-fill-outline) {
--background: none;
}
:host(.input-otp-fill-solid) {
--border-color: var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2));
--background: var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2));
}
:host(.input-otp-disabled) {
--color: var(--ion-color-step-350, var(--ion-text-color-step-650, #a6a6a6));
}
:host(.input-otp-fill-outline.input-otp-disabled) {
--background: var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2));
--border-color: var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6));
}
:host(.input-otp-disabled),
:host(.input-otp-disabled) .native-input:disabled {
cursor: not-allowed;
}
:host(.has-focus) .native-input:focus {
--border-color: var(--highlight-color);
outline: none;
}
:host(.input-otp-fill-outline.input-otp-readonly) {
--background: var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2));
}
:host(.input-otp-fill-solid.input-otp-disabled),
:host(.input-otp-fill-solid.input-otp-readonly) {
--border-color: var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6));
--background: var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6));
}
:host(.ion-touched.ion-invalid) {
--highlight-color: var(--highlight-color-invalid);
}
/**
* The component highlight is only shown
* on focus, so we can safely set the valid
* color state when valid. If we
* set it when .has-focus is present then
* the highlight color would change
* from the valid color to the component's
* color during the transition after the
* component loses focus.
*/
:host(.ion-valid) {
--highlight-color: var(--highlight-color-valid);
}
/**
* If the input has a validity state, the
* border should reflect that as a color.
* The invalid state should show if the input is
* invalid and has already been touched.
* The valid state should show if the input
* is valid, has already been touched, and
* is currently focused. Do not show the valid
* highlight when the input is blurred.
*/
:host(.has-focus.ion-valid),
:host(.ion-touched.ion-invalid) {
--border-color: var(--highlight-color);
}
:host(.ion-color) {
--highlight-color-focused: var(--ion-color-base);
}
:host(.input-otp-fill-outline.ion-color) .native-input,
:host(.input-otp-fill-solid.ion-color) .native-input:focus {
border-color: rgba(var(--ion-color-base-rgb), 0.6);
}
:host(.input-otp-fill-outline.ion-color.ion-invalid) .native-input,
:host(.input-otp-fill-solid.ion-color.ion-invalid) .native-input,
:host(.input-otp-fill-outline.ion-color.has-focus.ion-invalid) .native-input,
:host(.input-otp-fill-solid.ion-color.has-focus.ion-invalid) .native-input {
border-color: var(--ion-color-danger, #c5000f);
}
:host(.input-otp-fill-outline.ion-color.ion-valid) .native-input,
:host(.input-otp-fill-solid.ion-color.ion-valid) .native-input,
:host(.input-otp-fill-outline.ion-color.has-focus.ion-valid) .native-input,
:host(.input-otp-fill-solid.ion-color.has-focus.ion-valid) .native-input {
border-color: var(--ion-color-success, #2dd55b);
}
:host(.input-otp-fill-outline.input-otp-disabled.ion-color) .native-input {
border-color: rgba(var(--ion-color-base-rgb), 0.3);
}
/**
* Convert a font size to a dynamic font size.
* Fonts that participate in Dynamic Type should use
* dynamic font sizes.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param unit (optional) - The unit to convert to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* a maximum font size.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* a minimum font size.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* maximum and minimum font sizes.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
* @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* A heuristic that applies CSS to tablet
* viewports.
*
* Usage:
* @include tablet-viewport() {
* :host {
* background-color: green;
* }
* }
*/
/**
* A heuristic that applies CSS to mobile
* viewports (i.e. phones, not tablets).
*
* Usage:
* @include mobile-viewport() {
* :host {
* background-color: blue;
* }
* }
*/
:host {
--border-width: 0.55px;
}
:host(.has-focus) .native-input:focus {
--border-width: 1px;
}
:host(.input-otp-fill-outline) {
--border-color: var(--ion-item-border-color, var(--ion-border-color, var(--ion-color-step-250, var(--ion-background-color-step-250, #c8c7cc))));
}