Ionic/core/src/components/button/button.scss

308 lines
6.6 KiB
SCSS

@import "./button.vars";
// Button
// --------------------------------------------------
: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: $font-family-base;
text-align: center;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
user-select: none;
vertical-align: top; // the better option for most scenarios
vertical-align: -webkit-baseline-middle; // the best for those that support it
pointer-events: auto;
font-kerning: none;
}
:host(.button-disabled) {
cursor: default;
opacity: .5;
pointer-events: none;
}
// Solid Button
// --------------------------------------------------
// Default Solid Color
:host(.button-solid) {
--background: #{ion-color(primary, base)};
--color: #{ion-color(primary, contrast)};
}
// Outline Button
// --------------------------------------------------
// Default Outline Color
:host(.button-outline) {
--border-color: #{ion-color(primary, base)};
--background: transparent;
--color: #{ion-color(primary, base)};
}
// Clear Button
// --------------------------------------------------
// Default Clear Color
:host(.button-clear) {
--border-width: 0;
--background: transparent;
--color: #{ion-color(primary, base)};
}
// Block Button
// --------------------------------------------------
:host(.button-block) {
display: block;
}
:host(.button-block) .button-native {
@include margin-horizontal(0);
display: block;
width: 100%;
clear: both;
contain: content;
}
:host(.button-block) .button-native::after {
clear: both;
}
// Full Button
// --------------------------------------------------
:host(.button-full) {
display: block;
}
:host(.button-full) .button-native {
@include margin-horizontal(0);
display: block;
width: 100%;
contain: content;
}
:host(.button-full:not(.button-round)) .button-native {
@include border-radius(0);
border-right-width: 0;
border-left-width: 0;
}
.button-native {
@include border-radius(var(--border-radius));
@include font-smoothing();
@include margin(0);
@include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start));
@include text-inherit();
display: block;
position: relative;
width: 100%;
height: 100%;
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);
overflow: hidden;
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;
}
// Button Icons
// --------------------------------------------------
::slotted(ion-icon) {
font-size: 1.4em;
pointer-events: none;
}
::slotted(ion-icon[slot="start"]) {
@include margin(0, .3em, 0, -.3em);
}
::slotted(ion-icon[slot="end"]) {
@include margin(0, -.2em, 0, .3em);
}
::slotted(ion-icon[slot="icon-only"]) {
font-size: 1.8em;
}
// Button Ripple effect
// --------------------------------------------------
ion-ripple-effect {
color: var(--ripple-color);
}
// Button: States
// --------------------------------------------------
.button-native::after {
@include button-state();
}
// Button Activated
:host(.ion-activated) {
color: var(--color-activated);
}
:host(.ion-activated) .button-native::after {
background: var(--background-activated);
opacity: var(--background-activated-opacity);
}
// Button Focused
:host(.ion-focused) {
color: var(--color-focused);
}
:host(.ion-focused) .button-native::after {
background: var(--background-focused);
opacity: var(--background-focused-opacity);
}
// Button Hover
@media (any-hover: hover) {
:host(:hover) {
color: var(--color-hover);
}
:host(:hover) .button-native::after {
background: var(--background-hover);
opacity: var(--background-hover-opacity);
}
}
// Button Colors
// --------------------------------------------------
// Solid Button with Color
:host(.button-solid.ion-color) .button-native {
background: current-color(base);
color: current-color(contrast);
}
// Outline Button with Color
:host(.button-outline.ion-color) .button-native {
border-color: current-color(base);
background: transparent;
color: current-color(base);
}
// Clear Button with Color
:host(.button-clear.ion-color) .button-native {
background: transparent;
color: current-color(base);
}