Convert Figma logo to code with AI

huntabyte logoshadcn-svelte

shadcn/ui, but for Svelte. โœจ

5,107
315
5,107
76

Top Related Projects

71,970

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.

33,595

๐ŸŒผ ๐ŸŒผ ๐ŸŒผ ๐ŸŒผ ๐ŸŒผ โ€ƒThe most popular, free and open-source Tailwind CSS component library

A utility-first CSS framework for rapid UI development.

37,442

โšก๏ธ Simple, Modular & Accessible UI Components for your React Applications

Radix Primitives is an open-source UI component library for building high-quality, accessible design systems and web apps. Maintained by @workos.

39,623

๐Ÿ‰ Vue Component Framework

Quick Overview

Shadcn-svelte is a port of the popular shadcn/ui components to Svelte. It provides a set of accessible, customizable, and reusable components for building modern web applications using Svelte and Tailwind CSS. This project aims to bring the flexibility and design of shadcn/ui to the Svelte ecosystem.

Pros

  • Offers a wide range of pre-built, customizable components
  • Follows accessibility best practices
  • Seamlessly integrates with Tailwind CSS for easy styling
  • Provides a familiar API for developers coming from React

Cons

  • As a port, it may lag behind the original shadcn/ui in terms of updates and new features
  • Limited documentation compared to the original React version
  • May require additional setup and configuration for Svelte projects
  • Potential for inconsistencies or bugs due to the translation from React to Svelte

Code Examples

  1. Button component usage:
<script>
  import { Button } from "$lib/components/ui/button";
</script>

<Button variant="outline">Click me</Button>
  1. Dialog component example:
<script>
  import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "$lib/components/ui/dialog";
</script>

<Dialog>
  <DialogTrigger>Open Dialog</DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Dialog Title</DialogTitle>
      <DialogDescription>This is a dialog description.</DialogDescription>
    </DialogHeader>
    <p>Dialog content goes here.</p>
  </DialogContent>
</Dialog>
  1. Select component usage:
<script>
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "$lib/components/ui/select";
</script>

<Select>
  <SelectTrigger class="w-[180px]">
    <SelectValue placeholder="Select a fruit" />
  </SelectTrigger>
  <SelectContent>
    <SelectItem value="apple">Apple</SelectItem>
    <SelectItem value="banana">Banana</SelectItem>
    <SelectItem value="orange">Orange</SelectItem>
  </SelectContent>
</Select>

Getting Started

To use shadcn-svelte in your Svelte project:

  1. Install the package:
npm install shadcn-svelte
  1. Import and use components in your Svelte files:
<script>
  import { Button } from "shadcn-svelte";
</script>

<Button>Click me</Button>
  1. Make sure you have Tailwind CSS set up in your project for proper styling.

  2. Customize components by modifying their props or overriding their styles using Tailwind classes.

Competitor Comparisons

71,970

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.

Pros of ui

  • More comprehensive component library with a wider range of UI elements
  • Stronger community support and more frequent updates
  • Better documentation and examples for implementation

Cons of ui

  • Limited to React framework, less flexible for other technologies
  • Steeper learning curve for developers not familiar with React

Code Comparison

ui (React):

import { Button } from "@/components/ui/button"

export function Example() {
  return <Button>Click me</Button>
}

shadcn-svelte (Svelte):

<script>
  import { Button } from '$lib/components/ui/button';
</script>

<Button>Click me</Button>

Key Differences

  • ui is designed specifically for React, while shadcn-svelte is a Svelte port
  • shadcn-svelte offers easier integration for Svelte projects
  • ui has more extensive theming options and customization features
  • shadcn-svelte may lag behind ui in terms of new component additions and updates

Use Cases

  • Choose ui for React-based projects requiring a rich set of UI components
  • Opt for shadcn-svelte when working with Svelte and needing similar component functionality
  • ui is better suited for large-scale applications with complex UI requirements
  • shadcn-svelte is ideal for Svelte developers looking for a familiar component library
33,595

๐ŸŒผ ๐ŸŒผ ๐ŸŒผ ๐ŸŒผ ๐ŸŒผ โ€ƒThe most popular, free and open-source Tailwind CSS component library

Pros of daisyUI

  • Larger community and more established project with higher star count
  • Extensive collection of pre-built components and utility classes
  • Easier to customize with Tailwind CSS configuration

Cons of daisyUI

  • Less flexibility in component styling compared to shadcn-svelte
  • Potentially larger bundle size due to comprehensive component library
  • May require more effort to achieve a unique design aesthetic

Code Comparison

shadcn-svelte:

<script lang="ts">
  import { Button } from "$lib/components/ui/button";
</script>

<Button variant="outline">Click me</Button>

daisyUI:

<button class="btn btn-outline">Click me</button>

Both libraries offer easy-to-use components, but shadcn-svelte uses a more modular approach with imported components, while daisyUI relies on utility classes applied directly to HTML elements.

A utility-first CSS framework for rapid UI development.

Pros of Tailwind CSS

  • More flexible and customizable, allowing for fine-grained control over styles
  • Larger community and ecosystem, with extensive documentation and resources
  • Can be used with any JavaScript framework or vanilla HTML

Cons of Tailwind CSS

  • Steeper learning curve, requiring familiarity with utility-class naming conventions
  • Potentially larger CSS bundle size if not properly optimized
  • Requires more manual implementation of components compared to pre-built solutions

Code Comparison

Tailwind CSS:

<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
  Click me
</button>

shadcn-svelte:

<script>
  import { Button } from "$lib/components/ui/button";
</script>

<Button>Click me</Button>

The Tailwind CSS example shows direct utility class usage, while shadcn-svelte provides a pre-built component with encapsulated styles. Tailwind CSS offers more granular control but requires more markup, whereas shadcn-svelte provides a cleaner, more abstracted approach at the cost of some flexibility.

37,442

โšก๏ธ Simple, Modular & Accessible UI Components for your React Applications

Pros of Chakra UI

  • More mature and widely adopted, with a larger community and ecosystem
  • Offers a comprehensive set of pre-built components out of the box
  • Provides a robust theming system with built-in dark mode support

Cons of Chakra UI

  • Larger bundle size due to its comprehensive nature
  • Less flexibility in terms of customization compared to shadcn-svelte
  • Steeper learning curve for developers new to the library

Code Comparison

Chakra UI (React):

import { Box, Button } from '@chakra-ui/react'

function MyComponent() {
  return (
    <Box>
      <Button colorScheme="blue">Click me</Button>
    </Box>
  )
}

shadcn-svelte:

<script>
  import { Button } from "$lib/components/ui/button";
</script>

<div>
  <Button variant="default">Click me</Button>
</div>

Both libraries offer a similar component-based approach, but Chakra UI provides more built-in styling options, while shadcn-svelte focuses on simplicity and customization. Chakra UI is React-based, whereas shadcn-svelte is tailored for Svelte applications, offering a more native integration with the Svelte ecosystem.

Radix Primitives is an open-source UI component library for building high-quality, accessible design systems and web apps. Maintained by @workos.

Pros of Primitives

  • More comprehensive set of UI components
  • Highly customizable and flexible
  • Strong focus on accessibility and keyboard navigation

Cons of Primitives

  • Steeper learning curve due to its low-level nature
  • Requires more setup and configuration

Code Comparison

Primitives (React):

import * as Dialog from '@radix-ui/react-dialog';

<Dialog.Root>
  <Dialog.Trigger>Open</Dialog.Trigger>
  <Dialog.Content>
    <Dialog.Title>Dialog Title</Dialog.Title>
    <Dialog.Description>Dialog content here</Dialog.Description>
  </Dialog.Content>
</Dialog.Root>

shadcn-svelte:

<script>
  import { Dialog } from "$lib/components/ui/dialog";
</script>

<Dialog.Root>
  <Dialog.Trigger>Open</Dialog.Trigger>
  <Dialog.Content>
    <Dialog.Title>Dialog Title</Dialog.Title>
    <Dialog.Description>Dialog content here</Dialog.Description>
  </Dialog.Content>
</Dialog.Root>

Summary

Primitives offers a more extensive set of UI components with a strong focus on accessibility and customization. However, it has a steeper learning curve and requires more setup. shadcn-svelte, while more limited in scope, provides a simpler API and is specifically tailored for Svelte applications. The code comparison shows similar usage patterns, with Primitives using React syntax and shadcn-svelte using Svelte syntax.

39,623

๐Ÿ‰ Vue Component Framework

Pros of Vuetify

  • Comprehensive UI component library with a wide range of pre-built components
  • Extensive documentation and active community support
  • Material Design-based, offering a consistent and modern look out-of-the-box

Cons of Vuetify

  • Larger bundle size due to the extensive component library
  • Less flexibility in customization compared to shadcn-svelte's utility-first approach
  • Steeper learning curve for developers new to Material Design principles

Code Comparison

Vuetify component usage:

<template>
  <v-btn color="primary" @click="handleClick">
    Click me
  </v-btn>
</template>

shadcn-svelte component usage:

<script>
  import { Button } from "$lib/components/ui/button";
</script>

<Button on:click={handleClick}>Click me</Button>

The Vuetify example shows a more opinionated approach with built-in styling, while shadcn-svelte offers a more minimal and customizable component structure. Vuetify's components come with pre-defined styles and behaviors, whereas shadcn-svelte components are designed to be easily tailored to specific project needs.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

shadcn-svelte

shadcn-svelte is an unofficial community-led Svelte port of shadcn/ui.

Note
We are not affiliated with shadcn, but we did get his blessing prior to creating this project
This is a project born out of the need for a similar project for the Svelte ecosystem.

Accessible and customizable components that you can copy and paste into your apps. Free. Open Source. Use this to build your own component library.

hero

Documentation

Visit https://shadcn-svelte.com/docs to view the documentation.

Sponsors

This project is supported by the following beautiful people/organizations:

Logos from Sponsors

License

Published under the MIT license. Built by @huntabyte, CokaKoala,and community รฐยŸย’ย›

Community

Join the Discord server to ask questions, find collaborators, or just say hi!

Svecosystem Discord community