alpine README

The project's README from github.com/alpinejs/alpine. As one markdown file: README.md.

Alpine.js

Go to the Alpine docs for most things: Alpine Docs

You are welcome to submit updates to the docs by submitting a PR to this repo. Docs are located in the /packages/docs directory.

Stay here for contribution-related information.

Looking for V2 docs? here they are

Alpine Component Patterns

Contribution Guide:

Quickstart

Brief Tour

You can get everything installed with: npm install in the root directory of this repo after cloning it locally.

This repo is a "mono-repo" using npm workspaces for managing the packages. Each package has its own folder in the /packages directory.

Rather than having to run separate builds for each package, all package bundles are handled with the same command: npm run build

Here's a brief look at each package in this repo:

Package Description
alpinejs The main Alpine repo with all of Alpine's core
collapse A plugin for expanding and collapsing elements using smooth animations
csp A repo to provide a "CSP safe" build of Alpine
docs The Alpine documentation
focus A plugin that allows you to manage focus inside an element
history A plugin for binding data to query string parameters using the history API (name is likely to change)
intersect A plugin for triggering JS expressions based on elements intersecting with the viewport
mask A plugin for automatically formatting a text input field as a user types
morph A plugin for morphing HTML (like morphdom) inside the page intelligently
persist A plugin for persisting Alpine state across page loads

The compiled JS files (as a result of running npm run [build/watch]) to be included as a <script> tag for example are stored in each package's packages/[package]/dist directory.

Each package should at least have: a "cdn" build that is self-initializing and can be included using the src attribute in a <script defer> tag, and a module.[esm/cjs].js file that is used for importing as a JS module (cjs for node, esm for everything else).

The bundling for Alpine V3 is handled exclusively by ESBuild. All of the configuration for these builds is stored in the scripts/build.js file.

Testing

There are 2 different testing tools used in this repo: Cypress (for integration tests), and Vitest (for unit tests).

All tests are stored inside the /tests folder under /tests/cypress and /tests/vitest.

If you wish to only run Cypress and open it's user interface (recommended during development), you can run: npm run cypress

If you wish to only run Vitest tests, you can run npm run vitest like normal and target specific tests.

alpine (alpinejs/alpine)

Searching Database…

32K ·GitHub
What is this?Alpine.js is a rugged, minimal framework that lets you add interactive JavaScript behavior directly as attributes in your HTML markup, without a build step or component system.
Is this a full framework like Vue or React?It is much lighter than those - instead of writing separate JS components, you sprinkle behavior as HTML attributes right on your elements, similar in spirit to how Tailwind lets you style with classes.
How do I add Alpine to a web page?Include the compiled cdn.js file from the alpinejs package via a script tag on your page and it self-initializes, or install it with npm and import it as a module.
Do I need npm or a build tool just to use Alpine on my site?No - for normal use you just drop in the CDN script tag; npm install and the build step are only needed if you are cloning this repo to contribute.
Does this README explain how to actually use Alpine in my app?Not really - this repository's README is mainly a contribution guide; real usage documentation lives on the separate Alpine Docs site linked at the top.
Is there a build for strict Content-Security-Policy environments?Yes, the 'csp' package provides a CSP-safe build of Alpine for sites that disallow inline scripts and eval.
How is the Alpine codebase organized?It's an npm-workspaces monorepo where the core and every plugin live in their own folder under /packages, and all of them are bundled together with a single 'npm run build' command powered by ESBuild.
What are similar projects?svelte, hyperapp, angular.js, vue, solid, core, riot, dva
Creator
alpinejs
Size
9.2 MB
Stars
32K
Age
6y
Commits · 90 Days