Code Monkey home page Code Monkey logo

vuetify-swatches's Introduction

Vuetify Swatches

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

demo

This is for Vuetify3. Please use 1.0.x when using with Vuetify2.

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.

LICENSE

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

vuetify-swatches's People

Contributors

logue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vuetify-swatches's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.