GithubHelp home page GithubHelp logo

Comments (4)

segunadebayo avatar segunadebayo commented on May 4, 2024 1

Hi @kripod,

Thanks for this observation. The children prop of Radio or Checkbox is optional. If you need to gain control over the styling of the labels, ignore it and compose the component this way.

<Flex as="label">
  <Radio key={choice} value={choice} color="green" />
  <Box ml={2} color="red.500">{choice}</Box>
</Flex>

Note that applying the color prop for primitives other than Radio or Checkbox should be accessed with the dot notation. The Box you have should have a prop of red.X, where X is 50-900.

I've noted your feedback on the color though. I'll test it out.

Thanks again.

from chakra-ui.

kripod avatar kripod commented on May 4, 2024 1

I appreciate your detailed feedback. However, the outlined approach comes with a lot of boilerplate and might be hard to remember or reason about, especially for beginners. I would still suggest using a separate iconColor prop, which could be modified on its own, especially with #49 taken into consideration:

<Radio
  value="foo"
  color="red"
  iconColor="black"
  _checked={{ iconColor: 'green' }}
>
  This piece of text should be red, but the icon should be
  black by default or green when hovered
</Radio>

from chakra-ui.

segunadebayo avatar segunadebayo commented on May 4, 2024 1

I completely understand your perspective @kripod . Thanks for the feedback, I'll try it out.

from chakra-ui.

segunadebayo avatar segunadebayo commented on May 4, 2024 1

Hi @kripod ,

I'm closing to this issue because there are other ways to solve this.

Option 1 (recommended)

const choice = 'Answer to a quiz question';

  <Radio key={choice} value={choice} color="green">
    <Box color="red.500">{choice}</Box>
  </Radio>

Option 2

<Flex as="label">
  <Radio key={choice} value={choice} color="green" />
  <Box ml={2} color="red.500">{choice}</Box>
</Flex>

We've looked into this suggestion:

<Radio
  value="foo"
  color="red"
  iconColor="black"
  _checked={{ iconColor: 'green' }}
>
  This piece of text should be red, but the icon should be
  black by default or green when hovered
</Radio>

We think might not be possible at the moment because the iconColor isn't a style prop and there's more we need to do to support that.

Kindly use the suggested options above.

Thanks again.

from chakra-ui.

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.