Convert Figma logo to code with AI

solidjs-community logosolid-primitives

A library of high-quality primitives that extend SolidJS reactivity.

1,222
121
1,222
54

Top Related Projects

207,677

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

95,657

Deliver web apps with confidence 🚀

78,194

Cybernetically enhanced web apps

36,546

⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.

27,910

A rugged, minimal framework for composing JavaScript behavior in your markup.

Quick Overview

Solid Primitives is a collection of community-contributed primitives and utilities for the SolidJS framework. It provides a wide range of reusable components and functions to enhance development productivity and extend the capabilities of SolidJS applications.

Pros

  • Extensive collection of utilities and primitives for various common tasks
  • Community-driven, ensuring diverse and practical solutions
  • Well-documented and maintained, with regular updates
  • Seamless integration with SolidJS projects

Cons

  • May introduce additional dependencies to your project
  • Some primitives might have a learning curve for newcomers
  • Potential for inconsistencies in API design across different primitives
  • Occasional breaking changes between major versions

Code Examples

  1. Using the createLocalStorage primitive:
import { createLocalStorage } from "@solid-primitives/storage";

const [value, setValue] = createLocalStorage("myKey", "defaultValue");

// Reading the value
console.log(value());

// Setting a new value
setValue("newValue");
  1. Implementing a debounced function with debounce:
import { debounce } from "@solid-primitives/scheduled";

const debouncedSearch = debounce((query) => {
  // Perform search operation
  console.log("Searching for:", query);
}, 300);

// Usage
debouncedSearch("example");
  1. Creating a reactive media query with createMediaQuery:
import { createMediaQuery } from "@solid-primitives/media";

const isWideScreen = createMediaQuery("(min-width: 1024px)");

// In your component
<Show when={isWideScreen()}>
  <WideScreenContent />
</Show>

Getting Started

To use Solid Primitives in your SolidJS project:

  1. Install the package:

    npm install @solid-primitives/storage @solid-primitives/scheduled @solid-primitives/media
    
  2. Import and use the primitives in your components:

    import { createLocalStorage } from "@solid-primitives/storage";
    import { debounce } from "@solid-primitives/scheduled";
    import { createMediaQuery } from "@solid-primitives/media";
    
    // Use the primitives in your component logic
    
  3. Refer to the official documentation for specific usage instructions for each primitive.

Competitor Comparisons

207,677

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

Pros of Vue

  • Larger ecosystem and community support
  • More comprehensive documentation and learning resources
  • Wider adoption in industry, potentially leading to more job opportunities

Cons of Vue

  • Heavier bundle size compared to Solid's lightweight approach
  • Potentially slower performance due to virtual DOM diffing
  • More complex reactivity system compared to Solid's fine-grained reactivity

Code Comparison

Vue:

<template>
  <div>{{ count }}</div>
</template>

<script>
export default {
  data() {
    return { count: 0 }
  }
}
</script>

Solid Primitives:

import { createSignal } from "solid-js";

function Counter() {
  const [count, setCount] = createSignal(0);
  return <div>{count()}</div>;
}

The Solid Primitives repository focuses on providing a collection of reactive primitives for SolidJS, offering a more granular and flexible approach to reactivity. Vue, on the other hand, provides a full-featured framework with a template-based approach and a more opinionated structure.

While Vue offers a more traditional and widely-adopted framework experience, Solid Primitives aims to provide a lightweight and highly performant alternative with fine-grained reactivity. The choice between the two depends on project requirements, team familiarity, and performance needs.

95,657

Deliver web apps with confidence 🚀

Pros of Angular

  • Comprehensive framework with built-in features like routing, forms, and HTTP client
  • Large ecosystem and community support
  • Opinionated structure, promoting consistency across projects

Cons of Angular

  • Steeper learning curve due to its complexity
  • Larger bundle size compared to more lightweight alternatives
  • More verbose syntax and boilerplate code

Code Comparison

Angular:

@Component({
  selector: 'app-root',
  template: '<h1>{{ title }}</h1>'
})
export class AppComponent {
  title = 'Hello, Angular!';
}

Solid Primitives:

import { createSignal } from "solid-js";

const [title, setTitle] = createSignal("Hello, Solid!");
const App = () => <h1>{title()}</h1>;

Summary

Angular is a full-featured framework offering a complete solution for large-scale applications, while Solid Primitives provides lightweight, composable utilities for Solid.js. Angular's comprehensive nature comes at the cost of complexity and larger bundle sizes, whereas Solid Primitives focuses on simplicity and performance. The code comparison illustrates Angular's component-based approach with decorators, contrasting with Solid's more functional style using signals and JSX.

78,194

Cybernetically enhanced web apps

Pros of Svelte

  • More mature and widely adopted framework with a larger community
  • Built-in state management and reactivity system
  • Compiler-based approach resulting in smaller bundle sizes

Cons of Svelte

  • Less flexible for advanced use cases compared to Solid Primitives
  • Steeper learning curve due to its unique syntax and concepts
  • Limited options for fine-grained reactivity control

Code Comparison

Svelte:

<script>
  let count = 0;
  function increment() {
    count += 1;
  }
</script>

<button on:click={increment}>
  Clicks: {count}
</button>

Solid Primitives:

import { createSignal } from "solid-js";

function Counter() {
  const [count, setCount] = createSignal(0);
  return (
    <button onClick={() => setCount(count() + 1)}>
      Clicks: {count()}
    </button>
  );
}

Both examples demonstrate a simple counter component. Svelte uses its built-in reactivity system with a more declarative approach, while Solid Primitives leverages signals for fine-grained reactivity control. Svelte's syntax is more concise, but Solid Primitives offers more explicit control over reactivity.

36,546

⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.

Pros of Preact

  • Smaller bundle size and faster performance compared to React
  • Extensive ecosystem and compatibility with React libraries
  • Mature project with a large community and widespread adoption

Cons of Preact

  • Less fine-grained reactivity compared to Solid's primitives
  • Lacks built-in state management solutions like Solid's signals and stores
  • Virtual DOM diffing can be less efficient than Solid's direct DOM updates

Code Comparison

Preact:

import { useState } from 'preact/hooks';

function Counter() {
  const [count, setCount] = useState(0);
  return <button onClick={() => setCount(count + 1)}>{count}</button>;
}

Solid Primitives:

import { createSignal } from 'solid-js';

function Counter() {
  const [count, setCount] = createSignal(0);
  return <button onClick={() => setCount(count() + 1)}>{count()}</button>;
}

The main difference is in how state is managed and accessed. Preact uses React-like hooks, while Solid Primitives uses signals for more granular reactivity. Solid's approach can lead to more efficient updates and easier composition of reactive primitives.

27,910

A rugged, minimal framework for composing JavaScript behavior in your markup.

Pros of Alpine

  • Lightweight and easy to learn, with a minimal API
  • Can be added to existing projects without a build step
  • Works well for enhancing static HTML with interactivity

Cons of Alpine

  • Limited ecosystem and fewer advanced features compared to Solid Primitives
  • Less performant for complex applications with frequent updates
  • Lacks the fine-grained reactivity system found in Solid.js

Code Comparison

Alpine:

<div x-data="{ count: 0 }">
    <button @click="count++">Increment</button>
    <span x-text="count"></span>
</div>

Solid Primitives:

import { createSignal } from "solid-js";

function Counter() {
  const [count, setCount] = createSignal(0);
  return (
    <>
      <button onClick={() => setCount(count() + 1)}>Increment</button>
      <span>{count()}</span>
    </>
  );
}

Alpine is more HTML-centric and uses custom attributes for reactivity, while Solid Primitives leverages JavaScript functions and JSX for a more programmatic approach. Solid Primitives offers more powerful primitives for complex state management and side effects, making it better suited for larger applications. Alpine, on the other hand, excels in simplicity and ease of integration for smaller projects or adding interactivity to existing HTML.

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

Solid Primitives

Solid Primitives

pnpm turborepo combined-downloads

A project that strives to develop high-quality, community contributed Solid primitives. All utilities are well tested and continuously maintained. Every contribution to the repository is checked for quality and maintained to the highest degree of excellence. The ultimate goal is to extend Solid's primary and secondary primitives with a set of tertiary primitives.

While Solid Primitives is not officially maintained by the SolidJS Core Team, it is managed by members of the SolidJS core and ecosystem teams. This separation allows the core library to iterate independently while allowing Solid Primitives to remain in-sync with future plans.

Philosophy

The goal of Solid Primitives is to wrap client and server side functionality to provide a fully reactive API layer. Ultimately the more rooted our tertiary primitives are, the more they act as foundation within Solid's base ecosystem. With well built and re-used foundations, the smaller (aggregate tree-shaking benefits), more concise (readability) and stable (consistent and managed testing + maintenance) applications can be overall.

Primitives

NameStagePrimitivesSizeNPM

Inputs

active-elementSTAGEcreateActiveElement
createFocusSignal
SIZEVERSION
autofocusSTAGEautofocus
createAutofocus
SIZEVERSION
input-maskSTAGEcreateInputMask
createMaskPattern
SIZEVERSION
keyboardSTAGEuseKeyDownList
useCurrentlyHeldKey
useKeyDownSequence
createKeyHold
createShortcut
SIZEVERSION
mouseSTAGEcreateMousePosition
createPositionToElement
SIZEVERSION
pointerSTAGEcreatePointerListeners
createPerPointerListeners
createPointerPosition
createPointerList
SIZEVERSION
scrollSTAGEcreateScrollPosition
useWindowScrollPosition
SIZEVERSION
selectionSTAGEcreateSelectionSIZEVERSION

Display & Media

audioSTAGEmakeAudio
makeAudioPlayer
createAudio
SIZEVERSION
boundsSTAGEcreateElementBoundsSIZEVERSION
devicesSTAGEcreateDevices
createMicrophones
createSpeakers
createCameras
createAccelerometer
createGyroscope
SIZEVERSION
filesystemSTAGEcreateFileSystem
createSyncFileSystem
createAsyncFileSystem
makeNoFileSystem
makeNoAsyncFileSystem
makeVirtualFileSystem
makeWebAccessFileSystem
makeNodeFileSystem
makeTauriFileSystem
makeChokidarWatcher
rsync
SIZEVERSION
idleSTAGEcreateIdleTimerSIZEVERSION
intersection-observerSTAGEcreateIntersectionObserver
createViewportObserver
createVisibilityObserver
SIZEVERSION
mediaSTAGEmakeMediaQueryListener
createMediaQuery
createBreakpoints
usePrefersDark
SIZEVERSION
page-visibilitySTAGEcreatePageVisibilitySIZEVERSION
resize-observerSTAGEcreateResizeObserver
createWindowSize
createElementSize
SIZEVERSION
stylesSTAGEcreateRemSizeSIZEVERSION

Browser APIs

broadcast-channelSTAGEmakeBroadcastChannel
createBroadcastChannel
SIZEVERSION
clipboardSTAGEcopyClipboard
writeClipboard
createClipboard
SIZEVERSION
event-listenerSTAGEcreateEventListener
createEventSignal
createEventListenerMap
WindowEventListener
DocumentEventListener
SIZEVERSION
event-propsSTAGEcreateEventPropsSIZEVERSION
fullscreenSTAGEcreateFullscreenSIZEVERSION
geolocationSTAGEcreateGeolocation
createGeolocationWatcher
SIZEVERSION
mutation-observerSTAGEcreateMutationObserverSIZEVERSION
permissionSTAGEcreatePermissionSIZEVERSION
storageSTAGEmakePersisted
cookieStorage
tauriStorage
multiplexStorage
storageSync
messageSync
wsSync
multiplexSync
addClearMethod
addWithOptionsMethod
makeObjectStorage
SIZEVERSION
timerSTAGEmakeTimer
createTimer
createTimeoutLoop
createPolled
createIntervalCounter
SIZEVERSION
uploadSTAGEcreateFileUploader
createDropzone
SIZEVERSION
workersSTAGEcreateWorker
createWorkerPool
createSignaledWorker
SIZEVERSION

Network

connectivitySTAGEcreateConnectivitySignalSIZEVERSION
fetchSTAGEcreateFetchSIZEVERSION
graphqlSTAGEcreateGraphQLClientSIZEVERSION
streamSTAGEcreateStream
createAmplitudeStream
createMediaPermissionRequest
createAmplitudeFromStream
createScreen
SIZEVERSION
websocketSTAGEmakeWS
createWS
createWSState
makeReconnectingWS
createReconnectingWS
makeHeartbeatWS
SIZEVERSION

Control Flow

contextSTAGEcreateContextProvider
MultiProvider
SIZEVERSION
jsx-tokenizerSTAGEcreateTokenizer
createToken
resolveTokens
isToken
SIZEVERSION
keyedSTAGEkeyArray
Key
Entries
SIZEVERSION
listSTAGElistArray
List
SIZEVERSION
rangeSTAGErepeat
mapRange
indexRange
Repeat
Range
IndexRange
SIZEVERSION
refsSTAGEmergeRefs
resolveElements
resolveFirst
Ref
Refs
SIZEVERSION

Utilities

controlled-propsSTAGEcreateControlledPropSIZEVERSION
cursorSTAGEcreateElementCursor
createBodyCursor
SIZEVERSION
dateSTAGEcreateDate
createDateNow
createTimeDifference
createTimeDifferenceFromNow
createTimeAgo
createCountdown
createCountdownFromNow
SIZEVERSION
event-busSTAGEcreateEventBus
createEmitter
createEventHub
createEventStack
SIZEVERSION
event-dispatcherSTAGEcreateEventDispatcherSIZEVERSION
flux-storeSTAGEcreateFluxStore
createFluxFactory
createActions
createAction
SIZEVERSION
historySTAGEcreateUndoHistorySIZEVERSION
i18nSTAGEflatten
resolveTemplate
translator
scopedTranslator
chainedTranslator
SIZEVERSION
platformSTAGEList of variablesSIZEVERSION
promiseSTAGEpromiseTimeout
raceTimeout
until
SIZEVERSION
propsSTAGEcombineProps
filterProps
SIZEVERSION
scheduledSTAGEdebounce
throttle
scheduleIdle
leading
createScheduled
leadingAndTrailing
SIZEVERSION
script-loaderSTAGEcreateScriptLoaderSIZEVERSION
shareSTAGEcreateSocialShare
createWebShare
SIZEVERSION

Reactivity

deepSTAGEtrackDeep
trackStore
captureStoreUpdates
SIZEVERSION
destructureSTAGEdestructureSIZEVERSION
immutableSTAGEcreateImmutableSIZEVERSION
lifecycleSTAGEcreateIsMounted
isHydrated
onConnect
SIZEVERSION
mapSTAGEReactiveMap
ReactiveWeakMap
SIZEVERSION
memoSTAGEcreateLatest
createLatestMany
createWritableMemo
createLazyMemo
createPureReaction
createMemoCache
createReducer
SIZEVERSION
mutableSTAGEcreateMutable
modifyMutable
SIZEVERSION
resourceSTAGEcreateAggregated
createDeepSignal
makeAbortable
createAbortable
makeCache
makeRetrying
SIZEVERSION
rootlessSTAGEcreateSubRoot
createCallback
createDisposable
createSharedRoot
createRootPool
SIZEVERSION
setSTAGEReactiveSet
ReactiveWeakSet
SIZEVERSION
signal-buildersSTAGEList of buildersSIZEVERSION
state-machineSTAGEcreateMachineSIZEVERSION
static-storeSTAGEcreateStaticStore
createDerivedStaticStore
SIZEVERSION
triggerSTAGEcreateTrigger
createTriggerCache
SIZEVERSION

UI Patterns

markerSTAGEcreateMarkerSIZEVERSION
masonrySTAGEcreateMasonrySIZEVERSION
paginationSTAGEcreatePagination
createInfiniteScroll
SIZEVERSION
virtualSTAGEVirtualListSIZEVERSION

Animation

presenceSTAGEcreatePresenceSIZEVERSION
rafSTAGEcreateRAF
createMs
targetFPS
SIZEVERSION
transition-groupSTAGEcreateSwitchTransition
createListTransition
SIZEVERSION
tweenSTAGEcreateTweenSIZEVERSION

Solid Start

startSTAGEcreateServerCookie
createUserTheme
SIZEVERSION