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

@slhs/spark-combobox

v1.3.1

Published

Spark UI Combobox component packaged up for SLHS

Downloads

1,211

Readme

@slhs/spark-combobox

The Combobox component from the Spark UI design system with a CSS file and Tailwind config wrapper to override some of their styles.

npm Version Build Status

Installation

npm install @slhs/spark-combobox

Usage

This package assumes you're using Tailwind CSS and:

  1. Your main CSS file (e.g., app.css) looks something like this:

    @tailwind base;
    @tailwind components;
    @tailwind utilities;
    
    @layer base {
      :root {
        /* Primary */
        --color-brand-dark-blue: 0 44 119;
        /* Secondary blue hues */
        --color-brand-light-blue: 104 172 229;
        --color-brand-sky-blue: 37 194 230;
        --color-brand-brilliant-blue: 0 146 208;
        --color-brand-lapis-blue: 31 108 180;
        --color-brand-steel-blue: 64 88 104;
        /* Accent colors */
        --color-brand-buttercup: 255 222 117;
        --color-brand-canary: 235 186 30;
        --color-brand-tangerine: 246 142 30;
        --color-brand-kelly-green: 20 161 88;
        --color-brand-teal: 0 174 170;
        --color-brand-purple: 124 43 131;
        /* Neutral palette */
        --color-brand-concrete: 209 210 212;
        --color-brand-slate: 96 96 96;
        --color-brand-sand: 230 228 212;
    
        /* Abstract color names */
        --color-primary: var(--color-brand-dark-blue);
        --color-primary-hover: 51 66 142;
        --color-primary-active: 0 25 100;
        --color-secondary: var(--color-brand-slate);
        --color-secondary-hover: 105 105 105;
        --color-secondary-active: 89 89 89;
        --color-danger: 220 38 38;
        --color-danger-hover: 239 68 68;
        --color-danger-active: 201, 8, 8;
      }
    }
    
    /* Override input ring/border color from @tailwindcss/forms plugin with our primary color */
    input[type='text'],
    input[type='password'],
    input[type='email'],
    input[type='number'],
    input[type='url'],
    input[type='date'],
    input[type='datetime-local'],
    input[type='month'],
    input[type='week'],
    input[type='time'],
    input[type='search'],
    input[type='tel'],
    input[type='checkbox'],
    input[type='radio'],
    select,
    select[multiple],
    textarea {
      @apply ring-primary focus:border-primary;
    }
  2. Your Tailwind config file (e.g., tailwind.config.ts) looks something like this:

    import { withSparkCombobox } from '@slhs/spark-combobox/tw';
    
    /** @type {import('tailwindcss').Config} */
    const config = withSparkCombobox({
      content: ['./index.html', './src/**/*.tsx'],
      theme: {
        extend: {
          colors: {
            /* Literal color names */
            // Primary
            'brand-dark-blue': 'rgb(var(--color-brand-dark-blue) / <alpha-value>)',
            // Secondary blue hues
            'brand-light-blue': 'rgb(var(--color-brand-light-blue) / <alpha-value>)',
            'brand-sky-blue': 'rgb(var(--color-brand-sky-blue) / <alpha-value>)',
            'brand-brilliant-blue': 'rgb(var(--color-brand-brilliant-blue) / <alpha-value>)',
            'brand-lapis-blue': 'rgb(var(--color-brand-lapis-blue) / <alpha-value>)',
            'brand-steel-blue': 'rgb(var(--color-brand-steel-blue) / <alpha-value>)',
            // Accent colors
            'brand-buttercup': 'rgb(var(--color-brand-buttercup) / <alpha-value>)',
            'brand-canary': 'rgb(var(--color-brand-canary) / <alpha-value>)',
            'brand-tangerine': 'rgb(var(--color-brand-tangerine) / <alpha-value>)',
            'brand-kelly-green': 'rgb(var(--color-brand-kelly-green) / <alpha-value>)',
            'brand-teal': 'rgb(var(--color-brand-teal) / <alpha-value>)',
            'brand-purple': 'rgb(var(--color-brand-purple) / <alpha-value>)',
            // Neutral palette
            'brand-concrete': 'rgb(var(--color-brand-concrete) / <alpha-value>)',
            'brand-slate': 'rgb(var(--color-brand-slate) / <alpha-value>)',
            'brand-sand': 'rgb(var(--color-brand-sand) / <alpha-value>)',
    
            /* Abstract color names */
            primary: {
              DEFAULT: 'rgb(var(--color-primary) / <alpha-value>)',
              hover: 'rgb(var(--color-primary-hover) / <alpha-value>)',
              active: 'rgb(var(--color-primary-active) / <alpha-value>)',
            },
            secondary: {
              DEFAULT: 'rgb(var(--color-secondary) / <alpha-value>)',
              hover: 'rgb(var(--color-secondary-hover) / <alpha-value>)',
              active: 'rgb(var(--color-secondary-active) / <alpha-value>)',
            },
            danger: {
              DEFAULT: 'rgb(var(--color-danger) / <alpha-value>)',
              hover: 'rgb(var(--color-danger-hover) / <alpha-value>)',
              active: 'rgb(var(--color-danger-active) / <alpha-value>)',
            },
          },
        },
      },
    });
    
    export default config;

The override styles rely on this combined configuration for referencing certain values, e.g. var(--color-primary) and bg-brand-concrete/40. If you don't have these in place, you'll need to adjust the override styles accordingly. The withSparkCombobox() wrapper ensures all the default Tailwind classes Spark UI uses are included and also generates a few additional Spark-specific utility classes.

Once you've got the above in place, the next step is to copy the override styles from spark-combobox.css into your project. Import the styles in whichever way makes sense for your project (e.g., in a Remix v2 app, import the spark-combobox.css file to get a URL and include that URL in your exported links function). Customize your local copy of this file as needed.

Finally, import the component from this package like so:

import { Combobox } from '@slhs/spark-combobox';

Refer to the Spark UI Combobox docs for usage instructions.

[!WARNING] At this time, the Combobox component does not server render well. You should wrap it with ClientOnly to avoid hydration mismatches.