|
| 1 | + |
1 | 2 | --- |
2 | 3 | id: design-system |
3 | 4 | title: Design System Integration |
4 | 5 | sidebar_label: Design System Integration |
5 | 6 | --- |
6 | 7 |
|
7 | 8 | ## Introduction |
8 | | -A consistent design system is integrated to the all of the app types by using `styled-components` and `theme.js` file generated by [Theme Manager](http://theme-manager.com). |
9 | | - |
10 | | -`styled-component` is one of the most common ways to style components in the react ecosystem. It allows users to write styles in css within the js files. |
| 9 | +A consistent design system is integrated to the all of the app types by using `nextui` and `theme.js` file which can be generated by using the structure defined by [nextui create theme](https://nextui.org/docs/theme/typescript#create-theme) docs and using nextui `createTheme` method. |
11 | 10 |
|
12 | | -[Theme Manager](http://theme-manager.com) allows users to curate design tokens such as colors, space, border-radius, etc and then export them in a json object which then can be consumed within our apps. |
| 11 | +`nextui` is a library that uses stitches internally to style components in the react ecosystem. It allows users to write styles in css within the js files. It also has components and provides customized theming. To know more about nextui visit [nextui org](https://nextui.org/docs/guide/getting-started) docs. |
13 | 12 |
|
14 | | -`styled-components` provides `<ThemeProvider>` component which accepts a `theme` prop (json). The `<ThemeProvider>` is kept at the highest level in the component chain. This allows all of the components within it to inherit the `theme` prop. In case of our Next.js app the `<ThemeProvider>` is added in `src/pages/_app.js`. |
| 13 | +`nextui` provides `<NextUIProvider>` which is a theme provider component which accepts a `theme` prop (created using createTheme nextui method and json) which overrides the nextui default theme. The `<NextUIProvider>` is kept at the highest level in the component chain. This allows all of the components within it to inherit the `theme` prop. In case of our Next.js app the `<NextUIProvider>` is added in `src/pages/_app.js`. |
15 | 14 |
|
16 | 15 | ## How to use |
17 | | -1. Create a theme using [Theme Manager](http://theme-manager.com). Download the theme and store it as `src/themes/theme.js`. |
18 | | -2. Now in all `styled-component`, theme prop is available to use as following: |
| 16 | +1. Create a theme using the structure defined by [nextui create theme](https://nextui.org/docs/theme/typescript#create-theme) and store it as `src/themes/theme.js`. |
| 17 | +2. Now in all `nextui` styled components, theme prop is available to use as following: |
19 | 18 | ```jsx |
20 | | -export const Button = styled.button` |
21 | | - color: ${props => props.theme.colors.white[0]}; |
22 | | - font-size: 1em; |
23 | | - margin: 1em; |
24 | | - padding: 0.25em 1em; |
25 | | - border: 2px solid ${props => props.theme.colors.black[0]}; |
26 | | - background-color: ${props => props.theme.colors.black[0]}; |
27 | | - border-radius: 3px; |
28 | | - display: block; |
29 | | -`; |
| 19 | +export const Button = styled('button', { |
| 20 | + fontSize: '$3', |
| 21 | + color: '$fontColor', |
| 22 | + margin: '1em', |
| 23 | + padding: '0.25em 1em', |
| 24 | + border: '2px solid black', |
| 25 | + borderRadius: '$1', |
| 26 | + display: 'block', |
| 27 | + length: '1' // this property is added temporarily for the issue of nextui styled method with typescript v4.6.2. Will not be required once the issue is resolved. |
| 28 | +}); |
30 | 29 | ``` |
31 | 30 |
|
32 | | -More about theming can be found in [styled-components](https://styled-components.com/docs/advanced#theming) docs. |
| 31 | +More about cutomizing theming can be found in [nextui customize theme](https://nextui.org/docs/theme/customize-theme) docs. |
0 commit comments