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): give SegmentedControl the layers panes' pill variant

Josh Corbett37dc179ee445
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryViewTabs.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryViewTabs.tsx
index 894806e4e5..b2274f3fb7 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryViewTabs.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryViewTabs.tsx
@@ -61,6 +61,7 @@ export const GalleryViewTabs = () => {
isFullWidth={false}
options={options}
value={gallery.galleryView}
+ variant="pill"
onChange={handleViewChange}
/>
);
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.tsx
index bd512c04f5..6e994c5e77 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.tsx
@@ -114,6 +114,7 @@ export const DynamicPromptsButton = ({
isFullWidth={false}
options={tabItems}
value={tab}
+ variant="pill"
onChange={handleTabChange}
/>
{tab === 'preview' ? (
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.tsx
index 1f701b884a..abeb6ebf49 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.tsx
@@ -224,7 +224,13 @@ export const GraphPreviewDialog = ({
{subtitle}
</Text>
</Stack>
- <SegmentedControl isFullWidth={false} options={modeOptions} value={mode} onChange={handleModeChange} />
+ <SegmentedControl
+ isFullWidth={false}
+ options={modeOptions}
+ value={mode}
+ variant="pill"
+ onChange={handleModeChange}
+ />
</Dialog.Header>
<Dialog.Body display="flex" flex="1" flexDirection="column" gap="3" minH="0">
{hasInvalidReasons ? (
diff --git a/invokeai/frontend/webv2/src/platform/ui/SegmentedControl.tsx b/invokeai/frontend/webv2/src/platform/ui/SegmentedControl.tsx
index 5815a05978..7647bf2031 100644
--- a/invokeai/frontend/webv2/src/platform/ui/SegmentedControl.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/SegmentedControl.tsx
@@ -5,7 +5,20 @@ import { useCallback } from 'react';
// Axe measures the checked label against the item's own background, not the
// moving indicator sibling painted behind it, so the item carries the fill too.
-const CHECKED_ITEM_STYLES = { bg: 'accent.solid', color: 'accent.contrast' } as const;
+const ACCENT_CHECKED_ITEM_STYLES = { bg: 'accent.solid', color: 'accent.contrast' } as const;
+const PILL_CHECKED_ITEM_STYLES = { bg: 'bg.emphasized', color: 'fg' } as const;
+
+// The layers panes' pill look: borderless track, neutral emphasized fill.
+const PILL_ROOT_CSS = {
+ '--segment-indicator-bg': 'colors.bg.emphasized',
+ '--segment-radius': 'radii.md',
+ borderWidth: '0',
+} as const;
+// A translucent hover so it reads on panel and popover surfaces alike.
+const PILL_ITEM_CSS = {
+ fontWeight: '600',
+ _hover: { '&:not([data-state=checked])': { bg: 'bg.emphasized/50' } },
+} as const;
export interface SegmentedControlOption {
disabled?: boolean;
@@ -21,6 +34,8 @@ export interface SegmentedControlProps extends Omit<SegmentGroup.RootProps, 'onC
onChange: (value: string) => void;
options: readonly SegmentedControlOption[];
value: string | null;
+ /** `accent`: bordered track with the accent fill. `pill`: the layers panes' neutral pill tabs. */
+ variant?: 'accent' | 'pill';
}
/** The house segmented control: an `xs` group of equal centered segments with `2xs` labels. */
@@ -31,6 +46,7 @@ export const SegmentedControl = ({
onChange,
options,
value,
+ variant = 'accent',
...rest
}: SegmentedControlProps) => {
const handleValueChange = useCallback(
@@ -42,9 +58,12 @@ export const SegmentedControl = ({
[onChange]
);
+ const isPill = variant === 'pill';
+
return (
<SegmentGroup.Root
aria-label={ariaLabel}
+ css={isPill ? PILL_ROOT_CSS : undefined}
disabled={disabled}
size="xs"
value={value}
@@ -56,15 +75,16 @@ export const SegmentedControl = ({
{options.map((option) => (
<SegmentGroup.Item
key={option.value}
+ css={isPill ? PILL_ITEM_CSS : undefined}
disabled={option.disabled}
flex={isFullWidth ? '1' : undefined}
justifyContent={isFullWidth ? 'center' : undefined}
minW={isFullWidth ? '0' : undefined}
value={option.value}
- _checked={CHECKED_ITEM_STYLES}
+ _checked={isPill ? PILL_CHECKED_ITEM_STYLES : ACCENT_CHECKED_ITEM_STYLES}
>
<SegmentGroup.ItemHiddenInput />
- <SegmentGroup.ItemText fontSize="2xs">{option.label}</SegmentGroup.ItemText>
+ <SegmentGroup.ItemText fontSize={isPill ? 'xs' : '2xs'}>{option.label}</SegmentGroup.ItemText>
</SegmentGroup.Item>
))}
</SegmentGroup.Root>