Rate

Install

import React from 'react';
import { Rate } from 'vant-react';

Usage

Basic Usage

<Rate currentRate={4} />

Custom Icon

<Rate currentRate={4} icon='like' voidIcon='like-o' />

Custom Color

<Rate currentRate={4} icon='like' voidIcon='like-o' color='#1989fa' />

Custom Count

<Rate
      count={10}
      currentRate={4}
      icon='like'
      voidIcon='like-o'
      color='#1989fa'
/>

Disabled

<Rate
      disabled
      currentRate={4}
      icon='like'
      voidIcon='like-o'
      color='#1989fa'
/>

Read Only

<Rate
      readonly
      currentRate={4}
      icon='like'
      voidIcon='like-o'
      color='#1989fa'
/>

Custom Gutter

<Rate
      gutter='8px'
      currentRate={4}
      icon='like'
      voidIcon='like-o'
      color='#1989fa'
/>

Listen On Change

const [currentRate, setRate] = useState(4);

<h1>{currentRate}</h1>
      
<Rate
        change={(rate) => setRate(rate)}
        currentRate={currentRate}
        icon='like'
        voidIcon='like-o'
        color='#1989fa'
/>

API

Props

Event

Last updated