Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="app">
  <h1>Vue Star Rating for Vue 3.x</h1>
                
  <h2>Default</h2>
  <star-rating></star-rating>

  <h2>Half Stars</h2>
  <star-rating :increment="0.5"></star-rating>

  <h2>Red Stars</h2>
  <star-rating active-color="#9c0000"></star-rating>

  <h2>Vibrant Stars</h2>
  <star-rating inactive-color="#e1bad9" active-color="#cc1166"></star-rating>

  <h2>Small Stars</h2>
  <star-rating :star-size="20"></star-rating>

  <h2>Big Stars</h2>
  <star-rating :star-size="90"></star-rating>

  <h2>Bordered Stars</h2>
  <star-rating :border-width="5"></star-rating>

  <h2>Fluid Stars</h2>
  <star-rating :increment="0.01"></star-rating>

  <h2>Preset Stars</h2>
  <star-rating :rating="4"></star-rating>

  <h2>Non rounded start rating</h2>
  <star-rating :rating="4.67" :round-start-rating="false"></star-rating>

  <h2>Read Only Stars</h2>
  <star-rating :rating="3.8" :read-only="true" :increment="0.01"></star-rating>

  <h2>Lots of stars</h2>
  <star-rating :max-rating="10" :star-size="20"></star-rating>

  <h2>Right To Left</h2>
  <star-rating :rtl="true" :increment="0.01"></star-rating>

  <h2>Style Rating</h2>
  <star-rating text-class="custom-text"></star-rating>

  <h2>Hide Rating</h2>
  <star-rating :show-rating="false"></star-rating>

  <h2>Capture Rating</h2>
  <star-rating :show-rating="false" @update:rating="rating = $event"></star-rating>
  <div style="margin-top:10px;font-weight:bold;">{{currentRatingText}}</div>

  <h2>Capture Mouse Over Rating</h2>
  <div @mouseleave="mouseOverRating = null" style="display:inline-block;">
    <star-rating :show-rating="false" @hover:rating="mouseOverRating = $event" :increment="0.5"></star-rating>
  </div>
  <div style="margin-top:10px;font-weight:bold;">{{mouseOverRatingText}}</div>

  <h2>Resetable stars with v-model</h2>
  <div style="display:inline-block;">
    <star-rating v-model:rating="resetableRating"></star-rating>
    <div style="padding-top:10px;cursor:pointer;margin-bottom:20px;color: blue;"><a @click="resetableRating = 0;">Reset
        Rating</a></div>
  </div>

  <h2>Inline Stars</h2>
  <div style="display:inline-block;">
    Rated
    <star-rating :inline="true" :star-size="20" :read-only="true" :show-rating="false" :rating="5"></star-rating>
    by our customers.

  </div>

  <h2>Rounded Corners</h2>
  <star-rating :rounded-corners="true" :border-width="6"></star-rating>

  <h2>Custom Stars</h2>

  <star-rating :star-size="50" :rounded-corners="true" :border-width="4" :star-points="[23,2, 14,17, 0,19, 10,34, 7,50, 23,43, 38,50, 36,34, 46,19, 31,17]"></star-rating>

    <h2>Animated Stars</h2>
  <star-rating :animate="true" :active-color="['#ae0000','#003333']" :active-border-color="['#F6546A','#a8c3c0']" :border-width="4" :star-points="[23,2, 14,17, 0,19, 10,34, 7,50, 23,43, 38,50, 36,34, 46,19, 31,17]" :active-on-click="true" :clearable="true" :padding="3"></star-rating>
  
  <h2>Glowing Stars</h2>
  <div style="background:#000;overflow:auto;padding:10px;padding-bottom:20px;">
    <star-rating :star-size="70" :glow="10" glow-color="#ffd055"></star-rating>
  </div>

</div>
              
            
!

CSS

              
                body {
  font-family: 'Raleway', sans-serif;
}

.custom-text {
  font-weight: bold;
  font-size: 1.9em;
  border: 1px solid #cfcfcf;
  padding-left: 10px;
  padding-right: 10px;
  border-radius: 5px;
  color: #999;
  background: #fff;
}

              
            
!

JS

              
                const app = Vue.createApp({
  methods: {
    showCurrentRating(rating) {
      this.currentSelectedRating =
        rating === 0
          ? this.currentSelectedRating
          : "Click to select " + rating + " stars";
    },
    setCurrentSelectedRating(rating) {
      this.currentSelectedRating = "You have Selected: " + rating + " stars";
    }
  },
  computed: {
    currentRatingText() {
      return this.rating
        ? "You have selected " + this.rating + " stars"
        : "No rating selected";
    },
    mouseOverRatingText() {
      return this.mouseOverRating
        ? "Click to select " + this.mouseOverRating + " stars"
        : "No Rating";
    }
  },
  data() {
    return {
      rating: null,
      resetableRating: 2,
      currentRating: "No Rating",
      mouseOverRating: null
    };
  }
});
app.component("star-rating", VueStarRating.default);

app.mount("#app");

              
            
!
999px

Console