Top Related Projects
A set of headless, accessible component builders for Svelte.
Unofficial Svelte port of the Headless UI component library
shadcn/ui, but for Svelte. ✨
A complete design system and component solution, built on Tailwind.
Svelte implementation of the Carbon Design System
Official Svelte components built for Flowbite and Tailwind CSS
Quick Overview
Attractions is a UI component library for Svelte, designed to provide a set of customizable and accessible components for building web applications. It offers a range of UI elements with a focus on flexibility and ease of use, allowing developers to create modern and responsive interfaces quickly.
Pros
- Comprehensive set of UI components tailored for Svelte applications
- Highly customizable with a focus on accessibility
- Lightweight and performant, optimized for Svelte's reactivity system
- Well-documented with examples and API references
Cons
- Limited ecosystem compared to more established UI libraries
- May require additional styling effort for complex custom designs
- Learning curve for developers new to Svelte or component-based UI libraries
- Fewer third-party extensions and integrations available
Code Examples
- Using a Button component:
<script>
import { Button } from 'attractions';
</script>
<Button on:click={() => alert('Clicked!')}>
Click me
</Button>
- Creating a form with Input and Select components:
<script>
import { Form, Input, Select } from 'attractions';
let name = '';
let country = '';
</script>
<Form on:submit|preventDefault={() => console.log({ name, country })}>
<Input label="Name" bind:value={name} />
<Select label="Country" bind:value={country}>
<option value="us">United States</option>
<option value="ca">Canada</option>
<option value="uk">United Kingdom</option>
</Select>
<Button type="submit">Submit</Button>
</Form>
- Implementing a Modal dialog:
<script>
import { Button, Modal } from 'attractions';
let showModal = false;
</script>
<Button on:click={() => showModal = true}>Open Modal</Button>
<Modal bind:open={showModal}>
<h2>Modal Title</h2>
<p>This is the modal content.</p>
<Button on:click={() => showModal = false}>Close</Button>
</Modal>
Getting Started
To use Attractions in your Svelte project:
-
Install the package:
npm install attractions
-
Import and use components in your Svelte files:
<script> import { Button, Input } from 'attractions'; </script> <Button>Click me</Button> <Input label="Username" />
-
(Optional) Import the default CSS in your main app file:
import 'attractions/attractions.css';
For more detailed usage and customization options, refer to the official documentation.
Competitor Comparisons
A set of headless, accessible component builders for Svelte.
Pros of Melt UI
- Offers a more extensive set of UI components and primitives
- Provides greater flexibility and customization options
- Utilizes a headless approach, allowing for more control over styling
Cons of Melt UI
- Steeper learning curve due to its more complex architecture
- Requires more setup and configuration compared to Attractions
Code Comparison
Melt UI (Button component):
import { createButton } from '@melt-ui/svelte';
const { button, label } = createButton();
<button use:button>
<span use:label>Click me</span>
</button>
Attractions (Button component):
import { Button } from 'attractions';
<Button>Click me</Button>
Summary
Melt UI offers a more comprehensive and flexible UI toolkit with a headless approach, allowing for greater customization but requiring more setup. Attractions provides a simpler, more opinionated solution with less configuration needed. The code comparison shows that Melt UI requires more boilerplate but offers finer control over component behavior, while Attractions provides a more straightforward implementation.
Unofficial Svelte port of the Headless UI component library
Pros of svelte-headlessui
- Offers a wider range of UI components, including more complex ones like comboboxes and dialogs
- Provides unstyled components, allowing for greater customization and flexibility
- Closely follows the Headless UI API, making it familiar for developers coming from React
Cons of svelte-headlessui
- Less opinionated styling, requiring more work to achieve a polished look
- May have a steeper learning curve for developers new to headless UI concepts
- Potentially larger bundle size due to the comprehensive component set
Code Comparison
attractions:
<Button on:click={handleClick}>
Click me
</Button>
svelte-headlessui:
<Menu as="div">
<Menu.Button>Options</Menu.Button>
<Menu.Items>
<Menu.Item>
{({ active }) => (
<a class:active href="/account-settings">Account settings</a>
)}
</Menu.Item>
</Menu.Items>
</Menu>
The code comparison shows that attractions offers a more straightforward API for basic components, while svelte-headlessui provides a more complex structure for advanced components with additional functionality.
shadcn/ui, but for Svelte. ✨
Pros of shadcn-svelte
- More comprehensive component library with a wider range of UI elements
- Follows a modern, utility-first CSS approach using Tailwind
- Active development with frequent updates and community contributions
Cons of shadcn-svelte
- Steeper learning curve due to Tailwind CSS integration
- Potentially larger bundle size due to the inclusion of Tailwind
Code Comparison
attractions:
<Button on:click={handleClick}>
Click me
</Button>
shadcn-svelte:
<Button variant="outline" on:click={handleClick}>
<Mail class="mr-2 h-4 w-4" />
Login with Email
</Button>
Summary
shadcn-svelte offers a more extensive component library with modern styling approaches, but may require more initial setup and learning. attractions provides a simpler, more lightweight solution with a focus on ease of use. The choice between the two depends on project requirements, team expertise, and desired customization level.
A complete design system and component solution, built on Tailwind.
Pros of Skeleton
- More comprehensive UI component library with a wider range of pre-built elements
- Active development and frequent updates, ensuring compatibility with the latest Svelte versions
- Extensive documentation and examples, making it easier for developers to get started
Cons of Skeleton
- Larger bundle size due to the extensive component library
- Steeper learning curve for developers new to the framework
- Less flexibility in customizing individual components compared to Attractions
Code Comparison
Skeleton:
<script>
import { Button } from '@skeletonlabs/skeleton';
</script>
<Button>Click me</Button>
Attractions:
<script>
import { Button } from 'attractions';
</script>
<Button>Click me</Button>
Summary
Skeleton offers a more comprehensive UI library with frequent updates and extensive documentation, making it suitable for larger projects. However, it comes with a larger bundle size and potentially steeper learning curve. Attractions, on the other hand, provides a more lightweight and flexible approach, allowing for easier customization of individual components. The choice between the two depends on project requirements, team expertise, and desired level of customization.
Svelte implementation of the Carbon Design System
Pros of Carbon Components Svelte
- Comprehensive design system with a wide range of components
- Backed by IBM, ensuring long-term support and updates
- Follows accessibility standards and best practices
Cons of Carbon Components Svelte
- Larger bundle size due to the extensive component library
- Steeper learning curve for developers new to the Carbon Design System
- Less flexibility in customization compared to Attractions
Code Comparison
Carbon Components Svelte:
<script>
import { Button } from "carbon-components-svelte";
</script>
<Button>Click me</Button>
Attractions:
<script>
import { Button } from "attractions";
</script>
<Button>Click me</Button>
Both libraries offer similar component usage, but Carbon Components Svelte provides a more extensive set of props and options for each component, reflecting its comprehensive design system approach. Attractions, on the other hand, focuses on simplicity and ease of use, which can be beneficial for smaller projects or developers who prefer a more lightweight solution.
Official Svelte components built for Flowbite and Tailwind CSS
Pros of Flowbite-svelte
- Larger component library with more diverse UI elements
- Better documentation and examples for each component
- Active development with frequent updates and bug fixes
Cons of Flowbite-svelte
- Heavier bundle size due to more components and dependencies
- Less customizable styling options out of the box
- Steeper learning curve for beginners due to complexity
Code Comparison
Attractions:
<Button on:click={handleClick}>
Click me
</Button>
Flowbite-svelte:
<Button color="blue" size="lg" on:click={handleClick}>
<Icon name="arrow-right" class="mr-2 h-5 w-5" />
Click me
</Button>
Both libraries offer similar basic functionality, but Flowbite-svelte provides more built-in props for customization and includes icon support. Attractions focuses on simplicity, while Flowbite-svelte offers more advanced features at the cost of increased complexity.
Attractions is lightweight and easy to use, making it suitable for smaller projects or developers who prefer minimal dependencies. Flowbite-svelte, on the other hand, is more comprehensive and better suited for larger applications that require a wide range of UI components and customization options.
Ultimately, the choice between these libraries depends on the specific needs of your project and your preferred development style.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Attractions
A pretty cool UI kit for Svelte.
Refer to the main documentation: https://illright.github.io/attractions
Installation
Step 1. Install the library with your favorite package manager:
npm install --save-dev attractions
# -- or --
yarn add --dev attractions
# -- or --
pnpm add --save-dev attractions
Step 2. Install svelte-preprocess
, Dart Sass and PostCSS:
npm install --save-dev svelte-preprocess sass postcss
# -- or --
yarn add --dev svelte-preprocess sass postcss
# -- or --
pnpm add --save-dev svelte-preprocess sass postcss
Step 3. Add svelte-preprocess
to your preprocessor chain (as shown here):
// rollup.config.js
import sveltePreprocess from 'svelte-preprocess';
export default {
// ...,
plugins: [
svelte({
preprocess: sveltePreprocess(),
}),
],
};
Step 4. Import the desired components as named imports and use wherever you like!
<script>
import { Button } from 'attractions';
</script>
<Button>click me</Button>
For more information on how to customize/theme your installation, see the docs.
Alternatively, the library can be used from a CDN, such as unpkg, and then the components will be registered as custom elements. This is especially useful for quick prototypes that do not need all the features provided.
Example usage:
<head>
<script src="https://unpkg.com/attractions"></script>
</head>
<body>
<a-button filled="filled">My button</a-button>
</body>
For more details, check out the docs.
License
This project is MIT licensed.
Top Related Projects
A set of headless, accessible component builders for Svelte.
Unofficial Svelte port of the Headless UI component library
shadcn/ui, but for Svelte. ✨
A complete design system and component solution, built on Tailwind.
Svelte implementation of the Carbon Design System
Official Svelte components built for Flowbite and Tailwind CSS
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot