Coder Social home page Coder Social logo

Comments (4)

syntacticsugar avatar syntacticsugar commented on May 30, 2024 1

I'll look into all this over the next few days, and get back with my updates, thank you!

from material-ui-chip-input.

saschb2b avatar saschb2b commented on May 30, 2024

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:

from material-ui-chip-input.

Sharlaan avatar Sharlaan commented on May 30, 2024

Additional infos that might of some interest :

<ChipInput
  name='Compétences'
  openOnFocus
  inputStyle={{ border: '1px solid green' }}
  textFieldStyle={{ border: '1px solid red' }}
/>

additionalinfos
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.

leMaik avatar leMaik commented on May 30, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.