diff --git a/docs/components/JsonViewerPreview.tsx b/docs/components/JsonViewerPreview.tsx index 17d04d10..9e58e27f 100644 --- a/docs/components/JsonViewerPreview.tsx +++ b/docs/components/JsonViewerPreview.tsx @@ -9,7 +9,7 @@ export const JsonViewerPreview: FC = (props) => { return ( { }, [] ) } - style={{ - paddingLeft: 16 + sx={{ + paddingLeft: 2 }} /> diff --git a/docs/pages/index.mdx b/docs/pages/index.mdx index cae5b0a6..d65e502b 100644 --- a/docs/pages/index.mdx +++ b/docs/pages/index.mdx @@ -87,6 +87,7 @@ Check the [source code](https://github.com/TexteaInc/json-viewer/blob/main/docs/ | `theme` | `"light"`
\| `"dark"`
\| `"auto"`
\| [Base16](https://github.com/chriskempson/base16) | `"light"` | Color theme. | | `className` | `string` | - | Custom class name. | | `style` | `CSSProperties` | - | Custom style. | +| `sx` | `SxProps` | - | [The `sx` prop](https://mui.com/system/getting-started/the-sx-prop/) lets you style elements inline, using values from the theme. | | `indentWidth` | `number` | 3 | Indent width for nested objects | | `keyRenderer` | `{when: (props) => boolean}` | - | Customize a key, if `keyRenderer.when` returns `true`. | | `valueTypes` | `ValueTypes` | - | Customize value types. | diff --git a/src/index.tsx b/src/index.tsx index 3fa2bde2..b9758e9d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -102,7 +102,8 @@ const JsonViewerInner: FC = (props) => { sx={{ fontFamily: 'monospace', userSelect: 'none', - contentVisibility: 'auto' + contentVisibility: 'auto', + ...props.sx }} onMouseLeave={onMouseLeave} > diff --git a/src/type.ts b/src/type.ts index 6079f849..a9453211 100644 --- a/src/type.ts +++ b/src/type.ts @@ -1,3 +1,4 @@ +import type { SxProps, Theme } from '@mui/material/styles' import type { ComponentType, CSSProperties, Dispatch, FC, SetStateAction } from 'react' import type { Colorspace } from './theme/base16' @@ -154,6 +155,7 @@ export type JsonViewerProps = { className?: string style?: CSSProperties + sx?: SxProps /** * * @default 'light'