npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svelte-radio-checkbox-z

v1.0.2

Published

Svelte UI Check/Radio [RadioGroup, Checkbox(s)]. Custom (test-svelte)

Downloads

14

Readme


You can customize icon, theme or color for Checkbox/Radio

Vue /React/ Svelte


Usage

Install the package

npm install --save svelte-radio-checkbox-z

Import the module in the place you want to use:

import RadioCheckBox from "svelte-radio-checkbox-z";

Snippet

    // js
    // let selected = ['Radio', ...]  // radio || checkbox
    let selected = 'Radio' // radio
	let options = [
                'Radio',
                'Radio2',
                { label: 'Radio5', value: 'object', disabled: true },
                { label: 'Radio6', value: 'object1', disabled: true, className: "abcd", labelClassName: "addd" },
                // .... more
	]

	const setSelectedValue = ({ detail }) => {
            selected = detail
	}

    // default => style html
    <RadioCheckBox bind:value={selected} bind:options={options} on:change={setSelectedValue}/>

    // theme custom
    <RadioCheckBox
		bind:value={selected}
		bind:options={options}
		on:change={setSelectedValue}
		theme='tick'
		selectColor='red'
		tickColor='blue'
	/>

    <!--
    // more =>
    // groupName="item-group-template" // default random unique
    // height="30"          // min-height option
    // boxSize="16"         // box-size 16 x 16
    // className=className
    // disabled=true        // disabled all
    // checkBox=true        // input="checkbox"
    // displayBox=true      // display like checkbox
    // vertical=true        // display vertical
    // selectColor=any      // color when selected
    // unSelectColor=any    // color when no selected
    // hoverColor=any       // color when hover (default like selectColor)
    // tickColor=any        // only theme (type `tick/x`)
    // tabFocusColor        // keypress tab (shawdow box: #000)
    // checkedIcon          // custom icon

    // (boxSize is affected by: `box-sizing: border-box`)
    -->

Props

The following props are accepted:

value (Array || String)

Selected value.

change (Function)

Update value

groupName (String)

if you want to use multiple RadioCheckBox(same name), you can set the group name

    <RadioCheckBox groupName="groupabc" theme="in" ... />
    <RadioCheckBox groupName="groupabc" theme="fill" ... />

options (Array)

list data like. [Object, String, ...]

[
    {
        label: 'Display', value: 'value', disabled: false,  // disabled option
        className: 'itemClass', labelClassName: 'labelClass',
        htmlData, // you change display label by htmlData
        checkedIcon // passing custom checked icon (special)
    },
    ...,
    'value' // => make option { label: value, value: value }
]

disabled (boolean)

Disabled all options. Default false

checkBox (boolean)

Type is checkbox. Default false (radio)

displayBox (boolean)

Show check mark icon like a checkbox. Default false (radio)

vertical (boolean)

Display vertical true. Defaut false

theme (String)

    // default (nothing): html
    in: [
        'fill', 'in', 'out',
        'tick', 'tick-fill', 'tick-fill-in',
        'x', 'x-fill', 'x-fill-in'
    ]

selectColor (String)

color when checked. Default #4169E1

unSelectColor (String)

color when unchecked. Default [#cbd1d8]

hoverColor (String)

color when hover. Default using (selectColor)

tickColor (String)

Use when theme type = tick.. || x..

Color of tick when check.

tabFocusColor (String)

box shadow color when focus by tab. (#000)

height (number or number_px)

min-height of line-options. (default: 24px)

boxSize (number or number_px)

size of check. (default: 16px)

className

The className added to group.

checkedIcon

customize checked icon (see live example)

customize icon check (another solution)

You should refrain from using this method.

/* set your className(.itemClass) for selector unique */
.itemClass.ldk-sv-radio-checkbox .sv-option-checked .sv-option-icon {
    background: url('./assets/images/cal.png') no-repeat center;
}
.itemClass.ldk-sv-radio-checkbox .sv-option-checked .sv-option-icon::before {
    content: '' !important;
}

Example

LIVE EXAMPLE

A working example can be found in the example directory.

npm install
npm run dev
npm run start

License

MIT