Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions docs/data/system/getting-started/the-sx-prop/PassingSxProp.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ function ListHeader({ sx = [], children }) {
width: 'auto',
textDecoration: 'underline',
},
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
...(Array.isArray(sx) ? sx : [sx]),
]}
// SxProps (typeof sx) can be an array so we use the `.flat()` array method, which inlines `sx` whether it is a single style or an array of styles.
sx,
].flat()}
>
<FormLabel sx={{ color: 'inherit' }}>{children}</FormLabel>
</ListItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ function ListHeader({ sx = [], children }: ListHeaderProps) {
width: 'auto',
textDecoration: 'underline',
},
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
...(Array.isArray(sx) ? sx : [sx]),
]}
// SxProps (typeof sx) can be an array so we use the `.flat()` array method, which inlines `sx` whether it is a single style or an array of styles.
sx,
].flat()}
>
<FormLabel sx={{ color: 'inherit' }}>{children}</FormLabel>
</ListItem>
Expand Down