Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): move theme-dependent styling to the dark variant (#45710)

yyhd59a26468470
diff --git a/packages/dify-ui/AGENTS.md b/packages/dify-ui/AGENTS.md
index 83cfaddb334..3d1adad7194 100644
--- a/packages/dify-ui/AGENTS.md
+++ b/packages/dify-ui/AGENTS.md
@@ -27,7 +27,7 @@ This file owns the package boundary. Read the matching contract guide below dire
- Form structure, labels, and value ownership: [Forms]
- Picker choice and typed values: [Selection]
- Portals, presence, layering, and floating-surface semantics: [Overlays]
-- State styling, callbacks, composition, Tailwind integration, and border radius: [Styling]
+- State styling, callbacks, composition, Tailwind integration, theme, and border radius: [Styling]
- Package test ownership and setup: [Testing and development]
A component needs a local README only when it owns a substantial Dify-specific contract that its
diff --git a/packages/dify-ui/README.md b/packages/dify-ui/README.md
index 3b3eea22aee..a8f6404b1ed 100644
--- a/packages/dify-ui/README.md
+++ b/packages/dify-ui/README.md
@@ -56,7 +56,7 @@ Utilities:
- `./use-merged-refs` exports `useMergedRefs` for combining internal and caller refs, including callback cleanup.
- `./use-ref-with-init` exports `useRefWithInit` for lazy ref initialization. Later initializer or argument changes do not reset the ref; initialization runs during render and must be safe to retry or discard.
- `./use-render` exports `useRender` for building a part with Base UI's `render` prop, `className(state)` callback and state data attributes; `./merge-props` exports `mergeProps` for chaining event handlers and merging `className`/`style` when composing parts.
-- `./styles.css` provides design tokens, theme variables, and shared utilities.
+- `./styles.css` provides design tokens, theme variables, the `dark` variant, and shared utilities.
## Guides
diff --git a/packages/dify-ui/docs/styling.md b/packages/dify-ui/docs/styling.md
index c8e81bd938c..b3018c2251a 100644
--- a/packages/dify-ui/docs/styling.md
+++ b/packages/dify-ui/docs/styling.md
@@ -61,6 +61,14 @@ stylesheet:
@source not '../../../packages/dify-ui/src/**/*.stories.{ts,tsx}';
```
+## Theme
+
+Tokens and the `dark:` variant read the `data-theme` attribute that the consumer sets to `light` or
+`dark` on `<html>`; tokens have no values without it. Appearance follows the theme through semantic
+tokens first. When no token renders the same value, use `dark:`, which ignores the system color
+scheme. Do not choose classes from a theme value in JavaScript; read the theme there only when a
+value must leave CSS.
+
## Writing direction
Use logical inline-direction utilities for spacing, offsets, borders, corners, and alignment.
diff --git a/packages/dify-ui/src/styles/styles.css b/packages/dify-ui/src/styles/styles.css
index 6df47018b1c..32aedcbb0af 100644
--- a/packages/dify-ui/src/styles/styles.css
+++ b/packages/dify-ui/src/styles/styles.css
@@ -10,6 +10,7 @@
*/
@import '../themes/theme.css';
+@import '../themes/variant.css';
@import '../themes/light.css' layer(base);
@import '../themes/dark.css' layer(base);
@import './utilities.css';
diff --git a/packages/dify-ui/src/themes/variant.css b/packages/dify-ui/src/themes/variant.css
new file mode 100644
index 00000000000..da2768e5f36
--- /dev/null
+++ b/packages/dify-ui/src/themes/variant.css
@@ -0,0 +1 @@
+@custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *));
diff --git a/web/app/components/auth-shell/header.tsx b/web/app/components/auth-shell/header.tsx
index 0199a8ceb26..4894aae9cf5 100644
--- a/web/app/components/auth-shell/header.tsx
+++ b/web/app/components/auth-shell/header.tsx
@@ -4,7 +4,7 @@ import { useSuspenseQuery } from '@tanstack/react-query'
import { useLocale } from '#i18n'
import { DifyLogo } from '@/app/components/base/logo/dify-logo'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import ThemeSelector from '@/features/theme/theme-selector'
+import { ThemeSelector } from '@/features/theme/theme-selector'
import { setLocaleOnClient } from '@/i18n/client'
import { languages } from '@/i18n/language'
import { useRouter } from '@/next/navigation'
diff --git a/web/app/components/base/logo/dify-logo.tsx b/web/app/components/base/logo/dify-logo.tsx
index 4df9d8bb119..45d7ef102dc 100644
--- a/web/app/components/base/logo/dify-logo.tsx
+++ b/web/app/components/base/logo/dify-logo.tsx
@@ -4,21 +4,18 @@ import { cn } from '@langgenius/dify-ui/cn'
import { cva } from 'class-variance-authority'
import { basePath } from '@/utils/var'
-const difyLogoVariants = cva(
- 'block object-contain [html[data-theme=dark]_&]:brightness-0 [html[data-theme=dark]_&]:invert',
- {
- variants: {
- size: {
- small: 'h-4 w-9',
- medium: 'h-5.5 w-12',
- large: 'h-7 w-16',
- },
- },
- defaultVariants: {
- size: 'medium',
+const difyLogoVariants = cva('block object-contain dark:brightness-0 dark:invert', {
+ variants: {
+ size: {
+ small: 'h-4 w-9',
+ medium: 'h-5.5 w-12',
+ large: 'h-7 w-16',
},
},
-)
+ defaultVariants: {
+ size: 'medium',
+ },
+})
export type DifyLogoProps = Omit<
ComponentProps<'img'>,
diff --git a/web/app/components/base/markdown-blocks/code-block.tsx b/web/app/components/base/markdown-blocks/code-block.tsx
index 37fe9ac71b4..3ecd802cfc3 100644
--- a/web/app/components/base/markdown-blocks/code-block.tsx
+++ b/web/app/components/base/markdown-blocks/code-block.tsx
@@ -372,6 +372,7 @@ export const CodeBlock: any = memo(({ inline, className, children = '', ...props
if (chartState === 'loading') {
return (
<div
+ className="dark:bg-components-input-bg-normal"
style={{
minHeight: '350px',
width: '100%',
@@ -381,9 +382,6 @@ export const CodeBlock: any = memo(({ inline, className, children = '', ...props
justifyContent: 'center',
borderBottomLeftRadius: '10px',
borderBottomRightRadius: '10px',
- backgroundColor: isDarkMode
- ? 'var(--color-components-input-bg-normal)'
- : 'transparent',
color: 'var(--color-text-secondary)',
}}
>
diff --git a/web/app/components/billing/pricing/plans/self-hosted-plan-item/index.tsx b/web/app/components/billing/pricing/plans/self-hosted-plan-item/index.tsx
index 7897b4f2ef2..828a1f68a98 100644
--- a/web/app/components/billing/pricing/plans/self-hosted-plan-item/index.tsx
+++ b/web/app/components/billing/pricing/plans/self-hosted-plan-item/index.tsx
@@ -3,7 +3,6 @@ import type { SelfHostedPlan } from '../../../config'
import { buttonVariants } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import { useTranslation } from 'react-i18next'
-import { useResolvedTheme } from '@/features/theme/hooks'
import { SELF_HOSTED_PLAN_URLS } from '../../../config'
import Community from '../../assets/community'
import Enterprise from '../../assets/enterprise'
@@ -40,7 +39,6 @@ const STYLE_MAP = {
export function SelfHostedPlanItem({ plan }: { plan: SelfHostedPlan }) {
const { t } = useTranslation(['billing'])
- const theme = useResolvedTheme()
const i18nPrefix = `plans.${plan}` as const
const isFreePlan = plan === 'community'
const isPremiumPlan = plan === 'premium'
@@ -91,17 +89,14 @@ export function SelfHostedPlanItem({ plan }: { plan: SelfHostedPlan }) {
)}
{isPremiumPlan && (
<span aria-hidden className="pt-1.75 pb-px">
- {theme === 'light' ? (
- <span
- aria-hidden
- className="i-custom-public-billing-aws-marketplace-light h-6 w-31.5"
- />
- ) : (
- <span
- aria-hidden
- className="i-custom-public-billing-aws-marketplace-dark h-6 w-31.5"
- />
- )}
+ <span
+ aria-hidden
+ className="i-custom-public-billing-aws-marketplace-light h-6 w-31.5 dark:hidden"
+ />
+ <span
+ aria-hidden
+ className="i-custom-public-billing-aws-marketplace-dark h-6 w-31.5 not-dark:hidden"
+ />
</span>
)}
</span>
diff --git a/web/app/components/header/account-setting/model-provider-page/provider-icon/index.tsx b/web/app/components/header/account-setting/model-provider-page/provider-icon/index.tsx
index 701dfc1f622..5732d4278a9 100644
--- a/web/app/components/header/account-setting/model-provider-page/provider-icon/index.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/provider-icon/index.tsx
@@ -24,12 +24,11 @@ const ProviderIcon: FC<ProviderIconProps> = ({ provider, className }) => {
if (provider.provider === 'langgenius/anthropic/anthropic') {
return (
<div className={cn('py-1.75', className)}>
- {theme === 'dark' && (
- <span aria-hidden className="i-custom-public-llm-anthropic-light h-2.5 w-22.5" />
- )}
- {theme === 'light' && (
- <span aria-hidden className="i-custom-public-llm-anthropic-dark h-2.5 w-22.5" />
- )}
+ <span
+ aria-hidden
+ className="i-custom-public-llm-anthropic-light h-2.5 w-22.5 not-dark:hidden"
+ />
+ <span aria-hidden className="i-custom-public-llm-anthropic-dark h-2.5 w-22.5 dark:hidden" />
</div>
)
}
diff --git a/web/app/components/plugins/base/badges/__tests__/icon-with-tooltip.spec.tsx b/web/app/components/plugins/base/badges/__tests__/icon-with-tooltip.spec.tsx
index 41ffe70bf7e..2998a474065 100644
--- a/web/app/components/plugins/base/badges/__tests__/icon-with-tooltip.spec.tsx
+++ b/web/app/components/plugins/base/badges/__tests__/icon-with-tooltip.spec.tsx
@@ -6,7 +6,6 @@ describe('IconWithTooltip', () => {
it('exposes the badge meaning without opening the tooltip', () => {
render(
<IconWithTooltip
- theme="light"
lightIconClassName="i-custom-public-plugins-partner-light"
darkIconClassName="i-custom-public-plugins-partner-dark"
popupContent="Partner plugin"
diff --git a/web/app/components/plugins/base/badges/icon-with-tooltip.tsx b/web/app/components/plugins/base/badges/icon-with-tooltip.tsx
index 8290c0cf24a..c51f9cf27b0 100644
--- a/web/app/components/plugins/base/badges/icon-with-tooltip.tsx
+++ b/web/app/components/plugins/base/badges/icon-with-tooltip.tsx
@@ -1,5 +1,4 @@
import type { FC } from 'react'
-import type { ResolvedTheme } from '@/features/theme/theme'
import { cn } from '@langgenius/dify-ui/cn'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
import * as React from 'react'
@@ -7,23 +6,20 @@ import * as React from 'react'
type IconWithTooltipProps = {
className?: string
popupContent?: string
- theme: ResolvedTheme
lightIconClassName: string
darkIconClassName: string
}
const IconWithTooltip: FC<IconWithTooltipProps> = ({
className,
- theme,
popupContent,
lightIconClassName,
darkIconClassName,
}) => {
- const isDark = theme === 'dark'
- const iconClassName = cn(isDark ? darkIconClassName : lightIconClassName, 'size-5', className)
const icon = (
<span className="flex shrink-0 items-center justify-center">
- <span aria-hidden className={iconClassName} />
+ <span aria-hidden className={cn(lightIconClassName, 'size-5 dark:hidden', className)} />
+ <span aria-hidden className={cn(darkIconClassName, 'size-5 not-dark:hidden', className)} />
{popupContent && <span className="sr-only">{popupContent}</span>}
</span>
)
diff --git a/web/app/components/plugins/base/badges/partner.tsx b/web/app/components/plugins/base/badges/partner.tsx
index e53ef26d376..828d3085311 100644
--- a/web/app/components/plugins/base/badges/partner.tsx
+++ b/web/app/components/plugins/base/badges/partner.tsx
@@ -1,7 +1,6 @@
'use client'
import type { FC } from 'react'
-import { useResolvedTheme } from '@/features/theme/hooks'
import IconWithTooltip from './icon-with-tooltip'
type PartnerProps = {
@@ -10,12 +9,9 @@ type PartnerProps = {
}
const Partner: FC<PartnerProps> = ({ className, text }) => {
- const theme = useResolvedTheme()
-
return (
<IconWithTooltip
className={className}
- theme={theme}
lightIconClassName={'i-custom-public-plugins-partner-light'}
darkIconClassName={'i-custom-public-plugins-partner-dark'}
popupContent={text}
diff --git a/web/app/components/plugins/base/badges/verified.tsx b/web/app/components/plugins/base/badges/verified.tsx
index 7ea5f152c90..7dc87731fa0 100644
--- a/web/app/components/plugins/base/badges/verified.tsx
+++ b/web/app/components/plugins/base/badges/verified.tsx
@@ -1,5 +1,4 @@
import type { FC } from 'react'
-import { useResolvedTheme } from '@/features/theme/hooks'
import IconWithTooltip from './icon-with-tooltip'
type VerifiedProps = {
@@ -8,12 +7,9 @@ type VerifiedProps = {
}
const Verified: FC<VerifiedProps> = ({ className, text }) => {
- const theme = useResolvedTheme()
-
return (
<IconWithTooltip
className={className}
- theme={theme}
lightIconClassName={'i-custom-public-plugins-verified-light'}
darkIconClassName={'i-custom-public-plugins-verified-dark'}
popupContent={text}
diff --git a/web/app/components/plugins/marketplace/empty/line.tsx b/web/app/components/plugins/marketplace/empty/line.tsx
index 43f3c4166f8..5c52b36af20 100644
--- a/web/app/components/plugins/marketplace/empty/line.tsx
+++ b/web/app/components/plugins/marketplace/empty/line.tsx
@@ -1,23 +1,43 @@
-'use client'
-import { useResolvedTheme } from '@/features/theme/hooks'
+import { cn } from '@langgenius/dify-ui/cn'
type LineProps = {
className?: string
}
const Line = ({ className }: LineProps) => {
- const theme = useResolvedTheme()
- const isDarkMode = theme === 'dark'
-
- if (isDarkMode) {
- return (
+ return (
+ <>
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="2"
+ height="241"
+ viewBox="0 0 2 241"
+ fill="none"
+ className={cn(className, 'dark:hidden')}
+ >
+ <path d="M1 0.5L1 240.5" stroke="url(#paint0_linear_1989_74474)" />
+ <defs>
+ <linearGradient
+ id="paint0_linear_1989_74474"
+ x1="-7.99584"
+ y1="240.5"
+ x2="-7.88094"
+ y2="0.50004"
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop stopColor="white" stopOpacity="0.01" />
+ <stop offset="0.503965" stopColor="#101828" stopOpacity="0.08" />
+ <stop offset="1" stopColor="white" stopOpacity="0.01" />
+ </linearGradient>
+ </defs>
+ </svg>
<svg
xmlns="http://www.w3.org/2000/svg"
width="2"
height="240"
viewBox="0 0 2 240"
fill="none"
- className={className}
+ className={cn(className, 'not-dark:hidden')}
>
<path d="M1 0L1 240" stroke="url(#paint0_linear_6295_52176)" />
<defs>
@@ -35,34 +55,7 @@ const Line = ({ className }: LineProps) => {
</linearGradient>
</defs>
</svg>
- )
- }
-
- return (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="2"
- height="241"
- viewBox="0 0 2 241"
- fill="none"
- className={className}
- >
- <path d="M1 0.5L1 240.5" stroke="url(#paint0_linear_1989_74474)" />
- <defs>
- <linearGradient
- id="paint0_linear_1989_74474"
- x1="-7.99584"
- y1="240.5"
- x2="-7.88094"
- y2="0.50004"
- gradientUnits="userSpaceOnUse"
- >
- <stop stopColor="white" stopOpacity="0.01" />
- <stop offset="0.503965" stopColor="#101828" stopOpacity="0.08" />
- <stop offset="1" stopColor="white" stopOpacity="0.01" />
- </linearGradient>
- </defs>
- </svg>
+ </>
)
}
diff --git a/web/app/components/plugins/marketplace/home/home-creator-center.tsx b/web/app/components/plugins/marketplace/home/home-creator-center.tsx
index 7dc4ef00c3e..e86773d406c 100644
--- a/web/app/components/plugins/marketplace/home/home-creator-center.tsx
+++ b/web/app/components/plugins/marketplace/home/home-creator-center.tsx
@@ -27,7 +27,7 @@ export default function HomeCreatorCenter() {
aria-label={label}
className={cn(
buttonVariants({ variant: 'ghost' }),
- 'flex items-center gap-1 px-3 py-2 text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary [html[data-theme=dark]_&]:text-text-primary [html[data-theme=dark]_&]:hover:text-text-primary',
+ 'flex items-center gap-1 px-3 py-2 text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary dark:text-text-primary dark:hover:text-text-primary',
)}
>
<span aria-hidden className="i-ri-user-star-line size-4" />
diff --git a/web/app/components/plugins/marketplace/marketplace-logo.tsx b/web/app/components/plugins/marketplace/marketplace-logo.tsx
index 92e7e3f0999..ca429de4fca 100644
--- a/web/app/components/plugins/marketplace/marketplace-logo.tsx
+++ b/web/app/components/plugins/marketplace/marketplace-logo.tsx
@@ -5,7 +5,7 @@ export function MarketplaceLogo() {
<img
alt=""
aria-hidden
- className="block h-[16.386px] w-[141.761px] max-w-none shrink-0 [html[data-theme=dark]_&]:brightness-0 [html[data-theme=dark]_&]:invert-91"
+ className="block h-[16.386px] w-[141.761px] max-w-none shrink-0 dark:brightness-0 dark:invert-91"
height="16.386"
src={`${basePath}/marketplace/dify-marketplace-logo.svg`}
width="141.761"
diff --git a/web/app/components/tools/provider/empty.tsx b/web/app/components/tools/provider/empty.tsx
index 507d81739d8..5f23f8fb3e8 100644
--- a/web/app/components/tools/provider/empty.tsx
+++ b/web/app/components/tools/provider/empty.tsx
@@ -4,7 +4,6 @@ import { RiArrowRightLine, RiArrowRightUpLine } from '@remixicon/react'
import { useTranslation } from 'react-i18next'
import { buildIntegrationPath } from '@/app/components/integrations/routes'
import { useDocLink } from '@/context/i18n'
-import { useResolvedTheme } from '@/features/theme/hooks'
import Link from '@/next/link'
import { ToolType } from '../../workflow/block-selector/types'
@@ -32,7 +31,6 @@ const getLink = (type?: ToolType) => {
const Empty = ({ type, isAgent }: Props) => {
const { t } = useTranslation(['tools'])
const docLink = useDocLink()
- const theme = useResolvedTheme()
const hasLink = type === ToolType.Custom || type === ToolType.MCP
const renderType = isAgent ? ('agent' as const) : type
@@ -110,10 +108,7 @@ const Empty = ({ type, isAgent }: Props) => {
<div className="flex flex-col items-center justify-center">
<span
aria-hidden
- className={cn(
- 'i-custom-vender-other-no-tool-placeholder h-9 w-51',
- theme === 'dark' ? 'invert' : '',
- )}
+ className="i-custom-vender-other-no-tool-placeholder h-9 w-51 dark:invert"
/>
<div className="mt-2 mb-1 text-[13px] leading-4.5 font-medium text-text-primary">
{hasTitle && renderType
diff --git a/web/app/components/workflow-app/components/workflow-header/features-trigger.tsx b/web/app/components/workflow-app/components/workflow-header/features-trigger.tsx
index 5338be71114..0355f3f88b4 100644
--- a/web/app/components/workflow-app/components/workflow-header/features-trigger.tsx
+++ b/web/app/components/workflow-app/components/workflow-header/features-trigger.tsx
@@ -7,7 +7,6 @@ import type { EndNodeType } from '@/app/components/workflow/nodes/end/types'
import type { StartNodeType } from '@/app/components/workflow/nodes/start/types'
import type { CommonEdgeType, Node } from '@/app/components/workflow/types'
import { Button } from '@langgenius/dify-ui/button'
-import { cn } from '@langgenius/dify-ui/cn'
import { useMutation, useQuery, useQueryClient, useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
import { memo, useCallback, useMemo } from 'react'
@@ -33,13 +32,11 @@ import useNodes from '@/app/components/workflow/store/workflow/use-nodes'
import { BlockEnum, InputVarType, isTriggerNode } from '@/app/components/workflow/types'
import { toast } from '@/app/notifications'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import { useResolvedTheme } from '@/features/theme/hooks'
import { consoleQuery } from '@/service/console'
import { useResetWorkflowVersionHistory } from '@/service/use-workflow'
const FeaturesTrigger = () => {
const { t } = useTranslation(['common', 'workflow'])
- const theme = useResolvedTheme()
const isChatflow = useAtomValue(isChatflowAtom)
const workflowStore = useWorkflowStore()
const queryClient = useQueryClient()
@@ -240,10 +237,7 @@ const FeaturesTrigger = () => {
{/* Feature button is only visible in chatflow mode (advanced-chat) */}
{isChatflow && (
<Button
- className={cn(
- 'rounded-lg text-components-button-secondary-text inset-ring-1 inset-ring-transparent',
- theme === 'dark' && 'bg-white/10 inset-ring-black/5 backdrop-blur-xs',
- )}
+ className="rounded-lg text-components-button-secondary-text inset-ring-1 inset-ring-transparent dark:bg-white/10 dark:inset-ring-black/5 dark:backdrop-blur-xs"
onClick={handleShowFeatures}
>
<span className="i-ri-apps-2-add-line size-4 text-components-button-secondary-text" />
diff --git a/web/app/components/workflow/header/chat-variable-button.tsx b/web/app/components/workflow/header/chat-variable-button.tsx
index 90c5f2dd8d9..3768022be7c 100644
--- a/web/app/components/workflow/header/chat-variable-button.tsx
+++ b/web/app/components/workflow/header/chat-variable-button.tsx
@@ -4,10 +4,8 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/too
import { memo } from 'react'
import { useTranslation } from 'react-i18next'
import { useStore } from '@/app/components/workflow/store'
-import { useResolvedTheme } from '@/features/theme/hooks'
const ChatVariableButton = ({ disabled }: { disabled: boolean }) => {
- const theme = useResolvedTheme()
const { t } = useTranslation(['workflow'])
const showChatVariablePanel = useStore((s) => s.showChatVariablePanel)
const setShowChatVariablePanel = useStore((s) => s.setShowChatVariablePanel)
@@ -34,9 +32,7 @@ const ChatVariableButton = ({ disabled }: { disabled: boolean }) => {
size="lg"
className={cn(
'border border-transparent',
- theme === 'dark' &&
- showChatVariablePanel &&
- 'border-black/5 bg-white/10 backdrop-blur-xs',
+ showChatVariablePanel && 'dark:border-black/5 dark:bg-white/10 dark:backdrop-blur-xs',
)}
disabled={disabled}
onClick={handleClick}
diff --git a/web/app/components/workflow/header/env-button.tsx b/web/app/components/workflow/header/env-button.tsx
index a15e43e9c4f..218cbd0eb13 100644
--- a/web/app/components/workflow/header/env-button.tsx
+++ b/web/app/components/workflow/header/env-button.tsx
@@ -5,10 +5,8 @@ import { memo } from 'react'
import { useTranslation } from 'react-i18next'
import { useInputFieldPanel } from '@/app/components/rag-pipeline/hooks/use-input-field-panel'
import { useStore } from '@/app/components/workflow/store'
-import { useResolvedTheme } from '@/features/theme/hooks'
const EnvButton = ({ disabled }: { disabled: boolean }) => {
- const theme = useResolvedTheme()
const { t } = useTranslation(['workflow'])
const setShowChatVariablePanel = useStore((s) => s.setShowChatVariablePanel)
const showEnvPanel = useStore((s) => s.showEnvPanel)
@@ -35,7 +33,7 @@ const EnvButton = ({ disabled }: { disabled: boolean }) => {
size="lg"
className={cn(
'border border-transparent',
- theme === 'dark' && showEnvPanel && 'border-black/5 bg-white/10 backdrop-blur-xs',
+ showEnvPanel && 'dark:border-black/5 dark:bg-white/10 dark:backdrop-blur-xs',
)}
variant="ghost"
disabled={disabled}
diff --git a/web/app/components/workflow/header/global-variable-button.tsx b/web/app/components/workflow/header/global-variable-button.tsx
index 07462451eeb..91af662752f 100644
--- a/web/app/components/workflow/header/global-variable-button.tsx
+++ b/web/app/components/workflow/header/global-variable-button.tsx
@@ -5,10 +5,8 @@ import { memo } from 'react'
import { useTranslation } from 'react-i18next'
import { useInputFieldPanel } from '@/app/components/rag-pipeline/hooks/use-input-field-panel'
import { useStore } from '@/app/components/workflow/store'
-import { useResolvedTheme } from '@/features/theme/hooks'
const GlobalVariableButton = ({ disabled }: { disabled: boolean }) => {
- const theme = useResolvedTheme()
const { t } = useTranslation(['workflow'])
const showGlobalVariablePanel = useStore((s) => s.showGlobalVariablePanel)
const setShowGlobalVariablePanel = useStore((s) => s.setShowGlobalVariablePanel)
@@ -35,9 +33,8 @@ const GlobalVariableButton = ({ disabled }: { disabled: boolean }) => {
size="lg"
className={cn(
'border border-transparent',
- theme === 'dark' &&
- showGlobalVariablePanel &&
- 'border-black/5 bg-white/10 backdrop-blur-xs',
+ showGlobalVariablePanel &&
+ 'dark:border-black/5 dark:bg-white/10 dark:backdrop-blur-xs',
)}
disabled={disabled}
onClick={handleClick}
diff --git a/web/app/components/workflow/header/header-in-restoring.tsx b/web/app/components/workflow/header/header-in-restoring.tsx
index 72e6dad0d7b..adf0dc8b592 100644
--- a/web/app/components/workflow/header/header-in-restoring.tsx
+++ b/web/app/components/workflow/header/header-in-restoring.tsx
@@ -1,5 +1,4 @@
import { Button } from '@langgenius/dify-ui/button'
-import { cn } from '@langgenius/dify-ui/cn'
import { RiHistoryLine } from '@remixicon/react'
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
@@ -12,7 +11,6 @@ import { getWorkflowVersionName } from '@/app/components/workflow/utils/version'
import { toast } from '@/app/notifications'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import { deploymentEditionAtom } from '@/features/system-features/state'
-import { useResolvedTheme } from '@/features/theme/hooks'
import { consoleQuery } from '@/service/console'
import {
useInvalidateAllLastRun,
@@ -30,7 +28,6 @@ export type HeaderInRestoringProps = {
}
const HeaderInRestoring = ({ onRestoreSettled }: HeaderInRestoringProps) => {
const { t } = useTranslation(['billing', 'workflow', 'workflowHistory'])
- const theme = useResolvedTheme()
const [isRestorePlanUpgradeModalOpen, setIsRestorePlanUpgradeModalOpen] = useState(false)
const deploymentEdition = useAtomValue(deploymentEditionAtom)
const { data: plan } = useQuery(
@@ -169,19 +166,13 @@ const HeaderInRestoring = ({ onRestoreSettled }: HeaderInRestoringProps) => {
onClick={handleRestore}
disabled={isPlanUnavailable || !canRestore}
variant="primary"
- className={cn(
- 'rounded-lg inset-ring-1 inset-ring-transparent',
- theme === 'dark' && 'bg-white/10 inset-ring-black/5 backdrop-blur-xs',
- )}
+ className="rounded-lg inset-ring-1 inset-ring-transparent dark:bg-white/10 dark:inset-ring-black/5 dark:backdrop-blur-xs"
>
{t(($) => $['common.restore'], { ns: 'workflow' })}
</Button>
<Button
onClick={handleCancelRestore}
- className={cn(
- 'rounded-lg text-components-button-secondary-accent-text inset-ring-1 inset-ring-transparent',
- theme === 'dark' && 'bg-white/10 inset-ring-black/5 backdrop-blur-xs',
- )}
+ className="rounded-lg text-components-button-secondary-accent-text inset-ring-1 inset-ring-transparent dark:bg-white/10 dark:inset-ring-black/5 dark:backdrop-blur-xs"
>
<div className="flex items-center gap-x-0.5">
<RiHistoryLine className="size-4" />
diff --git a/web/app/components/workflow/header/version-history-button.tsx b/web/app/components/workflow/header/version-history-button.tsx
index 8f81274c027..e0762089925 100644
--- a/web/app/components/workflow/header/version-history-button.tsx
+++ b/web/app/components/workflow/header/version-history-button.tsx
@@ -1,9 +1,7 @@
-import { cn } from '@langgenius/dify-ui/cn'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
import { useHotkey } from '@tanstack/react-hotkeys'
import { useTranslation } from 'react-i18next'
-import { useResolvedTheme } from '@/features/theme/hooks'
import { VERSION_HISTORY_HOTKEY } from '../hotkeys'
import { ShortcutKbd } from '../shortcuts/shortcut-kbd'
@@ -12,7 +10,6 @@ type VersionHistoryButtonProps = {
}
export function VersionHistoryButton({ onClick }: VersionHistoryButtonProps) {
- const theme = useResolvedTheme()
const { t } = useTranslation(['workflow'])
const label = t(($) => $['common.versionHistory'], { ns: 'workflow' })
@@ -40,10 +37,7 @@ export function VersionHistoryButton({ onClick }: VersionHistoryButtonProps) {
aria-label={label}
variant="secondary"
size="lg"
- className={cn(
- 'inset-ring-1 inset-ring-transparent',
- theme === 'dark' && 'bg-white/10 inset-ring-black/5 backdrop-blur-xs',
- )}
+ className="inset-ring-1 inset-ring-transparent dark:bg-white/10 dark:inset-ring-black/5 dark:backdrop-blur-xs"
onClick={onClick}
>
<span
diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/assets/schema-generator-dark.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/assets/schema-generator-dark.tsx
index 13b3b2911cd..c3b073a3359 100644
--- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/assets/schema-generator-dark.tsx
+++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/assets/schema-generator-dark.tsx
@@ -1,6 +1,13 @@
-const SchemaGeneratorDark = () => {
+const SchemaGeneratorDark = ({ className }: { className?: string }) => {
return (
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ fill="none"
+ className={className}
+ >
<path
d="M9.33329 2.95825C10.2308 2.95825 10.9583 2.23071 10.9583 1.33325H11.7083C11.7083 2.23071 12.4358 2.95825 13.3333 2.95825V3.70825C12.4358 3.70825 11.7083 4.43579 11.7083 5.33325H10.9583C10.9583 4.43579 10.2308 3.70825 9.33329 3.70825V2.95825ZM0.666626 7.33325C2.87577 7.33325 4.66663 5.54239 4.66663 3.33325H5.99996C5.99996 5.54239 7.79083 7.33325 9.99996 7.33325V8.66659C7.79083 8.66659 5.99996 10.4575 5.99996 12.6666H4.66663C4.66663 10.4575 2.87577 8.66659 0.666626 8.66659V7.33325ZM11.5 9.33325C11.5 10.5299 10.5299 11.4999 9.33329 11.4999V12.4999C10.5299 12.4999 11.5 13.47 11.5 14.6666H12.5C12.5 13.47 13.47 12.4999 14.6666 12.4999V11.4999C13.47 11.4999 12.5 10.5299 12.5 9.33325H11.5Z"
fill="url(#paint0_linear_13059_32065)"
diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/assets/schema-generator-light.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/assets/schema-generator-light.tsx
index 08eee41f929..468475ed9a3 100644
--- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/assets/schema-generator-light.tsx
+++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/assets/schema-generator-light.tsx
@@ -1,6 +1,13 @@
-const SchemaGeneratorLight = () => {
+const SchemaGeneratorLight = ({ className }: { className?: string }) => {
return (
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ fill="none"
+ className={className}
+ >
<path
d="M9.33329 2.95837C10.2308 2.95837 10.9583 2.23083 10.9583 1.33337H11.7083C11.7083 2.23083 12.4358 2.95837 13.3333 2.95837V3.70837C12.4358 3.70837 11.7083 4.43591 11.7083 5.33337H10.9583C10.9583 4.43591 10.2308 3.70837 9.33329 3.70837V2.95837ZM0.666626 7.33337C2.87577 7.33337 4.66663 5.54251 4.66663 3.33337H5.99996C5.99996 5.54251 7.79083 7.33337 9.99996 7.33337V8.66671C7.79083 8.66671 5.99996 10.4576 5.99996 12.6667H4.66663C4.66663 10.4576 2.87577 8.66671 0.666626 8.66671V7.33337ZM11.5 9.33337C11.5 10.53 10.5299 11.5 9.33329 11.5V12.5C10.5299 12.5 11.5 13.4701 11.5 14.6667H12.5C12.5 13.4701 13.47 12.5 14.6666 12.5V11.5C13.47 11.5 12.5 10.53 12.5 9.33337H11.5Z"
fill="url(#paint0_linear_13059_18704)"
diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/index.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/index.tsx
index 562902c42a2..5e035b82ed2 100644
--- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/index.tsx
+++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/index.tsx
@@ -11,7 +11,6 @@ import { useAutoGenModel } from '@/app/components/app/configuration/config/auto-
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
import { toast } from '@/app/notifications'
-import { useResolvedTheme } from '@/features/theme/hooks'
import { consoleQuery } from '@/service/console'
import { ModelModeType } from '@/types/app'
import { useMittContext } from '../visual-editor/context'
@@ -45,7 +44,6 @@ export function JsonSchemaGenerator({ onApply, alignOffset }: JsonSchemaGenerato
const [model, setModel] = useAutoGenModel()
const [instruction, setInstruction] = useState('')
const [schema, setSchema] = useState<SchemaRoot | null>(null)
- const theme = useResolvedTheme()
const { defaultModel } = useModelListAndDefaultModelAndCurrentProviderAndModel(
ModelTypeEnum.textGeneration,
)
@@ -63,7 +61,6 @@ export function JsonSchemaGenerator({ onApply, alignOffset }: JsonSchemaGenerato
const advancedEditing = useVisualEditorStore((state) => state.advancedEditing)
const isAddingNewField = useVisualEditorStore((state) => state.isAddingNewField)
const { emit } = useMittContext()
- const SchemaGenerator = theme === 'light' ? SchemaGeneratorLight : SchemaGeneratorDark
const handleTrigger = useCallback(
(e: React.MouseEvent<HTMLElement, MouseEvent>) => {
@@ -156,7 +153,8 @@ export function JsonSchemaGenerator({ onApply, alignOffset }: JsonSchemaGenerato
onClick={handleTrigger}
className="flex size-6 items-center justify-center rounded-md p-0.5 hover:bg-state-accent-hover data-popup-open:bg-state-accent-active data-popup-open:hover:bg-state-accent-hover"
>
- <SchemaGenerator />
+ <SchemaGeneratorLight className="dark:hidden" />
+ <SchemaGeneratorDark className="not-dark:hidden" />
</button>
}
/>
diff --git a/web/app/components/workflow/run/status-container.tsx b/web/app/components/workflow/run/status-container.tsx
index 88746c9cb18..d220cc9ecfb 100644
--- a/web/app/components/workflow/run/status-container.tsx
+++ b/web/app/components/workflow/run/status-container.tsx
@@ -2,7 +2,6 @@
import type { FC } from 'react'
import { cn } from '@langgenius/dify-ui/cn'
import { CopyFeedback } from '@/app/components/base/copy-feedback'
-import { useResolvedTheme } from '@/features/theme/hooks'
type Props = {
readonly status: string
@@ -11,7 +10,6 @@ type Props = {
}
const StatusContainer: FC<Props> = ({ status, children, copyContent }) => {
- const theme = useResolvedTheme()
const isCopyable = copyContent !== undefined
return (
@@ -23,58 +21,33 @@ const StatusContainer: FC<Props> = ({ status, children, copyContent }) => {
status === 'succeeded' &&
'border-[rgba(23,178,106,0.8)] bg-workflow-display-success-bg bg-[url(~@/app/components/workflow/run/assets/bg-line-success.svg)] text-text-success',
status === 'succeeded' &&
- theme === 'light' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(23,178,106,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)]',
- status === 'succeeded' &&
- theme === 'dark' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(23,178,106,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
+ 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(23,178,106,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)] dark:shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(23,178,106,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
status === 'partial-succeeded' &&
'border-[rgba(23,178,106,0.8)] bg-workflow-display-success-bg bg-[url(~@/app/components/workflow/run/assets/bg-line-success.svg)] text-text-success',
status === 'partial-succeeded' &&
- theme === 'light' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(23,178,106,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)]',
- status === 'partial-succeeded' &&
- theme === 'dark' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(23,178,106,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
+ 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(23,178,106,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)] dark:shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(23,178,106,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
status === 'failed' &&
'border-[rgba(240,68,56,0.8)] bg-workflow-display-error-bg bg-[url(~@/app/components/workflow/run/assets/bg-line-error.svg)] text-text-warning',
status === 'failed' &&
- theme === 'light' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(240,68,56,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)]',
- status === 'failed' &&
- theme === 'dark' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(240,68,56,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
+ 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(240,68,56,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)] dark:shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(240,68,56,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
(status === 'stopped' || status === 'paused') &&
'border-[rgba(247,144,9,0.8)] bg-workflow-display-warning-bg bg-[url(~@/app/components/workflow/run/assets/bg-line-warning.svg)] text-text-destructive',
(status === 'stopped' || status === 'paused') &&
- theme === 'light' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(247,144,9,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)]',
- (status === 'stopped' || status === 'paused') &&
- theme === 'dark' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(247,144,9,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
+ 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(247,144,9,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)] dark:shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(247,144,9,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
status === 'exception' &&
'border-[rgba(247,144,9,0.8)] bg-workflow-display-warning-bg bg-[url(~@/app/components/workflow/run/assets/bg-line-warning.svg)] text-text-destructive',
status === 'exception' &&
- theme === 'light' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(247,144,9,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)]',
- status === 'exception' &&
- theme === 'dark' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(247,144,9,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
+ 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(247,144,9,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)] dark:shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(247,144,9,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
status === 'running' &&
'border-[rgba(11,165,236,0.8)] bg-workflow-display-normal-bg bg-[url(~@/app/components/workflow/run/assets/bg-line-running.svg)] text-util-colors-blue-light-blue-light-600',
status === 'running' &&
- theme === 'light' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(11,165,236,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)]',
- status === 'running' &&
- theme === 'dark' &&
- 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(11,165,236,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
+ 'shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.5),inset_0_1px_3px_0_rgba(0,0,0,0.12),inset_0_2px_24px_0_rgba(11,165,236,0.2),0_1px_2px_0_rgba(9,9,11,0.05),0_0_0_1px_rgba(0,0,0,0.05)] dark:shadow-[inset_2px_2px_0_0_rgba(255,255,255,0.12),inset_0_1px_3px_0_rgba(0,0,0,0.4),inset_0_2px_24px_0_rgba(11,165,236,0.25),0_1px_2px_0_rgba(0,0,0,0.1),0_0_0_1px_rgba(24,24,27,0.95)]',
)}
>
<div
className={cn(
'pointer-events-none absolute inset-s-0 top-0 h-12.5 w-[65%] bg-no-repeat',
- theme === 'light' && 'bg-[url(~@/app/components/workflow/run/assets/highlight.svg)]',
- theme === 'dark' && 'bg-[url(~@/app/components/workflow/run/assets/highlight-dark.svg)]',
+ 'bg-[url(~@/app/components/workflow/run/assets/highlight.svg)] dark:bg-[url(~@/app/components/workflow/run/assets/highlight-dark.svg)]',
)}
></div>
{children}
diff --git a/web/features/app-access-error/page.tsx b/web/features/app-access-error/page.tsx
index f6d5edf7e6e..7cea4b30a4e 100644
--- a/web/features/app-access-error/page.tsx
+++ b/web/features/app-access-error/page.tsx
@@ -10,7 +10,7 @@ import { I18nextProvider, Trans, useTranslation } from 'react-i18next'
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
import { DifyLogo } from '@/app/components/base/logo/dify-logo'
import { I18nDirectionProvider } from '@/app/components/provider/i18n-direction'
-import ThemeSelector from '@/features/theme/theme-selector'
+import { ThemeSelector } from '@/features/theme/theme-selector'
import { loadI18nResource } from '@/i18n/load-resource'
import { getInitOptions } from '@/i18n/settings'
import { usePathname, useSearchParams } from '@/next/navigation'
diff --git a/web/features/theme/README.md b/web/features/theme/README.md
index 6078cbb050d..000dc9cf804 100644
--- a/web/features/theme/README.md
+++ b/web/features/theme/README.md
@@ -1,10 +1,14 @@
# Theme
-This feature owns the color theme contract. It is the only Web module that imports `next-themes`; lint rejects that import everywhere else.
+This feature owns the color theme contract and is the only Web module that imports `next-themes`.
-- `theme.ts` owns the `ThemePreference` (`light`, `dark`, `system`) and `ResolvedTheme` (`light`, `dark`) types, and the option list (value, icon, `common` label key) that every theme control renders in the same order.
-- `provider.tsx` owns the provider configuration: the `data-theme` attribute, `system` as the default preference, and the CSP nonce.
-- `hooks.ts` separates the two questions a component can ask. `useThemePreference` returns what the user chose and is for theme controls. `useResolvedTheme` returns the light or dark value in effect and is for icons, editors, charts, and Marketplace links. A Marketplace link never receives `system`.
-- `theme-selector.tsx` is the standalone icon menu for pages without the account menu.
+- `theme.ts`: the `ThemePreference` and `ResolvedTheme` types and the shared option list.
+- `provider.tsx`: the provider configuration.
+- `hooks.ts`: `useThemePreference` returns the user's choice and is for theme controls. `useResolvedTheme` returns the light or dark value in effect and is only for values that must leave CSS.
+- `theme-selector.tsx`: a standalone theme menu.
-Theme copy lives in the `common` namespace (`theme.label`, `theme.light`, `theme.dark`, `theme.system`) because console, share, auth, and Goto Anything surfaces all load it. Surface-specific descriptions stay with their surface.
+Styling follows the [Dify UI theme guide]. `useResolvedTheme` returns `light` on the server, so styling must not branch on it.
+
+Theme copy lives in the `common` namespace.
+
+[Dify UI theme guide]: ../../../packages/dify-ui/docs/styling.md#theme
diff --git a/web/features/theme/__tests__/theme-selector.spec.tsx b/web/features/theme/__tests__/theme-selector.spec.tsx
index e3aab6c5190..fb3a89dd330 100644
--- a/web/features/theme/__tests__/theme-selector.spec.tsx
+++ b/web/features/theme/__tests__/theme-selector.spec.tsx
@@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { renderToString } from 'react-dom/server'
-import ThemeSelector from '../theme-selector'
+import { ThemeSelector } from '../theme-selector'
const setTheme = vi.fn()
diff --git a/web/features/theme/provider.tsx b/web/features/theme/provider.tsx
index 1b585f1f55c..f76e04922fa 100644
--- a/web/features/theme/provider.tsx
+++ b/web/features/theme/provider.tsx
@@ -1,10 +1,8 @@
-import type { ReactNode } from 'react'
+import type { ThemeProviderProps as NextThemesProviderProps } from 'next-themes'
import type { ThemePreference } from './theme'
import { ThemeProvider as NextThemesProvider } from 'next-themes'
-type ThemeProviderProps = {
- children: ReactNode
- nonce?: string | undefined
+type ThemeProviderProps = Pick<NextThemesProviderProps, 'children' | 'nonce'> & {
defaultPreference?: ThemePreference
}
@@ -19,7 +17,7 @@ export function ThemeProvider({
defaultTheme={defaultPreference}
enableSystem
disableTransitionOnChange
- {...(nonce === undefined ? {} : { nonce })}
+ nonce={nonce}
>
{children}
</NextThemesProvider>
diff --git a/web/features/theme/theme-selector.tsx b/web/features/theme/theme-selector.tsx
index ad1fa610507..937781deac9 100644
--- a/web/features/theme/theme-selector.tsx
+++ b/web/features/theme/theme-selector.tsx
@@ -25,7 +25,7 @@ const useIsHydrated = () =>
() => false,
)
-export default function ThemeSelector() {
+export function ThemeSelector() {
const direction = useDirection()
const { t } = useTranslation(['common'])
const { preference, setPreference } = useThemePreference()
@@ -60,7 +60,7 @@ export default function ThemeSelector() {
<span className="grow px-1 system-md-regular">
{t(($) => $[option.labelKey], { ns: 'common' })}
</span>
- <MenuRadioItemIndicator data-testid={`${option.value}-icon`} />
+ <MenuRadioItemIndicator />
</MenuRadioItem>
))}
</MenuRadioGroup>