Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(ui): add a prompt text size preference

Josh Corbett9b8ac5be4c58
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 97e5dba88b..daffcff1ea 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -1897,7 +1897,15 @@
"label": "Connection style",
"description": "How connections between nodes are drawn."
},
+ "promptFontSize": {
+ "label": "Prompt text size",
+ "description": "Size of the text in prompt fields."
+ },
"options": {
+ "small": "Small",
+ "default": "Default",
+ "large": "Large",
+ "larger": "Larger",
"curved": "Curved",
"square": "Square",
"activeProject": "Active project",
diff --git a/invokeai/frontend/webv2/src/app/ThemeController.tsx b/invokeai/frontend/webv2/src/app/ThemeController.tsx
index 951011bd79..fa2a7764b3 100644
--- a/invokeai/frontend/webv2/src/app/ThemeController.tsx
+++ b/invokeai/frontend/webv2/src/app/ThemeController.tsx
@@ -1,5 +1,6 @@
import { shallowEqual } from '@platform/state/selectors';
import { applyThemeToRoot } from '@theme/applyTheme';
+import { applyPromptFontSizeToRoot } from '@theme/promptFontSize';
import { DEFAULT_THEME, THEMES_BY_ID } from '@theme/system';
import { useWorkbenchSettingsSelector } from '@workbench/settings/store';
import { useLayoutEffect } from 'react';
@@ -30,9 +31,10 @@ const applyRootFlag = (dataKey: 'highContrast' | 'reduceMotion', hintKey: string
};
export const ThemeController = () => {
- const { highContrast, reduceMotion, status, themeId } = useWorkbenchSettingsSelector(
+ const { highContrast, promptFontSize, reduceMotion, status, themeId } = useWorkbenchSettingsSelector(
(snapshot) => ({
highContrast: snapshot.preferences.highContrast,
+ promptFontSize: snapshot.preferences.promptFontSize,
reduceMotion: snapshot.preferences.reduceMotion,
status: snapshot.status,
themeId: snapshot.preferences.themeId,
@@ -70,5 +72,12 @@ export const ThemeController = () => {
}
}, [hasResolved, highContrast]);
+ // No pre-paint hint: prompt fields are not on screen before settings resolve.
+ useLayoutEffect(() => {
+ if (hasResolved) {
+ applyPromptFontSizeToRoot(promptFontSize);
+ }
+ }, [hasResolved, promptFontSize]);
+
return null;
};
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTextarea.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTextarea.tsx
index 74d1e4527d..450eb9a375 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTextarea.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTextarea.tsx
@@ -5,6 +5,7 @@ import { Box } from '@chakra-ui/react';
import { HighlightedPrompt, MAX_HIGHLIGHTED_PROMPT_LENGTH } from '@features/generation/ui/promptFields/PromptHighlight';
import { getLineNumberGutterCh, PromptLineNumbers } from '@features/generation/ui/promptFields/PromptLineNumbers';
import { ResizableTextarea } from '@platform/ui';
+import { PROMPT_FONT_SIZE } from '@theme/promptFontSize';
import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
const PROMPT_TEXTAREA_LINE_HEIGHT = '1.6';
// Use literal lengths; fractional Chakra spacing variables fail inside calc.
@@ -68,7 +69,7 @@ export const PromptTextarea = ({
const isWithinHighlightBudget = value.length > 0 && value.length <= MAX_HIGHLIGHTED_PROMPT_LENGTH;
// Template chunk emphasis is independent of the syntax-highlighting preference.
const shouldHighlight = (showSyntaxHighlighting || templateChunks !== null) && isWithinHighlightBudget;
- const effectiveFontSize = fontSize ?? '0.82rem';
+ const effectiveFontSize = fontSize ?? PROMPT_FONT_SIZE;
const effectiveLineHeight = lineHeight ?? PROMPT_TEXTAREA_LINE_HEIGHT;
// The gutter widens with the line count, and the text has to start clear of it.
const gutterCh = showLineNumbers ? getLineNumberGutterCh(value.split('\n').length) : 0;
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/promptFontSize.ts b/invokeai/frontend/webv2/src/platform/ui/theme/promptFontSize.ts
new file mode 100644
index 0000000000..432e807658
--- /dev/null
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/promptFontSize.ts
@@ -0,0 +1,21 @@
+/** Prompt editors' text size, chosen in Appearance; the root variable lets every prompt follow it without props. */
+export const PROMPT_FONT_SIZES = {
+ small: '0.75rem',
+ default: '0.82rem',
+ large: '0.9375rem',
+ larger: '1.0625rem',
+} as const;
+
+export type PromptFontSize = keyof typeof PROMPT_FONT_SIZES;
+
+const PROMPT_FONT_SIZE_PROPERTY = '--prompt-font-size';
+
+/** The prompt text size as a CSS value; falls back to the default before preferences load. */
+export const PROMPT_FONT_SIZE = `var(${PROMPT_FONT_SIZE_PROPERTY}, ${PROMPT_FONT_SIZES.default})`;
+
+export const isPromptFontSize = (value: unknown): value is PromptFontSize =>
+ typeof value === 'string' && Object.hasOwn(PROMPT_FONT_SIZES, value);
+
+export const applyPromptFontSizeToRoot = (size: PromptFontSize): void => {
+ document.documentElement.style.setProperty(PROMPT_FONT_SIZE_PROPERTY, PROMPT_FONT_SIZES[size]);
+};
diff --git a/invokeai/frontend/webv2/src/workbench/settings/applicationContributions.ts b/invokeai/frontend/webv2/src/workbench/settings/applicationContributions.ts
index 1b4b8b612d..76c78a0c0a 100644
--- a/invokeai/frontend/webv2/src/workbench/settings/applicationContributions.ts
+++ b/invokeai/frontend/webv2/src/workbench/settings/applicationContributions.ts
@@ -47,6 +47,20 @@ export const appearanceSettings = section('appearance', 'Appearance', [
preference('reduceMotion', 'Reduce motion', 'animation'),
preference('highContrast', 'High contrast', 'accessibility a11y readability'),
preference('showFocusRegionHighlight', 'Highlight focused regions', 'panel outline'),
+ {
+ id: 'promptFontSize',
+ label: text('promptFontSize.label', 'Prompt text size'),
+ description: text('promptFontSize.description'),
+ keywords: 'font generate prompt editor',
+ kind: 'select',
+ scope: 'preference',
+ options: [
+ { value: 'small', label: text('options.small', 'Small') },
+ { value: 'default', label: text('options.default', 'Default') },
+ { value: 'large', label: text('options.large', 'Large') },
+ { value: 'larger', label: text('options.larger', 'Larger') },
+ ],
+ },
]);
export const behaviorSettings = section('behavior', 'Behavior', [
preference('autoSwitchInvocationRoute', 'Auto-switch Invoke route'),
diff --git a/invokeai/frontend/webv2/src/workbench/settings/contracts.ts b/invokeai/frontend/webv2/src/workbench/settings/contracts.ts
index e2b0cafe7b..f99fb848a1 100644
--- a/invokeai/frontend/webv2/src/workbench/settings/contracts.ts
+++ b/invokeai/frontend/webv2/src/workbench/settings/contracts.ts
@@ -1,6 +1,7 @@
import type { WorkbenchLanguage } from '@platform/i18n/languages';
import type { LogLevel, LogNamespace } from '@platform/logging/contracts';
import type { SettingsTarget } from '@platform/ui/settings/contracts';
+import type { PromptFontSize } from '@theme/promptFontSize';
import type { WorkbenchThemeId } from '@theme/themes';
import type { ProjectSortId, ProjectsViewId } from '@workbench/launchpad/projects/projectLibraryView';
@@ -63,6 +64,8 @@ export interface WorkbenchPreferences {
preferNumericAttentionStyle: boolean;
/** Color prompt syntax in prompt fields; changes rendering only. */
showPromptSyntaxHighlighting: boolean;
+ /** Text size of the prompt fields. */
+ promptFontSize: PromptFontSize;
developerLogEnabled: boolean;
developerLogLevel: LogLevel;
developerLogNamespaces: LogNamespace[];
diff --git a/invokeai/frontend/webv2/src/workbench/settings/store.ts b/invokeai/frontend/webv2/src/workbench/settings/store.ts
index eeed16f05c..b62eabbde0 100644
--- a/invokeai/frontend/webv2/src/workbench/settings/store.ts
+++ b/invokeai/frontend/webv2/src/workbench/settings/store.ts
@@ -20,6 +20,7 @@ import {
} from '@platform/state/accountLifecycle';
import { createExternalStore } from '@platform/state/externalStore';
import { createSingleFlight } from '@platform/state/singleFlight';
+import { isPromptFontSize } from '@theme/promptFontSize';
import { DEFAULT_THEME_ID, resolveWorkbenchThemeId } from '@theme/themes';
import { deleteClientStateValue, getClientStateValue, setClientStateValue } from '@workbench/projects/api';
import { fetchSessionBlob } from '@workbench/projects/session';
@@ -62,6 +63,7 @@ export const DEFAULT_PREFERENCES: WorkbenchPreferences = {
launchpadProjectsView: 'grid',
notifyOnEnqueue: true,
preferNumericAttentionStyle: false,
+ promptFontSize: 'default',
queueJobsScope: 'all',
reduceMotion: false,
showPromptSyntaxHighlighting: true,
@@ -326,6 +328,9 @@ export const normalizeWorkbenchPreferences = (preferences?: WorkbenchPreferences
typeof preferences?.preferNumericAttentionStyle === 'boolean'
? preferences.preferNumericAttentionStyle
: DEFAULT_PREFERENCES.preferNumericAttentionStyle,
+ promptFontSize: isPromptFontSize(preferences?.promptFontSize)
+ ? preferences.promptFontSize
+ : DEFAULT_PREFERENCES.promptFontSize,
queueJobsScope:
preferences?.queueJobsScope === 'all-projects'
? 'all'