@ionic/core
Version:
Base components for Ionic
657 lines (607 loc) • 19.7 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 of the button
* @prop --background-activated: Background of the button when pressed. Note: setting this will interfere with the Material Design ripple.
* @prop --background-activated-opacity: Opacity of the button when pressed
* @prop --background-focused: Background of the button when focused with the tab key
* @prop --background-focused-opacity: Opacity of the button when focused with the tab key
* @prop --background-hover: Background of the button on hover
* @prop --background-hover-opacity: Opacity of the background on hover
*
* @prop --color: Text color of the button
* @prop --color-activated: Text color of the button when pressed
* @prop --color-focused: Text color of the button when focused with the tab key
* @prop --color-hover: Text color of the button when hover
*
* @prop --transition: Transition of the button
*
* @prop --border-radius: Border radius of the button
* @prop --border-width: Border width of the button
* @prop --border-style: Border style of the button
* @prop --border-color: Border color of the button
*
* @prop --ripple-color: Color of the button ripple effect
*
* @prop --box-shadow: Box shadow of the button
* @prop --opacity: Opacity of the button
*
* @prop --padding-top: Top padding of the button
* @prop --padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button
* @prop --padding-bottom: Bottom padding of the button
* @prop --padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button
*/
--overflow: hidden;
--ripple-color: currentColor;
--border-width: initial;
--border-color: initial;
--border-style: initial;
--color-activated: var(--color);
--color-focused: var(--color);
--color-hover: var(--color);
--box-shadow: none;
display: inline-block;
width: auto;
color: var(--color);
font-family: var(--ion-font-family, inherit);
text-align: center;
text-decoration: none;
white-space: normal;
user-select: none;
vertical-align: top;
vertical-align: -webkit-baseline-middle;
font-kerning: none;
}
:host(.button-disabled) {
cursor: default;
opacity: 0.5;
pointer-events: none;
}
:host(.button-solid) {
--background: var(--ion-color-primary, #0054e9);
--color: var(--ion-color-primary-contrast, #fff);
}
:host(.button-outline) {
--border-color: var(--ion-color-primary, #0054e9);
--background: transparent;
--color: var(--ion-color-primary, #0054e9);
}
:host(.button-clear) {
--border-width: 0;
--background: transparent;
--color: var(--ion-color-primary, #0054e9);
}
:host(.button-block) {
display: block;
}
:host(.button-block) .button-native {
margin-left: 0;
margin-right: 0;
width: 100%;
clear: both;
contain: content;
}
:host(.button-block) .button-native::after {
clear: both;
}
:host(.button-full) {
display: block;
}
:host(.button-full) .button-native {
margin-left: 0;
margin-right: 0;
width: 100%;
contain: content;
}
:host(.button-full:not(.button-round)) .button-native {
border-radius: 0;
border-right-width: 0;
border-left-width: 0;
}
.button-native {
border-radius: var(--border-radius);
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
margin-left: 0;
margin-right: 0;
margin-top: 0;
margin-bottom: 0;
-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);
font-family: inherit;
font-size: inherit;
font-style: inherit;
font-weight: inherit;
letter-spacing: inherit;
text-decoration: inherit;
text-indent: inherit;
text-overflow: inherit;
text-transform: inherit;
text-align: inherit;
white-space: inherit;
color: inherit;
display: flex;
position: relative;
align-items: center;
width: 100%;
height: 100%;
min-height: inherit;
transition: var(--transition);
border-width: var(--border-width);
border-style: var(--border-style);
border-color: var(--border-color);
outline: none;
background: var(--background);
line-height: 1;
box-shadow: var(--box-shadow);
contain: layout style;
cursor: pointer;
opacity: var(--opacity);
overflow: var(--overflow);
z-index: 0;
box-sizing: border-box;
appearance: none;
}
.button-native::-moz-focus-inner {
border: 0;
}
.button-inner {
display: flex;
position: relative;
flex-flow: row nowrap;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
z-index: 1;
}
::slotted([slot=start]),
::slotted([slot=end]) {
flex-shrink: 0;
}
::slotted(ion-icon) {
font-size: 1.35em;
pointer-events: none;
}
::slotted(ion-icon[slot=start]) {
-webkit-margin-start: -0.3em;
margin-inline-start: -0.3em;
-webkit-margin-end: 0.3em;
margin-inline-end: 0.3em;
margin-top: 0;
margin-bottom: 0;
}
::slotted(ion-icon[slot=end]) {
-webkit-margin-start: 0.3em;
margin-inline-start: 0.3em;
-webkit-margin-end: -0.2em;
margin-inline-end: -0.2em;
margin-top: 0;
margin-bottom: 0;
}
ion-ripple-effect {
color: var(--ripple-color);
}
.button-native::after {
left: 0;
right: 0;
top: 0;
bottom: 0;
position: absolute;
content: "";
opacity: 0;
}
:host(.ion-focused) {
color: var(--color-focused);
}
:host(.ion-focused) .button-native::after {
background: var(--background-focused);
opacity: var(--background-focused-opacity);
}
@media (any-hover: hover) {
:host(:hover) {
color: var(--color-hover);
}
:host(:hover) .button-native::after {
background: var(--background-hover);
opacity: var(--background-hover-opacity);
}
}
:host(.ion-activated) {
color: var(--color-activated);
}
:host(.ion-activated) .button-native::after {
background: var(--background-activated);
opacity: var(--background-activated-opacity);
}
:host(.button-solid.ion-color) .button-native {
background: var(--ion-color-base);
color: var(--ion-color-contrast);
}
:host(.button-outline.ion-color) .button-native {
border-color: var(--ion-color-base);
background: transparent;
color: var(--ion-color-base);
}
:host(.button-clear.ion-color) .button-native {
background: transparent;
color: var(--ion-color-base);
}
:host(.in-toolbar:not(.ion-color):not(.in-toolbar-color)) .button-native {
color: var(--ion-toolbar-color, var(--color));
}
:host(.button-outline.in-toolbar:not(.ion-color):not(.in-toolbar-color)) .button-native {
border-color: var(--ion-toolbar-color, var(--color, var(--border-color)));
}
:host(.button-solid.in-toolbar:not(.ion-color):not(.in-toolbar-color)) .button-native {
background: var(--ion-toolbar-color, var(--background));
color: var(--ion-toolbar-background, var(--color));
}
/**
* 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;
* }
* }
*/
/**
* 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-radius: 14px;
--padding-top: 13px;
--padding-bottom: 13px;
--padding-start: 1em;
--padding-end: 1em;
--transition: background-color, opacity 100ms linear;
-webkit-margin-start: 2px;
margin-inline-start: 2px;
-webkit-margin-end: 2px;
margin-inline-end: 2px;
margin-top: 4px;
margin-bottom: 4px;
min-height: 3.1em;
font-size: min(1rem, 48px);
font-weight: 500;
letter-spacing: 0;
}
:host(.button-solid) {
--background-activated: var(--ion-color-primary-shade, #004acd);
--background-focused: var(--ion-color-primary-shade, #004acd);
--background-hover: var(--ion-color-primary-tint, #1a65eb);
--background-activated-opacity: 1;
--background-focused-opacity: 1;
--background-hover-opacity: 1;
}
:host(.button-outline) {
--border-radius: 14px;
--border-width: 1px;
--border-style: solid;
--background-activated: var(--ion-color-primary, #0054e9);
--background-focused: var(--ion-color-primary, #0054e9);
--background-hover: transparent;
--background-focused-opacity: .1;
--color-activated: var(--ion-color-primary-contrast, #fff);
}
:host(.button-clear) {
--background-activated: transparent;
--background-activated-opacity: 0;
--background-focused: var(--ion-color-primary, #0054e9);
--background-hover: transparent;
--background-focused-opacity: .1;
font-size: min(1.0625rem, 51px);
font-weight: normal;
}
/**
* The default buttons in a toolbar
* have a different font size/weight
* than buttons outside of a toolbar on iOS.
* However, we still want the "size"/"strong"
* properties to be usable in a toolbar, so we add
* the .in-buttons selector such that we
* can add the different font size/weight in a toolbar
* but still let "size"/"strong" override it.
*/
:host(.in-buttons) {
font-size: clamp(17px, 1.0625rem, 21.08px);
font-weight: 400;
}
:host(.button-large) {
--border-radius: 16px;
--padding-top: 17px;
--padding-start: 1em;
--padding-end: 1em;
--padding-bottom: 17px;
min-height: 3.1em;
font-size: min(1.25rem, 60px);
}
:host(.button-small) {
--border-radius: 6px;
--padding-top: 4px;
--padding-start: 0.9em;
--padding-end: 0.9em;
--padding-bottom: 4px;
min-height: 2.1em;
font-size: min(0.8125rem, 39px);
}
:host(.button-round) {
--border-radius: 999px;
--padding-top: 0;
--padding-start: 26px;
--padding-end: 26px;
--padding-bottom: 0;
}
:host(.button-strong) {
font-weight: 600;
}
:host(.button-has-icon-only) {
--padding-top: 0;
--padding-bottom: var(--padding-top);
--padding-end: var(--padding-top);
--padding-start: var(--padding-end);
min-width: clamp(30px, 2.125em, 60px);
min-height: clamp(30px, 2.125em, 60px);
}
::slotted(ion-icon[slot=icon-only]) {
/**
* The values were provided through a native iOS app.
* min font size: 15px, default font size: 18px, max font size: 43px
*
* Since the `ion-button` uses `rem` for the font size, we can't
* just pass the desired icon font size in `em` to the `
* dynamic-font-clamp`. Instead, we need to adjust the base size
* to account for the ion-button` font size.
*
* For example, if the default font size of `ion-button` is 16px
* (derived from rem), then the base size can use the default font
* size of the icon.
*/
font-size: clamp(15.12px, 1.125em, 43.02px);
}
:host(.button-small.button-has-icon-only) {
min-width: clamp(23px, 2.16em, 54px);
min-height: clamp(23px, 2.16em, 54px);
}
:host(.button-small) ::slotted(ion-icon[slot=icon-only]) {
/**
* The values were provided through a native iOS app.
* min font size: 12px, default font size: 17px, max font size: 40px
*
* Since the `ion-button` uses `rem` for the font size, we can't
* just pass the desired icon font size in `em` to the `
* dynamic-font-clamp`. Instead, we need to adjust the base size
* to account for the ion-button` font size.
*
* For example, if the default font size of `ion-button` is 13px
* (derived from rem) and the default font size of the icon is
* 17px, then the base size would need to be increased.
*/
font-size: clamp(12.1394px, 1.308125em, 40.1856px);
}
:host(.button-large.button-has-icon-only) {
min-width: clamp(46px, 2.5em, 78px);
min-height: clamp(46px, 2.5em, 78px);
}
:host(.button-large) ::slotted(ion-icon[slot=icon-only]) {
/**
* The values were provided through a native iOS app.
* min font size: 15px, default font size: 18px, max font size: 43px
*
* Since the `ion-button` uses `rem` for the font size, we can't
* just pass the desired icon font size in `em` to the `
* dynamic-font-clamp`. Instead, we need to adjust the base size
* to account for the ion-button` font size.
*
* For example, if the default font size of `ion-button` is 20px
* (derived from rem) and the default font size of the icon is
* 18px, then the base size would need to be decreased.
*/
font-size: clamp(15.12px, 0.9em, 43.056px);
}
:host(.button-outline.ion-focused.ion-color) .button-native,
:host(.button-clear.ion-focused.ion-color) .button-native {
color: var(--ion-color-base);
}
:host(.button-outline.ion-focused.ion-color) .button-native::after,
:host(.button-clear.ion-focused.ion-color) .button-native::after {
background: var(--ion-color-base);
}
:host(.button-solid.ion-color.ion-focused) .button-native::after {
background: var(--ion-color-shade);
}
@media (any-hover: hover) {
:host(.button-clear:not(.ion-activated):hover),
:host(.button-outline:not(.ion-activated):hover) {
opacity: 0.6;
}
:host(.button-clear.ion-color:hover) .button-native,
:host(.button-outline.ion-color:hover) .button-native {
color: var(--ion-color-base);
}
:host(.button-clear.ion-color:hover) .button-native::after,
:host(.button-outline.ion-color:hover) .button-native::after {
background: transparent;
}
:host(.button-solid.ion-color:hover) .button-native::after {
background: var(--ion-color-tint);
}
:host(:hover.button-solid.in-toolbar:not(.ion-color):not(.in-toolbar-color):not(.ion-activated)) .button-native::after {
background: #fff;
opacity: 0.1;
}
}
:host(.button-clear.ion-activated) {
opacity: 0.4;
}
:host(.button-outline.ion-activated.ion-color) .button-native {
color: var(--ion-color-contrast);
}
:host(.button-outline.ion-activated.ion-color) .button-native::after {
background: var(--ion-color-base);
}
:host(.button-solid.ion-color.ion-activated) .button-native::after {
background: var(--ion-color-shade);
}
:host(.button-outline.ion-activated.in-toolbar:not(.ion-color):not(.in-toolbar-color)) .button-native {
background: var(--ion-toolbar-color, var(--color));
color: var(--ion-toolbar-background, var(--background), var(--ion-color-primary-contrast, #fff));
}