Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

vuetify-swatches

logue332MIT1.7.8TypeScript support: included

Color Swatch component for Vuetify3.

vuejs, vue, vue-components, color-picker, color-palette, swatches, vue3, vue-plugin, vue-resource, vuetify, vuetify3, vuetify-components

readme

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.

Variables Type Default Info
size string 2rem Swatch Button size
icon string mdi-checkbox-marked-circle checked icon
icon-size string 1rem checked icon size
disabled boolean false Removes the ability to click or target the component.
rounded number|string undefined Applies a large border radius on the button.
variant string [^1] undefined The variant prop gives you easy access to several different button styles.
elevation number|string undefined
border number|string undefined

[^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-2025 by Logue. Licensed under the MIT License.

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

1.7.5

1.7.4

23 November 2024

1.3.9

23 March 2023

  • The value is now saved in the value attribute along with the bug of v-btn of vuetify being fixed. 1769d21
  • Add CHANGELOG.md a39f81a
  • Add workflows. 31e71f5

1.3.8

10 March 2023

  • Update vue and vuetify. 38c5fd5
  • Changed implementation to generate *.d.ts with vite-plugin-dts. 54ac56c

1.3.6

4 February 2023

1.3.2

28 October 2022

1.0.8

10 March 2023

  • Changed implementation to generate *.d.ts with vite-plugin-dts. d67859d

1.0.7

15 February 2023

1.0.6

4 February 2023

1.0.3

8 November 2022

1.0.0

14 September 2022

  • Compatible to Vue 2.7.0 and Vuetify 2.6.7. 8e5bcb6
  • Update vuetify and yarn. f59a516
  • Inherit v-btn design settings. f044e29

0.3.3

18 August 2022

0.3.2

11 August 2022

0.3.1

2 August 2022

0.1.3

11 August 2022

0.1.1

2 August 2022

  • Update dependencies. e0fab7f
  • The checked color icon is easier to see. 01e1e89
  • Changed the implementation to use the value of props directly as a parameter. efcbef7

0.0.10

6 July 2022

  • Compatible to Vue 2.7.0 and Vuetify 2.6.7. 8e5bcb6
  • Fixed style.css path. a7a234e
  • Fixed an issue that failed to build the demo page. b125e52

0.0.8

28 May 2022

  • Update dependencies. 2e8a6fc
  • Fixed a bug that unnecessary settings are included in package.json and the build does not pass depending on the environment when using the library. cb98ae4

0.0.7

21 May 2022

0.0.6

20 May 2022

  • Fixed not conforming to vue / no-v-text. b412158

0.0.5

26 April 2022

  • Fixed a typo in the file name of the export destination of package.json. 8e22354

0.0.4

26 April 2022

  • Rewrite with composition api ba5dcd6
  • Fixed a bug that pre-built files do not work properly fd3e1b6
  • Update dependencies. 90a13ad

0.0.2

31 March 2022

0.0.1

17 March 2022