1.6.2 • Published 2 months ago

vuetify-swatches v1.6.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Vuetify Swatches

jsdelivr CDN NPM Downloads Open in unpkg npm version Open in Gitpod Twitter Follow

demo

⚠ This is for Vuetify3. If you are using Vuetify2, please use 1.0.x.

This project is a remake of saintplay's vue-swatches with Vuetify.

Unlike the original version, it provides a UI based on Vuetify, such as ripple effects and dark mode.

This library is positioned as a complement to Vuetify and provides a minimal UI. Use theMenu Component if you want to display a pop-up menu, and the Card component if you want to display a palette.

Usage

In this example, the selected color is assigned to selected.

<script setup lang="ts">
import { ref, type Ref } from 'vue';

import VSwatches from 'vuetify-swatches';

const selected: Ref<string> = ref('#ffffff');
</script>

<template>
  <v-swatches v-model="selected" />
</template>

<style>
@import 'vuetify-swatches/dist/style.css';
</style>

The method of specifying swatches is the same as nested-color of Vue Swatches.

If you want to make the color palette appear when you click it, combine it with VMenu.

<script setup lang="ts">
import { ref, type Ref } from 'vue';

import VSwatches from 'vuetify-swatches';

const palette: Ref<string[] | string[][]> = ref([
  [
    '#ffb7b7',
    '#ffdbb7',
    '#ffffb7',
    '#b7ffb7',
    '#b7ffff',
    '#b7b7ff',
    '#ffb7ff',
    '#ffffff',
  ],
  [
    '#ff5555',
    '#ffa555',
    '#ffff55',
    '#55ff55',
    '#55ffff',
    '#5555ff',
    '#ff55ff',
    '#aaaaaa',
  ],
  [
    '#ff0000',
    '#ff7f00',
    '#ffff00',
    '#00ff00',
    '#00ffff',
    '#0000ff',
    '#ff00ff',
    '#555555',
  ],
  [
    '#7f0000',
    '#7f4c00',
    '#7f7f00',
    '#007f00',
    '#007f7f',
    '#00007f',
    '#7f007f',
    '#000000',
  ],
]);
const selected: Ref<string> = ref('#ffffff');
</script>

<template>
  <v-menu offset-y>
    <template #activator="{ props }">
      <v-btn v-bind="props" class="mb-3" min-width="auto" :color="selected">
        <v-icon
          :color="selected"
          style="filter: invert(100%) grayscale(100%) contrast(100)"
        >
          mdi-menu-down
        </v-icon>
      </v-btn>
    </template>
    <v-swatches v-model="selected" :swatches="palette" />
  </v-menu>
</template>

<style>
@import 'vuetify-swatches/dist/style.css';
</style>

Options

Most props other than size and placement are the same as v-btn.

VariablesTypeDefaultInfo
sizestring2remSwatch Button size
iconstringmdi-checkbox-marked-circlechecked icon
icon-sizestring1remchecked icon size
disabledbooleanfalseRemoves the ability to click or target the component.
roundednumber|stringundefinedApplies a large border radius on the button.
variantstring ^1undefinedThe variant prop gives you easy access to several different button styles.
elevationnumber|stringundefined
bordernumber|stringundefined

^1 Available variants are: elevated(default), flat, tonal, outlined, text, and plain.

CDN Usage

<!-- Vue core -->
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@3.3.14/dist/vuetify.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/vuetify@3.3.14/dist/vuetify.min.js"
/>
<!-- Markdown wasm -->
<script src="https://cdn.jsdelivr.net/npm/vuetify-swatches@1.4.3/dist/index.iife.min.js"></script>
<script>
  const { createApp } = Vue;
  const { createVuetify } = Vuetify;

  const app = createApp();
  app.use(vuetify).component(VSwatches).mount('#app');
</script>

LICENSE

©2022-2024 by Logue. Licensed under the MIT License.

1.6.2

2 months ago

1.6.0

3 months ago

1.4.6

6 months ago

1.5.0

5 months ago

1.4.5

7 months ago

1.4.4

8 months ago

1.4.3

8 months ago

1.4.1

9 months ago

1.4.0

11 months ago

1.3.6

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.3.10

1 year ago

1.3.11

1 year ago

1.3.12

1 year ago

1.3.9

1 year ago

1.3.8

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

2 years ago

1.0.4

1 year ago

1.3.1

2 years ago

1.0.3

1 year ago

1.0.0

2 years ago

1.3.0

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.3.0

2 years ago

0.1.1

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.3.2

2 years ago

0.1.3

2 years ago

0.3.1

2 years ago

0.0.7

2 years ago

0.3.3

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago