Is there an easy way to customize component?
See original GitHub issueWhat problem does this feature solve?
In our project we want to customize button component, such as changing its height. I just saw the V1 theming API but it needs much code.
What does the proposed API look like?
Can we have the way to customize a component like below so we can customize a component with less code:
import theme from '@chakra-ui/theme';
const customTheme = theme.customizeComponent('Button', {
sizes: {
md: {
height: '38px',
}
}
})
export default customTheme;
Thanks in advance.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Strategies for building customizable components - MUI
This article reviews several different approaches that a developer might take to customize UI components, as well as the various tradeoffs ...
Read more >How To Customize React Components with Props
In this tutorial, you'll create custom components by passing props to your component. Props are arguments that you provide to a JSX element....
Read more >How to customize your third party React components
We talked about three ways to customize your third party React components. Overwriting CSS; Using Wrapper Component; Modifying the source code.
Read more >Building highly customizable React components - Medium
1. Define boundaries · 2. Simple use case first approach · 3. Basic customization · 4. Renderers and Components · 5. Custom props...
Read more >The Easiest Way to Style your Material-UI Components
However, if we change the default color theme, this will change the color of all of the buttons. If we want to customize...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I keep coming back to this topic because it is definitely frustrating to have to spread so deeply to add basic modifications, but so far I haven’t come up with anything that isn’t more clear than using
deepmerge
.Here’s an example: https://codesandbox.io/s/quizzical-bogdan-vh593?file=/src/App.tsx
You can make whatever modifications you want to the entire theme by passing an object that is deeply merged with the theme.
imo off the top of my head there are a few wins we can gain from making our own API for this though (or wrapping
deepmerge
with our own typed function(s) at least):Just thinking out loud a little bit here, definitely not sure what the best way to proceed is! But
deepmerge
allows you to achieve a degree of simplicity immediately if you want it.Your solution would work, but you’d pollute your autocomplete with a second
Button
and couldn’t just import from chakra directly. And if you rename it, you’d need everyone working on the project to know what yourCustomButton
orThemedButton
is called and I bet someone still imports from Chakra directly.Besides, this would only work for components itself I’m afraid. You couldn’t customize e.g. breakpoints there.