Skip to content

Commit 45d6f69

Browse files
committed
FormGroup no longer accepts styled system props (#1562)
1 parent 6b95d53 commit 45d6f69

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

.changeset/wild-olives-talk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/components': major
3+
---
4+
5+
FormGroup no longer accepts styled-system props. Please use the `sx` prop to extend Primer component styling instead. See also https://primer.style/react/overriding-styles for information about `sx` and https://primer.style/react/system-props for context on the removal.

docs/content/FormGroup.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,19 @@ Adds styles for multiple form elements used together.
2020
</>
2121
```
2222

23-
## System props
24-
25-
<Note variant="warning">
26-
27-
System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
28-
29-
</Note>
30-
31-
FormGroup components get `COMMON` system props. FormGroup.Label components get `COMMON` and `TYPOGRAPHY` system props. Read our [System Props](/system-props) doc page for a full list of available props.
32-
3323
## Component props
3424

3525
### FormGroup
3626

37-
| Name | Type | Default | Description |
38-
| :--- | :----- | :-----: | :---------------------------------- |
39-
| as | String | `div` | Sets the HTML tag for the component |
27+
| Name | Type | Default | Description |
28+
| :--- | :---------------- | :-----: | :----------------------------------- |
29+
| as | String | `div` | Sets the HTML tag for the component |
30+
| sx | SystemStyleObject | {} | Style to be applied to the component |
4031

4132
### FormGroup.Label
4233

43-
| Name | Type | Default | Description |
44-
| :------ | :----- | :-----: | :----------------------------------------------------------------------------- |
45-
| as | String | `label` | Sets the HTML tag for the component |
46-
| htmlFor | String | | The value of `htmlFor` needs to be the same as the `id` of the input it labels |
34+
| Name | Type | Default | Description |
35+
| :------ | :---------------- | :-----: | :----------------------------------------------------------------------------- |
36+
| as | String | `label` | Sets the HTML tag for the component |
37+
| htmlFor | String | | The value of `htmlFor` needs to be the same as the `id` of the input it labels |
38+
| sx | SystemStyleObject | {} | Style to be applied to the component |

src/FormGroup.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
import styled from 'styled-components'
2-
import {COMMON, get, SystemCommonProps, SystemTypographyProps, TYPOGRAPHY} from './constants'
2+
import {get} from './constants'
33
import sx, {SxProp} from './sx'
44
import {ComponentProps} from './utils/types'
55

6-
const FormGroup = styled.div<SystemCommonProps & SxProp>`
6+
const FormGroup = styled.div<SxProp>`
77
margin: ${get('space.3')} 0;
88
font-weight: ${get('fontWeights.normal')};
9-
${COMMON};
109
${sx};
1110
`
1211

13-
const FormGroupLabel = styled.label<SystemTypographyProps & SystemCommonProps & SxProp>`
12+
const FormGroupLabel = styled.label<SxProp>`
1413
display: block;
1514
margin: 0 0 ${get('space.2')};
1615
font-size: ${get('fontSizes.1')};
1716
font-weight: ${get('fontWeights.bold')};
18-
${TYPOGRAPHY};
19-
${COMMON};
2017
${sx};
2118
`
2219

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
import FormGroup from '../FormGroup'
3+
4+
export function shouldAcceptCallWithNoProps() {
5+
return <FormGroup />
6+
}
7+
8+
export function shouldNotAcceptSystemProps() {
9+
// @ts-expect-error system props should not be accepted
10+
return <FormGroup backgroundColor="thistle" />
11+
}

0 commit comments

Comments
 (0)