Melt UI

repository·main·Indexed 43 days ago

https://github.com/melt-ui/next-gen

A headless component library for Svelte that provides accessible, uncoupled builders. Melt UI focuses on logic and WAI-ARIA compliance for complex UI components—such as Accordion, Avatar, Collapsible, Combobox, and Dialog—while leaving styling entirely to the developer. It offers two integration patterns: low-level Builders for maximum control in logic files and high-level Components for an idiomatic Svelte experience using the bind: directive and snippets.

Tokens
28.1K
Snippets
74
Records
117
Agent score
56%

What's inside Melt UI

  1. Overview of Melt UI features

    main

    Melt UI is a next-generation library of headless components designed for Svelte. Its core value propositions include:

    • Headless Components: Components are fully customizable with zero styling opinions, giving you complete control over the UI.
    • Type Safety: Built with TypeScript to provide a high-quality developer experience.
    • Accessibility: Components follow WAI-ARIA guidelines and include built-in keyboard navigation.
    • Svelte 5 Ready: Fully compatible with Svelte 5, including support for runes and other modern Svelte features.
  2. What is Melt UI?

    main
    Melt UI is a collection of headless, accessible component builders designed specifically for Svelte. Instead of providing pre-styled components, it provides 'builders' that manage logic, state, and accessibility (WAI-ARIA) requirements. This allows developers to attach the builder's functionality to any HTML element or custom component, giving them full control over the visual styling while ensuring the component remains accessible and robust.
  3. Tree component features

    main

    The Tree component provides the following capabilities:

    • Keyboard navigation: Full support for navigating the hierarchy via keyboard.
    • Multi-selection mode: Ability to select multiple items within the tree.
    • Smart focus management: Automatic handling of focus as users navigate.
    • Optional expand on click: Configurable behavior for expanding nodes.
    • Typeahead: Highlight items by typing their names.
  4. PinInput features

    main

    The PinInput component provides the following capabilities:

    • Keyboard navigation: Optimized for sequence entry.
    • Multiple entry validation types: Supports various validation logic for the PIN sequence.
    • Paste support: Allows users to paste a full sequence into the input.
    • Mobile optimization: Automatically triggers the appropriate keyboard type on mobile devices.
  5. Slider features

    main

    The Slider component includes the following built-in capabilities:

    • Keyboard navigation: Full support for controlling the value via keyboard.
    • Smart focus management: Handles focus states appropriately.
    • Orientation: Supports both horizontal and vertical orientations.
    • Data attributes: Provides attributes like data-dragging to help with styling transitions during interaction.
  6. Features of the Tabs component

    main

    The Tabs component provides the following built-in capabilities:

    • Keyboard navigation: Full support for navigating between tabs using keyboard inputs.
    • Smart focus management: Automatically handles focus transitions when switching tabs.
    • Orientation: Supports both horizontal and vertical layouts.
    • RTL support: (Incoming feature)
  7. Understand MaybeMultiple props

    main

    Some Melt builders use MaybeMultiple props, where the expected type changes based on an accompanying boolean prop (e.g., multiple).

    For example, a FileUpload builder with a selected prop and a multiple prop:

    • If multiple is false or undefined: selected accepts a MaybeGetter<File> (standard reactive value).
    • If multiple is true: selected accepts an IterableProp<File>, which can be a SvelteSet or a MaybeGetter<Iterable<File>>.
  8. Understand the Starlight project structure

    main

    A standard Starlight project follows this directory structure:

    • src/content/docs/: The primary location for documentation. Starlight automatically exposes .md or .mdx files in this directory as routes based on their filenames.
    • src/assets/: Place images here to embed them in Markdown using relative links.
    • public/: Store static assets that do not need processing, such as favicons.
    • astro.config.mjs: The main configuration file for Astro and Starlight.
    • package.json: Defines project dependencies and scripts.
    .
    ├── public/
    ├── src/
    │   ├── assets/
    │   ├── content/
    │   │   ├── docs/
    │   │   └── config.ts
    │   └── env.d.ts
    ├── astro.config.mjs
    ├── package.json
    └── tsconfig.json