Comments (4)
I'll look into all this over the next few days, and get back with my updates, thank you!
from material-ui-chip-input.
The best option would be to support multiple styles via prop. The current styles prop only supports to override the root element.
We could introduce more style props like:
- style = root (the whole component. Already exists)
- inputStyle = style of the input (for example to make the font bigger)
- chipStyle = style of the chip (for example colored background)
This is also the way material-ui handles further styling.
Are there any more styling needs you want to achieve?
For further details see the style props for used components:
- Chips http://www.material-ui.com/#/components/chip
- Auto-Complete http://www.material-ui.com/#/components/auto-complete
from material-ui-chip-input.
Additional infos that might of some interest :
<ChipInput
name='Compétences'
openOnFocus
inputStyle={{ border: '1px solid green' }}
textFieldStyle={{ border: '1px solid red' }}
/>
Somehow the border-color green gets overriden
Explanations:
ChipInput is based on MaterialUI's AutoComplete, which is itself composed of components TextField and Popover.
TextField exposes its inputStyle property to its parent (AutoComplete here).
textFieldStyle property comes from ChipInput to access styling the underlying TextField (but not the inner input element).
You can also find the default styles used by ChipInput author in the code source here.
As for inline styling CSS-in-JS, the 2 i've read the most about are Aphrodite and JSS.
Material-UI is based on JSS.
From my understanding, the main differences between the 2 is that JSS is more flexible than Aphrodite because it ignores IE9 limitation of 4k style sheets max. So if your product might get more than this limitation, go for Aphrodite, otherwise JSS all the way.
Hope it helps.
from material-ui-chip-input.
@syntacticsugar @saschb2b I wanted to at first, but then I didn't implement a chipStyle
property. It is even more flexible by allowing to specify a chipRenderer
.
A function of the type ({ value, isFocused, isDisabled, handleClick, handleRequestDelete }, key) => node that returns a chip based on the given properties. This can be used to customize chip styles.
Example (from the stories):
<ChipInput
defaultValue={['foo', 'bar']}
fullWidth
chipRenderer={({ value, isFocused, isDisabled, handleClick, handleRequestDelete }, key) => (
<Chip
key={key}
style={{ margin: '8px 8px 0 0', float: 'left', pointerEvents: isDisabled ? 'none' : undefined }}
backgroundColor={isFocused ? green800 : green300}
onTouchTap={handleClick}
onRequestDelete={handleRequestDelete}
>
<Avatar size={32}>{value[0].toUpperCase()}</Avatar>
{value}
</Chip>
)}
/>
You can use this to create any chip style you want, e.g. chips with avatars. And when #9 is done, it's even more powerful. :)
from material-ui-chip-input.
Related Issues (20)
- On Android Mobile: newChipKeys not working HOT 1
- dataSource is not working HOT 1
- Update storybook examples
- How to add date/datetime values as chips?
- Can I add icon to input field like in TextField by using Input Adornments?
- Label positioning on "outlined" variant is incorrect.
- Dependency version mismatch error: Unable to install this module HOT 12
- Dependency error with material-ui/core v5 HOT 3
- Make chips editable in the same place HOT 1
- "future" compatibility issue HOT 1
- Module not found HOT 1
- Make ChipInput a required field in a form HOT 1
- Chip note adding using space bar HOT 1
- MUI v5 HOT 1
- Please add React 17 support HOT 7
- Is there a way to change OnBlur so that focusing and then clicking on a chip doesn't trigger it?
- Submit button not working after update the Android system WebView in android device.
- Performance issue with pasting 100+ items in chip input. Cannot add more chips and DOM freezes
- Should ChipInput component be wrapped by Form tag ?
- unable to install in react 18v HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-ui-chip-input.