For AI agents: the complete documentation index is available at https://ifhover.github.io/leaf-ui/en/llms.txt, the full documentation bundle is available at https://ifhover.github.io/leaf-ui/en/llms-full.txt, and this page is available as Markdown at https://ifhover.github.io/leaf-ui/en/guide/colors.md.

Colors

Each of the five semantic colors generates seven derived shades, while neutral keeps its nine-step scale. Light and dark modes share both.

Global Color Variables

Each row shows an independently preserved base color and its derived band. The five semantic colors provide 35 derived swatches and neutral provides nine, for 44 in total. Select a swatch to see its value and CSS variable.

Primary

Base #007aff--leaf-color-primary
--leaf-color-primary-light-3rgba(77, 162, 255, 1)

Success

Base #4bb418--leaf-color-success
--leaf-color-success-light-3rgba(129, 203, 93, 1)

Danger

Base #ff4d4f--leaf-color-danger
--leaf-color-danger-light-3rgba(255, 130, 132, 1)

Warning

Base #e69f12--leaf-color-warning
--leaf-color-warning-light-3rgba(238, 188, 89, 1)

Info

Base #1677ff--leaf-color-info
--leaf-color-info-light-3rgba(92, 160, 255, 1)

Neutral

Base #707070--leaf-color-neutral
--leaf-color-neutral-500#8c8c8c

Change Base Colors

Configure the primary base with theme.primaryColor, and the other five with theme.tokens. Update these JS values through ConfigProvider to regenerate the scales; changing DOM styles does not trigger JS theme recalculation.

The example uses the light appearance and sets tokens.mutedSurfaceColor to rgb(244,243,239). The outer canvas of a layered Card uses this surface, while inner Card content and clean controls keep the content surface. Explicit component overrides take precedence.

All on*Color values default to white. Set the corresponding value to #000000 for black text and choose suitable foreground/background pairs for your application.

Primary
Success
Danger
Warning
Info
Neutral
Muted surface
SuccessDangerWarningInfo

Shared muted surface

The active tab tint and inset content keep using the content surface.
colors.tsx
import { Button, Card, ColorPicker, ConfigProvider, Flex, Tabs, Tag } from '@ifhover/leaf-ui';
import { useState } from 'react';

const colorOptions = [
  ['primary', 'Primary'],
  ['success', 'Success'],
  ['danger', 'Danger'],
  ['warning', 'Warning'],
  ['info', 'Info'],
  ['neutral', 'Neutral'],
  ['mutedSurface', 'Muted surface'],
] as const;

export function ThemeColors() {
  const [colors, setColors] = useState({
    primary: '#007aff',
    success: '#4bb418',
    danger: '#ff4d4f',
    warning: '#e69f12',
    info: '#1677ff',
    neutral: '#707070',
    mutedSurface: 'rgb(244,243,239)',
  });
  const [blackText, setBlackText] = useState(false);
  const foreground = blackText ? '#000000' : '#ffffff';
  return (
    <ConfigProvider
      theme={{
        primaryColor: colors.primary,
        appearance: 'light',
        tokens: {
          successColor: colors.success,
          dangerColor: colors.danger,
          warningColor: colors.warning,
          infoColor: colors.info,
          neutralColor: colors.neutral,
          mutedSurfaceColor: colors.mutedSurface,
          onPrimaryColor: foreground,
          onSuccessColor: foreground,
          onDangerColor: foreground,
          onWarningColor: foreground,
          onInfoColor: foreground,
        },
      }}
    >
      <Flex direction="column" gap={16}>
        <Flex wrap gap={12}>
          {colorOptions.map(([name, label]) => (
            <Flex key={name} direction="column" gap={4}>
              <span>{label}</span>
              <ColorPicker
                aria-label={label}
                value={colors[name]}
                disableAlpha
                showText
                onChange={(value) => setColors((previous) => ({ ...previous, [name]: value }))}
              />
            </Flex>
          ))}
        </Flex>
        <Flex wrap gap={8}>
          <Button variant="solid">Save</Button>
          <Tag color="success" variant="soft">
            Success
          </Tag>
          <Tag color="danger" variant="soft">
            Danger
          </Tag>
          <Tag color="warning" variant="soft">
            Warning
          </Tag>
          <Tag color="info" variant="soft">
            Info
          </Tag>
        </Flex>
        <Button onClick={() => setBlackText(!blackText)}>
          {blackText ? 'Use white text' : 'Use black text'}
        </Button>
        <Card
          variant="layered"
          size="sm"
          title="Shared muted surface"
          description="The layered Card outer canvas uses mutedSurfaceColor."
        >
          <Tabs
            type="segmented"
            size="sm"
            block
            aria-label="Surface levels"
            items={[
              {
                key: 'surface',
                label: 'Content surface',
                children: 'The active tab tint and inset content keep using the content surface.',
              },
              {
                key: 'muted',
                label: 'Muted surface',
                children:
                  'Outer layered canvases use mutedSurfaceColor without tinting the clean rail.',
              },
            ]}
          />
        </Card>
      </Flex>
    </ConfigProvider>
  );
}