Skip to content

Commit

Permalink
Merge pull request #241 from abhinavkrin/theming-doc
Browse files Browse the repository at this point in the history
Adding theming.md
  • Loading branch information
abhinavkrin authored Oct 3, 2023
2 parents 1feda05 + 379e72c commit ed7e0f3
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions packages/react/docs/theming.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Theming

Hello everyone,

After setting up the project, you can explore the project's components to understand how theming is implemented.

## Using Emotion for Styling

We use [Emotion](https://emotion.sh/) for styling our components. Theming is implemented by providing a theme object that includes a `components` field.

For example:

```json
"components": {
"ChatInput": {
"styleOverrides": {
"fontWeight": 400,
"color": "gray",
"border": "1px solid black"
},
"classNames": "myCustomClassForChatInput"
},
"Message": {
"classNames": "myCustomClass"
}
}
```

In the above example:
- theme.components.ChatInput.styleOverrides would be applied to the style of the ChatInput component.
- theme.components.ChatInput.classNames would be applied to the className of the ChatInput component.

## Using the useComponentsOverrides Hook
We provide a `useComponentsOverrides` hook that returns the necessary data for component customization.

```jsx
import { useComponentOverrides } from '../../theme/useComponentOverrides';

export const MessageBody = ({
children,
className = '',
style = {},
...props
}) => {
const { styleOverrides, classNames } = useComponentOverrides(
'MessageBody',
className,
style
);

return (
<Box
css={MessageBodyCss}
className={appendClassNames('ec-message-body', classNames)}
style={styleOverrides}
{...props}
>
<p>{children}</p>
</Box>
);
};
```
## Adding Classes to Components
We also add a class to each component. For example, `ec-message-body` for the MessageBody component.

Feel free to explore and customize these components according to your project's needs.

If you have any questions or need further assistance, please don't hesitate to ask.

Happy theming!

0 comments on commit ed7e0f3

Please sign in to comment.