Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5d76f0b
rms sx prop from TextInputWrapper and related components
mperrotti Aug 25, 2025
3356187
rms 'width', 'minWidth', 'maxWidth' from TextInputWrapper
mperrotti Aug 25, 2025
55947fe
rms 'width', 'minWidth', 'maxWidth' from component API docs
mperrotti Aug 25, 2025
cabae97
appeases Stylelint
mperrotti Aug 25, 2025
bb312d5
adds changeset
mperrotti Aug 25, 2025
5934861
Merge branch 'main' into mp/rm-sx/textinput+related
mperrotti Aug 25, 2025
231a177
forgot to add CSS file lint fixes
mperrotti Aug 25, 2025
1e677a6
Merge branch 'main' into mp/rm-sx/textinput+related
mperrotti Aug 26, 2025
5d28459
fixes broken SelectPanel styles
mperrotti Aug 26, 2025
741e430
Merge branch 'main' of github.com:primer/react into mp/rm-sx/textinpu…
mperrotti Aug 26, 2025
15248ef
rms unused VRTs
mperrotti Aug 26, 2025
d364402
Merge branch 'main' into mp/rm-sx/textinput+related
mperrotti Aug 27, 2025
b39a405
Merge branch 'main' into mp/rm-sx/textinput+related
mperrotti Sep 3, 2025
ddbfd2e
rm 'color' usage from Overlay features stories
mperrotti Sep 9, 2025
c1e2cd7
Merge branch 'main' of github.com:primer/react into mp/rm-sx/textinpu…
mperrotti Sep 9, 2025
3a22d20
rm unused class from SelectPanel CSS Module
mperrotti Sep 9, 2025
cec75cb
Merge branch 'mp/rm-sx/textinput+related' of github.com:primer/react …
mperrotti Sep 9, 2025
a496448
Merge branch 'main' of github.com:primer/react into mp/rm-sx/textinpu…
mperrotti Sep 10, 2025
5679e24
adds components to styled-react
mperrotti Sep 11, 2025
d68de93
code style cleanups
mperrotti Sep 11, 2025
e3f4e57
story styling fixes
mperrotti Sep 11, 2025
a6c13c5
Merge branch 'main' into mp/rm-sx/textinput+related
mperrotti Sep 11, 2025
792b1ef
Merge branch 'main' of github.com:primer/react into mp/rm-sx/textinpu…
mperrotti Sep 11, 2025
eb29047
fixes Breadcrumb story typescript errors
mperrotti Sep 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-dingos-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': major
---

Removes styled-system usage from TextInputWrapper and related components and Storybook stories.
36 changes: 0 additions & 36 deletions e2e/components/TextInput.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,24 +219,6 @@ test.describe('TextInput', () => {
}
})

test.describe('Dev: With Sx', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-textinput-dev--with-sx',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`TextInput.Dev.WithSx.${theme}.png`)
})
})
}
})

test.describe('Dev: With CSS', () => {
for (const theme of themes) {
test.describe(theme, () => {
Expand All @@ -254,22 +236,4 @@ test.describe('TextInput', () => {
})
}
})

test.describe('Dev: With Sx and CSS', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-textinput-dev--with-sx-and-css',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`TextInput.Dev.WithSxAndCSS.${theme}.png`)
})
})
}
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.EditableTextInput {
min-width: 120px;
max-width: 180px;
font-size: inherit;
border: var(--borderWidth-thin) dashed var(--borderColor-muted);
}

.EditableTextInput:focus {
border: var(--borderWidth-thin) solid var(--borderColor-accent-emphasis);
}
11 changes: 2 additions & 9 deletions packages/react/src/Breadcrumbs/Breadcrumbs.dev.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useState} from 'react'
import Breadcrumbs from '.'
import TextInput from '../TextInput'
import classes from './Breadcrumbs.dev.stories.module.css'

export default {
title: 'Components/Breadcrumbs/Dev',
Expand Down Expand Up @@ -146,15 +147,7 @@ export const WithEditableNameInput = () => (
<TextInput
defaultValue="Untitled Document"
size="small"
sx={{
minWidth: '120px',
maxWidth: '180px',
fontSize: 'inherit',
border: '1px dashed var(--borderColor-muted)',
'&:focus': {
border: '1px solid var(--borderColor-accent-emphasis)',
},
}}
className={classes.EditableTextInput}
aria-label="Edit document name"
/>
</Breadcrumbs.Item>
Expand Down
18 changes: 18 additions & 0 deletions packages/react/src/Overlay/Overlay.features.stories.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@
padding: var(--base-size-12);
}

.TextInputWithMargin {
margin-bottom: var(--base-size-8);
}

.IssueTitleInput {
width: 100%;
padding: var(--base-size-2) var(--base-size-8);
text-align: left;
color: var(--fgColor-default);
}

.IssueTitleInput input {
font-weight: var(--base-text-weight-semibold);
font-size: var(--text-title-size-medium);
padding-left: 0;
padding-right: 0;
}

.IssueEditorContainer {
padding: var(--base-size-24);
height: 100vh;
Expand Down
14 changes: 4 additions & 10 deletions packages/react/src/Overlay/Overlay.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ActionList,
ActionMenu,
useFocusTrap,
Textarea,
} from '..'
import {Tooltip} from '../TooltipV2'
import classes from './Overlay.features.stories.module.css'
Expand Down Expand Up @@ -386,8 +387,8 @@ export const NestedOverlays = ({role, open}: Args) => {
<Text color="fg.muted" sx={{fontSize: 1, mb: 3}}>
Create a list to organize your starred repositories.
</Text>
<TextInput placeholder="Name this list" sx={{mb: 2}} />
<TextInput as="textarea" placeholder="Write a description" rows={3} sx={{mb: 2, textarea: {p: 2}}} />
<TextInput placeholder="Name this list" className={classes.TextInputWithMargin} />
<Textarea placeholder="Write a description" rows={3} className={classes.TextInputWithMargin} />

<Button variant="primary" onClick={() => setCreateListOverlayOpen(!createListOverlayOpen)}>
Create
Expand Down Expand Up @@ -481,14 +482,7 @@ export const MemexIssueOverlay = ({role, open}: Args) => {
}
}}
ref={inputRef}
sx={{
width: '100%',
py: '2px',
px: '7px',
textAlign: 'left',
color: 'fg.default',
input: {fontWeight: 'bold', fontSize: 4, px: 0},
}}
className={classes.IssueTitleInput}
/>
) : (
<Button
Expand Down
9 changes: 5 additions & 4 deletions packages/react/src/SelectPanel/SelectPanel.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
color: var(--fgColor-muted);
}

.FilterInputWrapper {
margin: var(--base-size-8);
width: auto;
}

.Notice {
margin-top: var(--base-size-4);
margin-right: var(--base-size-8);
Expand Down Expand Up @@ -230,7 +235,3 @@
inset: 0;
background-color: var(--overlay-backdrop-bgColor);
}

.TextInput {
margin: var(--base-size-8);
}
2 changes: 1 addition & 1 deletion packages/react/src/SelectPanel/SelectPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ function Panel({

const extendedTextInputProps: Partial<TextInputProps> = useMemo(() => {
return {
className: classes.TextInput,
className: classes.FilterInputWrapper,
contrast: true,
leadingVisual: SearchIcon,
'aria-label': inputLabel,
Expand Down
18 changes: 0 additions & 18 deletions packages/react/src/TextInput/TextInput.dev.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,3 @@ export const WithCSS = () => (
</FormControl>
</form>
)

export const WithSx = () => (
<form>
<FormControl>
<FormControl.Label>Default label</FormControl.Label>
<TextInput sx={{borderColor: 'red'}} />
</FormControl>
</form>
)

export const WithSxAndCSS = () => (
<form>
<FormControl>
<FormControl.Label>Default label</FormControl.Label>
<TextInput sx={{borderColor: 'red'}} className="testCustomClassnameBorderColor" />
</FormControl>
</form>
)
23 changes: 1 addition & 22 deletions packages/react/src/TextInput/TextInput.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,27 +140,6 @@
"deprecated": true,
"description": "(Use size) Creates a smaller or larger input than the default."
},
{
"name": "width",
"type": "string | number | Array<string | number>",
"defaultValue": "",
"deprecated": true,
"description": "(Use sx prop) Set the width of the input"
},
{
"name": "maxWidth",
"type": "string | number | Array<string | number>",
"defaultValue": "",
"deprecated": true,
"description": "(Use sx prop) Set the maximum width of the input"
},
{
"name": "minWidth",
"type": "string | number | Array<string | number>",
"defaultValue": "",
"deprecated": true,
"description": "(Use sx prop) Set the minimum width of the input"
},
{
"name": "icon",
"type": "React.ComponentType",
Expand Down Expand Up @@ -228,4 +207,4 @@
}
}
]
}
}
23 changes: 1 addition & 22 deletions packages/react/src/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,7 @@ export type TextInputNonPassthroughProps = {
*/
trailingAction?: React.ReactElement<React.HTMLProps<HTMLButtonElement>>
} & Partial<
Pick<
StyledWrapperProps,
| 'block'
| 'contrast'
| 'disabled'
| 'monospace'
| 'sx'
| 'width'
| 'maxWidth'
| 'minWidth'
| 'variant'
| 'size'
| 'validationStatus'
>
Pick<StyledWrapperProps, 'block' | 'contrast' | 'disabled' | 'monospace' | 'variant' | 'size' | 'validationStatus'>
>

export type TextInputProps = Merge<React.ComponentPropsWithoutRef<'input'>, TextInputNonPassthroughProps>
Expand All @@ -75,14 +62,10 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
loaderText = 'Loading',
monospace,
validationStatus,
sx: sxProp,
size: sizeProp,
onFocus,
onBlur,
// start deprecated props
width: widthProp,
minWidth: minWidthProp,
maxWidth: maxWidthProp,
variant: variantProp,
// end deprecated props
type = 'text',
Expand Down Expand Up @@ -137,11 +120,7 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
contrast={contrast}
disabled={disabled}
monospace={monospace}
sx={sxProp}
size={sizeProp}
width={widthProp}
minWidth={minWidthProp}
maxWidth={maxWidthProp}
variant={variantProp}
hasLeadingVisual={Boolean(LeadingVisual || showLeadingLoadingIndicator)}
hasTrailingVisual={Boolean(TrailingVisual || showTrailingLoadingIndicator)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,13 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
className,
block,
disabled,
sx: sxProp,
tokens,
onTokenRemove,
tokenComponent: TokenComponent = Token,
preventTokenWrapping = false,
size = 'xlarge',
hideTokenRemoveButtons = false,
maxHeight,
width: widthProp,
minWidth: minWidthProp,
maxWidth: maxWidthProp,
validationStatus,
variant: variantProp, // deprecated. use `size` instead
visibleTokenCount,
Expand Down Expand Up @@ -262,17 +258,13 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
disabled={disabled}
hasLeadingVisual={Boolean(LeadingVisual || showLeadingLoadingIndicator)}
hasTrailingVisual={Boolean(TrailingVisual || showTrailingLoadingIndicator)}
width={widthProp}
minWidth={minWidthProp}
maxWidth={maxWidthProp}
size={inputSizeMap[size]}
validationStatus={validationStatus}
variant={variantProp} // deprecated. use `size` prop instead
onClick={focusInput}
data-token-wrapping={Boolean(preventTokenWrapping || maxHeight) || undefined}
className={clsx(className, styles.TextInputWrapper)}
style={maxHeight ? {maxHeight, ...style} : style}
sx={sxProp}
>
{IconComponent && !LeadingVisual && <IconComponent className="TextInput-icon" />}
<TextInputInnerVisualSlot
Expand Down
6 changes: 1 addition & 5 deletions packages/react/src/Textarea/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type {TextareaHTMLAttributes, ReactElement} from 'react'
import React from 'react'
import {TextInputBaseWrapper} from '../internal/components/TextInputWrapper'
import type {FormValidationStatus} from '../utils/types/FormValidationStatus'
import type {SxProp} from '../sx'
import classes from './TextArea.module.css'

export const DEFAULT_TEXTAREA_ROWS = 7
Expand Down Expand Up @@ -46,8 +45,7 @@ export type TextareaProps = {
* CSS styles to apply to the Textarea
*/
style?: React.CSSProperties
} & TextareaHTMLAttributes<HTMLTextAreaElement> &
SxProp
} & TextareaHTMLAttributes<HTMLTextAreaElement>

/**
* An accessible, native textarea component that supports validation states.
Expand All @@ -58,7 +56,6 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
{
value,
disabled,
sx: sxProp,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see usage of this in dotcom, are we planning to migrate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we would, but we're also planning to get rid of sx props in this upcoming release. Is there a plan for how to handle this? I know we have react-styled, but I don't really know what it is or how to use it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes I think react-styled is the way to go here. @joshblack would it be part of https://github.com/github/primer/issues/5422 as well to go in dotcom and replace the textarea + sx usage with react-styled instead or what's the pipeline here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, yeah. I would make sure in github-ui to update usage there first (the migration in this case is just find the places that use styled-system for these components and update the imports to pull the component from @primer/styled-react) and then merge here so that we don't have to deal with any challenges in the release.

Hope that makes sense, let me know if it'd be helpful to walk through this or do a loom or something since this is a new process 👀

required,
validationStatus,
rows = DEFAULT_TEXTAREA_ROWS,
Expand All @@ -76,7 +73,6 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
): ReactElement => {
return (
<TextInputBaseWrapper
sx={sxProp}
validationStatus={validationStatus}
disabled={disabled}
block={block}
Expand Down
Loading
Loading