Search code examples
antdant-design-pro

How can I change ant design progress bar color according to value?


I want to give 'yellow' color until 50%, after 50% it will display 'green'.

It is not like strokeColor feature. I want to see yellow or green. Not together.

Is it possible to handle it (preferred without css)?

import { Progress } from 'antd';
<Progress 
  percent={this.state.progress}
/>

Solution

  • use strokeColor props:

    <Progress 
      percent={this.state.progress}
      strokeColor={this.state.progress < 50 ? "yellow" : "green"}
    />
    

    check it there: https://codesandbox.io/s/dynamic-ant-design-demo-icli2