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(webv2): redesign the segment control as a flat strip

joshistoastfe07eaca4fc1
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/reference-images/ReferenceImageControls.tsx b/invokeai/frontend/webv2/src/features/generation/ui/reference-images/ReferenceImageControls.tsx
index 250222ceb6..c2083850b4 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/reference-images/ReferenceImageControls.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/reference-images/ReferenceImageControls.tsx
@@ -85,7 +85,6 @@ const BEGIN_END_MARKS = [
{ label: '100%', value: 1 },
];
-const SEGMENT_CHECKED_STYLES = { color: 'accent.contrast' };
const ADVANCED_TRIGGER_HOVER_STYLES = { color: 'fg' };
const COLLAPSIBLE_INDICATOR_OPEN_STYLES = { transform: 'rotate(90deg)' };
@@ -251,15 +250,9 @@ export const IPAdapterControls = ({
<Stack gap="1">
<FieldHeader label={t('widgets.generate.mode')} />
<SegmentGroup.Root disabled={disabled} size="xs" value={mode} w="full" onValueChange={handleModeChange}>
- <SegmentGroup.Indicator bg="accent.solid" />
+ <SegmentGroup.Indicator />
{MODE_SEGMENTS.map((segment) => (
- <SegmentGroup.Item
- key={segment.value}
- flex="1"
- justifyContent="center"
- value={segment.value}
- _checked={SEGMENT_CHECKED_STYLES}
- >
+ <SegmentGroup.Item key={segment.value} flex="1" justifyContent="center" value={segment.value}>
<SegmentGroup.ItemText fontSize="2xs">{t(segment.labelKey)}</SegmentGroup.ItemText>
<SegmentGroup.ItemHiddenInput />
</SegmentGroup.Item>
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
index 39cd5f5b6c..dda370c9f0 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
@@ -121,6 +121,90 @@ export const tabsSlotRecipe = defineSlotRecipe({
} as typeof chakraSlotRecipes.tabs.variants,
});
+/**
+ * Segment control: a flat strip, not a recessed pill.
+ *
+ * Chakra's stock look — inset-shadowed `bg.muted` track, elevated white
+ * indicator, hairline dividers between every segment — is a light-UI form
+ * control, and it read as a foreign object among the workbench's flat toolbars.
+ * This version drops the track and the dividers entirely: selection is a filled
+ * `bg.emphasized` segment, exactly the fill the icon-button strips in the canvas
+ * and preview toolbars already use, so a segment control now reads as one of
+ * them rather than as a form field.
+ *
+ * Unselected segments sit at `fg.muted` and step to `fg` on hover, which is the
+ * only feedback they need — a hover fill on top of a selection fill would give
+ * the strip two competing highlights.
+ *
+ * A hairline stroke bounds the strip so it still reads as one control when
+ * nothing around it provides an edge. It is a real border rather than the
+ * `inset` box-shadow used elsewhere in this file: the indicator is a negative
+ * z-index child, so it paints over the root's own background and shadow layer
+ * and would punch a gap in an inset hairline wherever the active segment meets
+ * the edge. A border sits outside the padding box, so the indicator can never
+ * reach it. Root radius is one step above `--segment-radius` to absorb the
+ * border width, keeping the corners concentric.
+ */
+export const segmentGroupSlotRecipe = defineSlotRecipe({
+ ...chakraSlotRecipes.segmentGroup,
+ base: {
+ ...chakraSlotRecipes.segmentGroup.base,
+ root: {
+ ...chakraSlotRecipes.segmentGroup.base?.root,
+ '--segment-radius': 'radii.sm',
+ '--segment-indicator-bg': 'colors.bg.emphasized',
+ '--segment-indicator-shadow': 'none',
+ bg: 'transparent',
+ borderColor: 'border.subtle',
+ borderRadius: 'md',
+ borderWidth: '1px',
+ boxShadow: 'none',
+ },
+ item: {
+ ...chakraSlotRecipes.segmentGroup.base?.item,
+ color: 'fg.muted',
+ fontWeight: '500',
+ transitionDuration: 'faster',
+ transitionProperty: 'background, color',
+ // Stock draws a hairline between neighbouring segments. With a filled
+ // selection they only add noise, and they never line up with the
+ // indicator's rounded corners.
+ _before: { display: 'none' },
+ _checked: { color: 'fg' },
+ _hover: {
+ '&:not([data-state=checked])': { color: 'fg' },
+ },
+ // Pre-hydration fallback: without the measured indicator, the checked
+ // segment has to paint its own fill.
+ '&[data-state=checked][data-ssr]': {
+ bg: 'bg.emphasized',
+ shadow: 'none',
+ },
+ },
+ indicator: {
+ ...chakraSlotRecipes.segmentGroup.base?.indicator,
+ shadow: 'none',
+ },
+ },
+ variants: {
+ ...chakraSlotRecipes.segmentGroup.variants,
+ size: {
+ ...chakraSlotRecipes.segmentGroup.variants?.size,
+ xs: {
+ item: { ...chakraSlotRecipes.segmentGroup.variants?.size?.xs?.item, px: '2.5' },
+ },
+ sm: {
+ item: { ...chakraSlotRecipes.segmentGroup.variants?.size?.sm?.item, px: '3', textStyle: 'xs' },
+ },
+ },
+ } as unknown as typeof chakraSlotRecipes.segmentGroup.variants,
+ defaultVariants: {
+ ...chakraSlotRecipes.segmentGroup.defaultVariants,
+ // Workbench density — stock defaults to `md`.
+ size: 'xs',
+ },
+});
+
/**
* Shared interactive states for every bordered form control — text inputs,
* textareas, number inputs, select/combobox triggers, and hand-rolled trigger
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/system.ts b/invokeai/frontend/webv2/src/platform/ui/theme/system.ts
index c31c2eeddd..e602987a57 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/system.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/system.ts
@@ -8,6 +8,7 @@ import {
menuSlotRecipe,
numberInputSlotRecipe,
progressCircleSlotRecipe,
+ segmentGroupSlotRecipe,
selectSlotRecipe,
sliderSlotRecipe,
tabsSlotRecipe,
@@ -288,6 +289,7 @@ const config = defineConfig({
menu: menuSlotRecipe,
numberInput: numberInputSlotRecipe,
progressCircle: progressCircleSlotRecipe,
+ segmentGroup: segmentGroupSlotRecipe,
select: selectSlotRecipe,
slider: sliderSlotRecipe,
tabs: tabsSlotRecipe,