Skip to content

Global Configuration Theme

Style Import

scss
/* This is a fully expanded import, which can be imported globally */
@use '@hy-app/ui/index.scss' as *;
scss
.custom-style {
    background: $hy-background;
    color: $hy-text-color;
}
scss
/* This is an aliased import, which needs to be imported in the current component */
@use '@hy-app/ui/index.scss' as hy;

.custom-style {
    background: hy.$hy-background;
    color: hy.$hy-text-color;
}

Globally Modify Component Theme Styles

Basic Configuration

scss
/* uni.scss */
page {
  --hy-text-color: #000000;
  --hy-theme-color: red;
  --hy-background: #f6f6f6;
  ...
}

Configuration when config-provider sets theme

Note

When your components on a common page are wrapped with the hy-config-provider component, and the theme property is set to light or dark, you need to make the following changes

With the following settings, you can set the common colors for both dark and light themes

scss
/* Light uni.scss */
page .hy-theme--light {
    --hy-text-color: #000000;
    --hy-background: #f8f8f8;
}
/* Dark uni.scss */
page .hy-theme--dark {
    --hy-text-color: #ffffff;
    --hy-background: #1b1b1f;
}

Theme CSS Variables

Primary Color

Usage VariableCSS VariableDefault ValueDescription
$hy-primary--hy-primary#2979ffPrimary color
$hy-primary-dark--hy-primary-dark#2b85e4Primary dark
$hy-primary-disabled--hy-primary-disabled#a0cfffPrimary disabled
$hy-primary-light--hy-primary-light#ecf5ffPrimary light

Warning Color

Usage VariableCSS VariableDefault ValueDescription
$hy-warning--hy-warning#ff9900Warning color
$hy-warning-dark--hy-warning-dark#f29100Warning dark
$hy-warning-disabled--hy-warning-disabled#fcbd71Warning disabled
$hy-warning-light--hy-warning-light#fdf6ecWarning light

Success Color

Usage VariableCSS VariableDefault ValueDescription
$hy-success--hy-success#19be6bSuccess color
$hy-success-dark--hy-success-dark#18b566Success dark
$hy-success-disabled--hy-success-disabled#71d5a1Success disabled
$hy-success-light--hy-success-light#dbf1e1Success light

Error Color

Usage VariableCSS VariableDefault ValueDescription
$hy-error--hy-error#fa3534Error color
$hy-error-dark--hy-error-dark#dd6161Error dark
$hy-error-disabled--hy-error-disabled#fab6b6Error disabled
$hy-error-light--hy-error-light#fef0f0Error light

Info Color

Usage VariableCSS VariableDefault ValueDescription
$hy-info--hy-info#909399Info color
$hy-info-dark--hy-info-dark#82848aInfo dark
$hy-info-disabled--hy-info-disabled#c8c9ccInfo disabled
$hy-info-light--hy-info-light#f4f4f5Info light

Text Color

Usage VariableCSS VariableDefault ValueDescription
$hy-text-color--hy-text-color#3c3c43Basic text
$hy-text-color--2--hy-text-color--2#67676cSecondary text/hint
$hy-text-color--3--hy-text-color--3#929295Light hint
$hy-text-color--4--hy-text-color--4rgba(0, 0, 0, 0.1)Extremely light
$hy-text-color--grey--hy-text-color--grey#999Auxiliary gray
$hy-text-color--placeholder--hy-text-color--placeholder#808080Placeholder
$hy-text-color--disabled--hy-text-color--disabled#c0c0c0Disabled state
$hy-text-color-hover--hy-text-color-hover#58595bHover state

Font Size

Usage VariableCSS VariableDefault ValueDescription
$hy-font-size-xs--hy-font-size-xs20rpxExtra small font
$hy-font-size-sm--hy-font-size-sm24rpxSmall font
$hy-font-size-base--hy-font-size-base28rpxBase font
$hy-font-size-md--hy-font-size-md32rpxMedium font
$hy-font-size-lg--hy-font-size-lg36rpxLarge font
$hy-font-size-xl--hy-font-size-xl40rpxExtra large font
$hy-font-size-xxl--hy-font-size-xxl48rpxExtra extra large font

Font Style

Usage VariableCSS VariableDefault ValueDescription
$hy-font-weight-normal--hy-font-weight-normal400Normal weight
$hy-font-weight-medium--hy-font-weight-medium500Medium weight
$hy-font-weight-bold--hy-font-weight-bold600Bold

Line Height

Usage VariableCSS VariableDefault ValueDescription
$hy-line-height-sm--hy-line-height-sm1.4Small line height
$hy-line-height-base--hy-line-height-base1.5Base line height
$hy-line-height-lg--hy-line-height-lg1.8Large line height

Icon Color

Usage VariableCSS VariableDefault ValueDescription
$hy-icon-color--hy-icon-color#606266Default icon

Background Color

Usage VariableCSS VariableDefault ValueDescription
$hy-background--hy-background#f8f8f8Page background
$hy-background--2--hy-background--2#ffffffCard/popup background
$hy-background--3--hy-background--3#646566Dark background
$hy-background--container--hy-background--container#ffffffContainer background
$hy-background--disabled--hy-background--disabled#f5f5f5Disabled background
$hy-background--track--hy-background--track#f6f6f6Track background
$hy-background--empty--hy-background--empty#f3f3f3Empty state background
$hy-background--skeleton--hy-background--skeleton#EEEEEESkeleton screen background
$hy-background--hover--hy-background--hoverrgba(0, 0, 0, 0.1)Tap state background
$hy-background-mask--hy-background-maskrgba(0, 0, 0, 0.5)Mask
$hy-background--active--hy-background--active#FFFFFFSelected background
$hy-background--close--hy-background--close#f0f0f0Close background
$hy-background--box--hy-background--box#FFFFFFBox background
$hy-background--line--hy-background--linergba(0, 0, 0, 0.15)Thin line background
$hy-background--table-header--hy-background--table-header#FAFAFATable header background
$hy-background-image--mask--two-flanks--hy-background-image--mask--two-flanks-Forms a haze shape toward both sides

Image Size

Usage VariableCSS VariableDefault Value
$hy-img-size-sm--hy-img-size-sm45rpx
$hy-img-size-base--hy-img-size-base80rpx
$hy-img-size-lg--hy-img-size-lg120rpx

Avatar Size

Usage VariableCSS VariableDefault Value
$hy-avatar-size-sm--hy-avatar-size-sm80rpx
$hy-avatar-size-base--hy-avatar-size-base100rpx
$hy-avatar-size-lg--hy-avatar-size-lg120rpx

Opacity

Usage VariableCSS VariableDefault ValueDescription
$hy-opacity-disabled--hy-opacity-disabled0.3Disabled state opacity

Border Radius

Usage VariableCSS VariableDefault ValueDescription
$hy-radius-no--hy-radius-no0No radius
$hy-radius-sm--hy-radius-sm8rpxSmall radius
$hy-radius-base--hy-radius-base20rpxDefault radius
$hy-radius-lg--hy-radius-lg32rpxLarge radius
$hy-radius-circle--hy-radius-circle50%Circle
$hy-radius-semicircle--hy-radius-semicircle100pxSemicircle

Spacing

Usage VariableCSS VariableDefault ValueDescription
$hy-border-margin-padding-sm--hy-border-margin-padding-sm10rpxSmall spacing
$hy-border-margin-padding-base--hy-border-margin-padding-base20rpxDefault spacing
$hy-border-margin-padding-lg--hy-border-margin-padding-lg30rpxLarge spacing
$hy-border-margin-padding-xl--hy-border-margin-padding-xl48rpxExtra large spacing
$hy-border-margin-padding-xxl--hy-border-margin-padding-xxl64rpxExtra extra large spacing

Border

Usage VariableCSS VariableDefault ValueDescription
$hy-border-line--hy-border-line1px solid #e8e8e8Border

Border Color

Usage VariableCSS VariableDefault ValueDescription
$hy-border-color--hy-border-color#c2c2c4Default border
$hy-border-color-light--hy-border-color-light#c8c7ccLight border
$hy-border-color--2--hy-border-color--2#c9caccSecondary border color

Border Width

Usage VariableCSS VariableDefault ValueDescription
$hy-border-width-xs--hy-border-width-xs1rpxExtra thin border
$hy-border-width-sm--hy-border-width-sm2rpxThin border
$hy-border-width-base--hy-border-width-base4rpxBase border
$hy-border-width-lg--hy-border-width-lg8rpxThick border

Shadow Levels

Usage VariableCSS VariableDefault ValueDescription
$hy-box-shadow--hy-box-shadow0 0 10rpx 4rpx rgba(0, 0, 0, 0.16)Default shadow
$hy-shadow-sm--hy-shadow-sm0 2rpx 8rpx rgba(0, 0, 0, 0.06)Slight shadow
$hy-shadow-base--hy-shadow-base0 4rpx 16rpx rgba(0, 0, 0, 0.08)Base shadow
$hy-shadow-lg--hy-shadow-lg0 8rpx 24rpx rgba(0, 0, 0, 0.12)Strong shadow
$hy-shadow-xl--hy-shadow-xl0 12rpx 40rpx rgba(0, 0, 0, 0.16)Extremely strong shadow

Opacity

Usage VariableCSS VariableDefault ValueDescription
$hy-opacity-xs--hy-opacity-xs0.1Extremely low opacity
$hy-opacity-sm--hy-opacity-sm0.3Low opacity
$hy-opacity-base--hy-opacity-base0.5Medium opacity
$hy-opacity-lg--hy-opacity-lg0.7High opacity
$hy-opacity-disabled--hy-opacity-disabled0.4Disabled state opacity

Transition Curves

Usage VariableCSS VariableDefault ValueDescription
$hy-transition-ease--hy-transition-easecubic-bezier(0.4, 0, 0.2, 1)Standard curve
$hy-transition-bounce--hy-transition-bouncecubic-bezier(0.34, 1.56, 0.64, 1)Bounce curve