Using the Styled Kit
CLI
Simply run the following command:
pnpm dlx qwik-ui init
(or "npx qwik-ui init" if you prefer npm)
This will help you install tailwind, create a qwik-ui.config.json
file and modify your root/global css and tailwind config files with the necessary Qwik UI design system variables and values (see below)
Generating components using the CLI
When you want to add a component you can run:
pnpm qwik-ui add
Or if you know a specific component you want to add, let's say "input
", you can run:
pnpm qwik-ui add input
Manual installation
Step 1: Install the Headless Kit and qwikest icons
pnpm i -D @qwik-ui/headless @qwikest/icons @qwik-ui/utils tw-animate-css class-variance-authority
Step 2: copy/paste your theme config
Click on "make it yours" -> choose your favorite color theme and style -> copy/paste the css-variables config to your global css file.
Here's an example:
@layer base, qwik-ui, popover-polyfill, theme, components, utilities;
@import 'tailwindcss';
@import 'tw-animate-css';
@custom-variant dark (&:is(.dark *));
@layer base {
:root {
--background: white;
--foreground: var(--color-slate-950);
--muted: var(--color-slate-100);
--muted-foreground: var(--color-slate-700);
--popover: white;
--popover-foreground: var(--color-slate-900);
--card: white;
--card-foreground: var(--color-slate-900);
--border: var(--color-slate-200);
--input: var(--color-slate-200);
--primary: var(--color-cyan-600);
--primary-foreground: white;
--secondary: var(--color-slate-900);
--secondary-foreground: white;
--accent: var(--color-slate-100);
--accent-foreground: var(--color-slate-900);
--alert: var(--color-red-500);
--alert-foreground: var(--color-slate-50);
--ring: var(--color-slate-900);
--border-width: 0px;
--stroke-width: 1px;
--border-radius: 0.5rem;
--shadow-base: none;
--shadow-2xs: 0 1px rgb(0 0 0 / 0.05);
--shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
--shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
--shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
--shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.01);
--transform-press: scale(0.95);
}
.dark {
--background: var(--color-slate-950);
--foreground: var(--color-slate-50);
--muted: var(--color-slate-800);
--muted-foreground: var(--color-slate-300);
--popover: var(--color-slate-950);
--popover-foreground: var(--color-slate-50);
--card: var(--color-slate-950);
--card-foreground: var(--color-slate-50);
--border: var(--color-slate-800);
--input: var(--color-slate-800);
--primary: var(--color-cyan-600);
--primary-foreground: white;
--secondary: var(--color-slate-100);
--secondary-foreground: black;
--accent: var(--color-slate-700);
--accent-foreground: var(--color-slate-50);
--alert: var(--color-red-500);
--alert-foreground: var(--color-slate-50);
--ring: var(--color-slate-300);
--border-width: 0px;
--stroke-width: 1px;
--border-radius: 0.5rem;
--shadow-base: none;
--shadow-2xs: 0 1px rgb(0 0 0 / 0.05);
--shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
--shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
--shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
--shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.01);
--transform-press: scale(0.95);
}
}
@theme {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-card: var(--card);
--color-card-foreground: var(--card-foreground);
--color-popover: var(--popover);
--color-popover-foreground: var(--popover-foreground);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
--color-accent: var(--accent);
--color-accent-foreground: var(--accent-foreground);
--color-alert: var(--alert);
--color-alert-foreground: var(--alert-foreground);
--color-border: var(--border);
--color-input: var(--input);
--color-ring: var(--ring);
--radius-xs: var(--border-radius);
--radius-sm: calc(var(--border-radius) + 0.125rem);
--radius-md: calc(var(--border-radius) + 0.375rem);
--radius-lg: calc(var(--border-radius) + 0.5rem);
--radius-xl: calc(var(--border-radius) + 0.75rem);
--radius-2xl: calc(var(--border-radius) + 1rem);
--radius-3xl: calc(var(--border-radius) + 1.5rem);
--shadow-base: var(--shadow-base);
--shadow-2xs: var(--shadow-2xs);
--shadow-xs: var(--shadow-xs);
--shadow-sm: var(--shadow-sm);
--shadow-md: var(--shadow-md);
--shadow-lg: var(--shadow-lg);
--shadow-xl: var(--shadow-xl);
--shadow-2xl: var(--shadow-2xl);
--shadow-inner: var(--shadow-inner);
--default-border-width: calc(var(--border-width) + 1px);
--border-width-base: var(--border-width);
--border-width-2: calc(var(--border-width) + 2px);
--border-width-4: calc(var(--border-width) + 4px);
--border-width-8: calc(var(--border-width) + 8px);
--stroke-width-0: 0px;
--stroke-width-base: var(--stroke-width);
--stroke-width-1: calc(var(--stroke-width) + 1px);
--stroke-width-2: calc(var(--stroke-width) + 2px);
--animate-accordion-down: collapsible-down 0.2s ease-out forwards;
--animate-accordion-up: collapsible-up 0.2s ease-out forwards;
@keyframes collapsible-down {
from {
height: 0;
}
to {
height: var(--qwikui-collapsible-content-height);
}
}
@keyframes collapsible-up {
from {
height: var(--qwikui-collapsible-content-height);
}
to {
height: 0;
}
}
}
}
@utility press {
transform: var(--transform-press);
}
@utility border-width-* {
/* prettier-ignore */
border: --value(--border-width-*);
}
@utility stroke-width-* {
/* prettier-ignore */
stroke: --value(--stroke-width-*);
}
@utility shadow-* {
/* prettier-ignore */
box-shadow: --value(--shadow-*);
}
@layer base {
* {
@apply border-border outline-ring/50;
}
body {
@apply bg-background text-foreground;
}
}
Step 3: Find the components you need in the docs and copy/paste them into your project
You will find the components code in their corresponding link in the docs.
Bonus step: add a barrel file to ~/components/ui
export * from './accordion/accordion';
export * from './alert/alert';
export * from './avatar/avatar';
export * from './badge/badge';
export * from './breadcrumb/breadcrumb';
export * from './button/button';
export * from './card/card';
export * from './carousel/carousel';
export * from './checkbox/checkbox';
export * from './combobox/combobox';
export * from './dropdown/dropdown';
export * from './input/input';
export * from './label/label';
export * from './modal/modal';
export * from './popover/popover';
export * from './progress/progress';
export * from './radio-group/radio-group';
export * from './separator/separator';
export * from './skeleton/skeleton';
export * from './tabs/tabs';
export * from './textarea/textarea';
export * from './select/select';
export * from './toggle/toggle';
export * from './toggle-group/toggle-group';
export * from './tooltip/tooltip';
This way you can now import { Accordion, Alert, ... } from '~/components/ui';
👯♀️
(small tip: you can comment out the components you don't use!)
Tailwind CSS editor extension
You can configure your code editor to recognize the Qwik UI utility functions. This gives you the same auto-completion that you get for the default Tailwind CSS classes.
Use the following configuration with your chosen editor:
{
"tailwindCSS.experimental.classRegex": [
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["cn\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
]
}
VSCode
The Tailwind CSS IntelliSense extension is available to download for VSCode.
Install it, open your settings.json file, and append the provided configuration.
JetBrains IDEs
The Tailwind CSS plugin is already bundled with JetBrains IDEs.
Click here to navigate to Settings > Languages & Frameworks > Style Sheets > Tailwind CSS, and append the provided configuration.