Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to add margin between stars? #66

Open
Lucascoorek opened this issue Jan 13, 2020 · 1 comment
Open

Is it possible to add margin between stars? #66

Lucascoorek opened this issue Jan 13, 2020 · 1 comment

Comments

@Lucascoorek
Copy link

Can't find a way to style individual stars e.g. adding margin or padding.

@reginapizza
Copy link

reginapizza commented May 17, 2020

Yes, I've found two ways to do this.

1.) This one will work if the component is not being used anywhere else or if the style will be the same throughout your project (ie. you will never require more than one margin size):

Use the css class it already has to target the margin

.dv-star-rating-star {
  margin: 0rem !important;
  padding: 0rem !important;
}

2.) This method works if your component is customized but NOT editable (I have not been able to make it work if you require it to be editable):

I used renderStarIcon to make the icon an image and then gave that image a class, then added margins to that class.

React Component:

           <StarRatingComponent
                value={this.state.rating}
                onStarClick= {(val) => this.setState({ rating: val })}
                emptyStarColor="#FFF"
                starColor="#FFCC47"
                renderStarIcon={() => <img src="star-icon.svg" className="review-star" alt="star"/>}
            />

CSS:

.review-star {
  height: 32px;
  width: 32px;
  margin: 8px;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants