Skip to content

Theme Customization ​

CSS Variables ​

lh-ui-plus uses CSS variables for theming. All theme variables are prefixed with --lh-.

Key variables include:

  • --lh-primary-color - Primary color
  • --lh-success-color - Success color
  • --lh-warning-color - Warning color
  • --lh-danger-color - Danger color
  • --lh-info-color - Info color

Custom Theme via ConfigProvider ​

vue
<script setup lang="ts">
import { ref } from 'vue'

const themeVars = ref({
  primaryColor: '#1890ff',
  successColor: '#52c41a',
  warningColor: '#faad14',
  dangerColor: '#f5222d',
  infoColor: '#91d5ff',
})
</script>

<template>
  <LhConfigProvider :theme-vars="themeVars">
    <div>
      <LhButton type="primary">Custom Primary</LhButton>
      <LhButton type="success">Custom Success</LhButton>
    </div>
  </LhConfigProvider>
</template>

Dark Mode ​

vue
<script setup lang="ts">
import { ref } from 'vue'

const isDark = ref(false)
</script>

<template>
  <div :class="{ 'dark-mode': isDark }">
    <LhButton @click="isDark = !isDark">Toggle Dark Mode</LhButton>
    <LhButton type="primary">Content</LhButton>
  </div>
</template>

<style scoped>
.dark-mode {
  --lh-primary-color: #409eff;
  --lh-bg-color: #1a1a1a;
  --lh-text-color: #ffffff;
}
</style>

sx Quick Layout ​

The sx prop provides a declarative way to set spacing and sizing on a component inline, without writing CSS. It is currently available on Button, Input, Dialog, and Tooltip.

How it works ​

sx is based on an 8px scale: numeric values are multiplied by 8 to produce pixels. For example, mt: 2 is equivalent to marginTop: 16px.

Supported props ​

Spacing ​

PropDescriptionExampleEquivalent CSS
mMargin on all sidesm: 2margin: 16px
mxHorizontal marginmx: 1marginLeft: 8px; marginRight: 8px
myVertical marginmy: 1marginTop: 8px; marginBottom: 8px
mt, mr, mb, mlSingle-side marginmt: 2marginTop: 16px
pPadding on all sidesp: 3padding: 24px
pxHorizontal paddingpx: 2paddingLeft: 16px; paddingRight: 16px
pyVertical paddingpy: 1paddingTop: 8px; paddingBottom: 8px
pt, pr, pb, plSingle-side paddingpt: 2paddingTop: 16px

Sizing ​

PropDescriptionExample
wWidth (numbers are px, strings are used as-is)w: 200 or w: '100%'
hHeighth: 100 or h: 'auto'

Flexbox ​

PropDescriptionExample
displayDisplay typedisplay: 'flex'
flexflex shorthandflex: '1 1 0%'
flexDirectionMain axis directionflexDirection: 'column'
alignItemsCross-axis alignmentalignItems: 'center'
justifyContentMain-axis alignmentjustifyContent: 'flex-end'

Example ​

vue
<script setup lang="ts">
import { ref } from 'vue'

const visible = ref(false)
</script>

<template>
  <!-- Button spacing -->
  <LhButton type="primary" :sx="{ mt: 2, mx: 1 }">Spaced button</LhButton>

  <!-- Input margin -->
  <LhInput placeholder="Vertical margin" :sx="{ my: 1 }" />

  <!-- Dialog max width -->
  <LhDialog v-model="visible" title="Example" :sx="{ maxWidth: 400 }">
    <p>With a max width</p>
  </LhDialog>
</template>

Beauty of tradition, foundation of code