Skip to content

Commit 62a0daf

Browse files
docs: explain theme customization more
1 parent 754abe1 commit 62a0daf

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/components/ThemeProvider/ThemeProvider.stories.tsx

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,44 @@ type Story = StoryObj<typeof ThemeProvider>
5151
*
5252
* In general, most useful theme properties are exposed on `theme.custom`. (Root
5353
* `theme` properties are used internally by MUI.) See typescript definitions
54-
* for more information.
54+
* for more information about `theme.custom`.
55+
*
56+
* ## Further Customized Theme with `createTheme`
57+
* Consuming applications can customize `smoot-design`'s default theme by creating
58+
* a theme instance with `createTheme` and passing it to `ThemeProvider`:
59+
*
60+
* ```tsx
61+
* const customTheme = createTheme({...})
62+
*
63+
* <ThemeProvider theme={customTheme}>
64+
* {children}
65+
* </ThemeProvider>
66+
* ```
67+
*
5568
*
5669
* ### Custom Link Adapter
5770
* One particularly notable property is `theme.custom.LinkAdapter`. Some `smoot-design`
5871
* components render links. These links are native anchor tags by default. In
5972
* order to use these components with custom routing libraries (e.g. `react-router`
60-
* or `next/link`), you can provide a custom link adapter. Link components wills
73+
* or `next/link`), you can provide a custom link adapter.
6174
*
62-
* As an example, `ButtonLink` will:
75+
* Components such as `ButtonLink` will:
6376
* - use `Component` on `ButtonLink` if specified (`<ButtonLink Component={Link} />`)
6477
* - else, use `theme.custom.LinkAdapter` if specified,
6578
* - else, use `a` tag.
6679
*
67-
* If you provide a custom `LinkAdapter` and need **aditional** props, you can
68-
* use [module augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation) to add the custom props to relevant
69-
* components. For example, if using `next/link`
80+
* For example, to use `next/link` as the default link implementation:
81+
*
82+
* ```tsx
83+
* import Link from "next/link"
84+
* const theme = createTheme({ LinkAdapter: Link })
7085
* ```
86+
*
87+
* You can use [module augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation)
88+
* to add the custom props to relevant components. For example, to expose
89+
* `next/link`'s `scroll` prop on `ButtonLink`:
90+
*
91+
* ```ts
7192
* // Add scroll prop to all components using LinkAdapter
7293
* declare module "@mitodl/smoot-design" {
7394
* interface LinkAdapterPropsOverrides {

0 commit comments

Comments
 (0)