---
slug: "spartan"
source_type: "readme"
source_url: "https://cdn.jsdelivr.net/gh/spartan-ng/spartan@main/README.md"
repo: "https://github.com/spartan-ng/spartan"
source_file: "README.md"
branch: "main"
---
# spartan

<a href="https://www.spartan.ng" target="_blank">
<img alt="A spartan shield" width="100px" src="./spartan.svg" title="Spartan logo"/>
</a>

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT) [![Discord server](https://dcbadge.limes.pink/api/server/EqHnxQ4uQr?style=flat-square)](https://discord.gg/EqHnxQ4uQr)

[Website](https://www.spartan.ng) • [Documentation](https://www.spartan.ng/documentation/introduction) • [Components](https://www.spartan.ng/components) • [Blocks](https://www.spartan.ng/blocks) • [GitHub](https://github.com/spartan-ng/spartan)

> Cutting-edge tools that power Angular full-stack development - accessible, un-styled UI primitives with copy-paste, shadcn-style styles, plus an opinionated full-stack setup. Build like a spartan.

Welcome to the spartan mono-repo. This Nx repository is home to **spartan/ui** - accessible,
un-styled UI primitives for Angular with copy-paste, shadcn-style helm styles - and the **spartan/stack**,
an opinionated full-stack setup built on AnalogJs.

spartan/ui is **1.0** and stable: production-ready, [semantically versioned](https://semver.org), and
shipping more than 55 components. Install it from npm with
[`@spartan-ng/brain`](https://www.npmjs.com/package/@spartan-ng/brain) and the
[`@spartan-ng/cli`](https://www.npmjs.com/package/@spartan-ng/cli), or explore everything at
[spartan.ng](https://www.spartan.ng).

## Packages

| Package                             | Description                                                                    |                                                        |
| ----------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------ |
| [`@spartan-ng/brain`](https://github.com/spartan-ng/spartan/tree/HEAD/libs/brain) | Headless, accessible UI primitives for Angular - the behavior half of spartan. | [npm](https://www.npmjs.com/package/@spartan-ng/brain) |
| [`@spartan-ng/cli`](https://github.com/spartan-ng/spartan/tree/HEAD/libs/cli)     | Nx plugin & Angular schematics that add spartan/ui to any workspace in one go. | [npm](https://www.npmjs.com/package/@spartan-ng/cli)   |
| [`@spartan-ng/mcp`](https://github.com/spartan-ng/spartan/tree/HEAD/libs/mcp)     | Model Context Protocol server giving AI assistants up-to-date spartan docs.    | [npm](https://www.npmjs.com/package/@spartan-ng/mcp)   |

The styled **helm** components aren't published as a package on purpose - the [CLI](https://github.com/spartan-ng/spartan/tree/HEAD/libs/cli) copies them straight into your project so you own and customize every line.

## The 300 spartans

All of spartan is an MIT-licensed open source project with its ongoing development made possible by contributors and sponsors.

Our initial 300 contributors and sponsors are featured here and on the front page of [spartan.ng](https://www.spartan.ng)

1. [goetzrobin](https://github.com/goetzrobin)
2. [thatsamsonkid](https://github.com/thatsamsonkid)
3. [elite-benni](https://github.com/elite-benni)
4. [ashley-hunter](https://github.com/ashley-hunter)
5. [marcjulian](https://github.com/marcjulian)
6. [MerlinMoos](https://github.com/MerlinMoos)
7. [zeropsio](https://github.com/zeropsio)
8. [snyder-tech](https://github.com/snyder-tech)
9. [mihajm](https://github.com/mihajm)
10. [ajitzero](https://github.com/ajitzero)
11. [arturgawlik](https://github.com/arturgawlik)
12. [deepakrudrapaul](https://github.com/deepakrudrapaul)
13. [evanfuture](https://github.com/evanfuture)
14. [AdditionAddict](https://github.com/AdditionAddict)
15. [Altamimi-Dev](https://github.com/Altamimi-Dev)
16. [ferat](https://github.com/ferat)
17. [jeremy-js-devweb](https://github.com/jeremy-js-devweb)
18. [heddendorp](https://github.com/heddendorp)
19. [tutkli](https://github.com/tutkli)
20. [Pascalmh](https://github.com/Pascalmh)
21. [okkindel](https://github.com/okkindel)
22. [oidre](https://github.com/oidre)
23. [nartc](https://github.com/nartc)
24. [santoshyadavdev](https://github.com/santoshyadavdev)
25. [markostanimirovic](https://github.com/markostanimirovic)
26. [theo-matzavinos](https://github.com/theo-matzavinos)
27. [jkuri](https://github.com/jkuri)
28. [dongphuong0905](https://github.com/dongphuong0905)
29. [DominikPieper](https://github.com/DominikPieper)
30. [brandonroberts](https://github.com/brandonroberts)
31. [izikd](https://github.com/izikd)
32. [ryancraigmartin](https://github.com/ryancraigmartin)
33. [gaetanBloch](https://github.com/gaetanBloch)
34. [gergobergo](https://github.com/gergobergo)
35. [rpacheco124](https://github.com/rpacheco124)
36. [benjaminforras](https://github.com/benjaminforras)
37. [jstnjs](https://github.com/jstnjs)
38. [r3ps4J](https://github.com/r3ps4J)
39. [Celtian](https://github.com/Celtian)
40. [miljan-code](https://github.com/miljan-code)
41. [alexciesielski](https://github.com/alexciesielski)
42. [ty-ler](https://github.com/ty-ler)
43. [m-risto](https://github.com/m-risto)
44. [badsgahhl](https://github.com/badsgahhl)
45. [monacodelisa](https://github.com/monacodelisa)
46. [tomdev9](https://github.com/tomdev9)
47. [ragul1697](https://github.com/ragul1697)
48. [kkamman](https://github.com/kkamman)
49. [i-am-the-slime](https://github.com/i-am-the-slime)
50. [DevWedeloper](https://github.com/DevWedeloper)
51. [mrsofiane](https://github.com/mrsofiane)
52. [mateoetchepare](https://github.com/mateoetchepare)
53. [DonaldMurillo](https://github.com/DonaldMurillo)
54. [toniskobic](https://github.com/toniskobic)
55. [eneajaho](https://github.com/eneajaho)
56. [Den-dp](https://github.com/Den-dp)
57. [0xfraso](https://github.com/0xfraso)
58. [Muneersahel](https://github.com/Muneersahel)
59. [danilolmc](https://github.com/danilolmc)
60. [tomalaforge](https://github.com/tomalaforge)
61. [canserkanuren](https://github.com/canserkanuren)
62. [cjosue15](https://github.com/cjosue15)
63. [hirenchauhan2](https://github.com/hirenchauhan2)
64. [Roguyt](https://github.com/Roguyt)
65. [tsironis13](https://github.com/tsironis13)
66. [guillermoecharri](https://github.com/guillermoecharri)
67. [ValentinFunk](https://github.com/ValentinFunk)
68. [Femi236](https://github.com/Femi236)
69. [dineshkp](https://github.com/dineshkp)
70. [robingenz](https://github.com/robingenz)
71. [Balastrong](https://github.com/Balastrong)
72. [OlegSuncrown](https://github.com/OlegSuncrown)
73. [stewones](https://github.com/stewones)
74. [shinkhouse](https://github.com/shinkhouse)
75. [donaldxdonald](https://github.com/donaldxdonald)
76. [BenoitPE](https://github.com/BenoitPE)
77. [Georg632](https://github.com/Georg632)
78. [hillin](https://github.com/hillin)
79. [Besbash](https://github.com/Besbash)
80. [davidedammino](https://github.com/davidedammino)
81. [marcindz88](https://github.com/marcindz88)
82. [thyco](https://github.com/thyco)
83. [hitro11](https://github.com/hitro11)
84. [GODrums](https://github.com/GODrums)
85. [samsonkumawong](https://github.com/samsonkumawong)
86. [PR4SAN](https://github.com/PR4SAN)
87. [JeevanMahesha](https://github.com/JeevanMahesha)
88. [dlhck](https://github.com/dlhck)
89. [tomer953](https://github.com/tomer953)
90. [drdreo](https://github.com/drdreo)
91. [tlandenberger](https://github.com/tlandenberger)
92. [yackinn](https://github.com/yackinn)
93. [OmerGronich](https://github.com/OmerGronich)
94. [kubalinio](https://github.com/kubalinio)
95. [AlexHladin](https://github.com/AlexHladin)
96. [CO97](https://github.com/CO97)
97. [MatanShushan](https://github.com/MatanShushan)
98. [maxhov](https://github.com/maxhov)
99. [josueggh](https://github.com/josueggh)
100. [namdien177](https://github.com/namdien177)
101. [zelenchuk](https://github.com/zelenchuk)
102. [a-malacarne](https://github.com/a-malacarne)
103. [YasinKuralay](https://github.com/YasinKuralay)
104. [nico13051995](https://github.com/nico13051995)
105. [francotalarico](https://github.com/francotalarico)
106. [koenigderluegner](https://github.com/koenigderluegner)
107. [Turtl3e](https://github.com/Turtl3e)
108. [minhnguyen120898](https://github.com/minhnguyen120898)
109. [liam-langstaff](https://github.com/liam-langstaff)
110. [dw-0](https://github.com/dw-0)
111. [Khumozin](https://github.com/Khumozin)
112. [abiramcodes](https://github.com/abiramcodes)
113. [garygrossgarten](https://github.com/garygrossgarten)
114. [Oussemasahbeni](https://github.com/Oussemasahbeni)
115. [benpsnyder](https://github.com/benpsnyder)
116. [dhwani1806](https://github.com/dhwani1806)
117. [elite-lucas](https://github.com/elite-lucas)
118. [esteecodes](https://github.com/esteecodes)
119. [felhag](https://github.com/felhag)
120. [notsufferbutbutter](https://github.com/notsufferbutbutter)
121. [vlrjuan](https://github.com/vlrjuan)
122. [Dafnik](https://github.com/Dafnik)
123. [hassantayyab](https://github.com/hassantayyab)
124. [mathwizard](https://github.com/mathwizard)
125. [RaminGe](https://github.com/RaminGe)
126. [abos-gergo](https://github.com/abos-gergo)
127. [jpsullivan](https://github.com/jpsullivan)
128. [ayangabryl](https://github.com/ayangabryl)
129. [s-froghyar](https://github.com/s-froghyar)
130. [aziz-zina](https://github.com/aziz-zina)
131. [avihayAsus](https://github.com/avihayAsus)
132. [multignite](https://github.com/multignite)
133. [sefatanam](https://github.com/sefatanam)
134. [LinboLen](https://github.com/LinboLen)
135. [Oneill19](https://github.com/Oneill19)
136. [homj](https://github.com/homj)
137. [Musta-Pollo](https://github.com/Musta-Pollo)
138. [mitja-kurath](https://github.com/mitja-kurath)
139. [alisterpineda](https://github.com/alisterpineda)
140. [amitshalev2](https://github.com/amitshalev2)
141. [SOG-web](https://github.com/SOG-web)
142. [Joebeurg](https://github.com/Joebeurg)
143. [mehrabix](https://github.com/mehrabix)
144. [PatrickLarocque](https://github.com/PatrickLarocque)
145. [Ban117](https://github.com/Ban117)
146. [gerasidev](https://github.com/gerasidev)
147. [Nicoss54](https://github.com/Nicoss54)
148. [xonaib](https://github.com/xonaib)
149. [SocDario](https://github.com/SocDario)
150. [bcl-dev](https://github.com/bcl-dev)
151. [skolldev](https://github.com/skolldev)

### Sponsor spartan

spartan is MIT-licensed and free, forever. But free to use isn't free to build - countless hours of late-night, hard-fought work hold this phalanx together, and they keep the components shipping and the docs current.

If spartan saves your company or team time, consider returning the favor. Sponsoring keeps spartan actively maintained, the roadmap moving, and the open-source work of the 300 sustainable. No spartan holds the line alone - every shield in the wall counts.

**[Become a spartan today! →](https://github.com/sponsors/goetzrobin)**

## Zerops: The Strategic Alliance

<div align="center">
  <a href="https://zerops.io" target="_blank">
    <img src="https://avatars.githubusercontent.com/u/65757521?s=200&v=4" alt="Zerops" width="250">
  </a>
</div>

spartan.ng has formed a powerful alliance with Zerops, a developer-first cloud platform that shares our commitment to advancing the Angular ecosystem.

Through their strategic support, Zerops has enabled:

- Dedicated resources for our core development team
- Accelerated component development on our path to v1 and beyond
- Creation of production-ready templates and starter kits
- Long-term sustainability for the entire project

Zerops eliminates deployment complexity so developers can focus on building great software—a philosophy that perfectly aligns with our mission to create powerful yet easy-to-implement components.

**[Experience the cloud platform that's powering Spartan.ng's future →](https://zerops.io)**

## spartan/ui

spartan/ui brings the [shadcn/ui](https://ui.shadcn.com) philosophy to Angular: accessible, un-styled primitives - inspired by [Radix](https://www.radix-ui.com) and built on the Angular CDK and other proven community solutions - paired with beautiful, copy-paste shadcn-style styles that you own.

Each primitive is made up of two halves:

- a headless **`brain`** library in [`libs/brain`](https://github.com/spartan-ng/spartan/tree/HEAD/libs/brain) that provides the behavior, accessibility, and state - published to npm as [`@spartan-ng/brain`](https://www.npmjs.com/package/@spartan-ng/brain).
- a **`helm`** library in [`libs/helm`](https://github.com/spartan-ng/spartan/tree/HEAD/libs/helm) that adds the styles, copied straight into your project by the CLI so you can edit them freely.

[`libs/cli`](https://github.com/spartan-ng/spartan/tree/HEAD/libs/cli) holds the Nx plugin & Angular CLI code that adds spartan/ui to any Nx or Angular workspace in a single command - published as [`@spartan-ng/cli`](https://www.npmjs.com/package/@spartan-ng/cli).

[`libs/mcp`](https://github.com/spartan-ng/spartan/tree/HEAD/libs/mcp) is a [Model Context Protocol](https://modelcontextprotocol.io) server - published as [`@spartan-ng/mcp`](https://www.npmjs.com/package/@spartan-ng/mcp) - that gives AI assistants up-to-date spartan docs, components, and blocks.

The `skills/spartan` folder contains the spartan agent skill - procedural knowledge that teaches AI coding assistants how to build spartan/ui correctly. Users install it with `npx skills add spartan-ng/spartan`. See [the Skills docs](https://www.spartan.ng/documentation/skills).

### Install Dependencies

Run `pnpm install` to install the dependencies of this project.

### Development with storybook

A storybook project is set up and is the primary way to develop UI components. You can run it with:

```
pnpm run storybook
```

Story files live in `apps/ui-storybook/stories`, one per primitive, e.g. `apps/ui-storybook/stories/accordion.stories.ts`.

Use these files to add stories and drive development of the primitives.

### Testing

spartan uses [Jest](https://jestjs.io) for tests. To test all projects locally, run the following command from the root
folder:

```shell
pnpm run test
```

### e2e testing

Cypress e2e testing is set up to run on the storybook. You can run it with:

```
pnpm run e2e
```

To add your own `e2e` tests add them to the `apps/ui-storybook-e2e` application.

## spartan/stack

An example application running
on [Supabase](https://supabase.com/), [Drizzle](https://orm.drizzle.team/), [Analog](https://analogjs.org/),
[tRPC](https://trpc.io/), [Tailwind](https://tailwindcss.com/), [Angular](https://angular.io/),
and [Nx](https://nx.dev/). It also serves as the documentation page introducing the stack and UI library.

Follow the directions in the official documentation to set up your own project:
https://www.spartan.ng/stack/overview

### Example App

In the `apps` folder of this repository, you can also find an example application of the spartan stack.
It also serves as the documentation page for this project.

Follow the directions below to get it up and running:

#### Prerequisites

- You will need `pnpm` as your package manager.
- You will need to set up a [Supabase](https://supabase.com/) account (it's free)
- You will need [NodeJs](https://nodejs.org/en) installed. The version I have working is `20.17.0`.

#### Development server

Then you can run the following command:

```shell
pnpm nx serve app
```

or

```shell
pnpm run dev
```

for a dev server. Navigate to http://localhost:4200/. The app will automatically reload
if you change any of the source files.

#### Database

We use Drizzle to connect to a Supabase instance for the example app.

Add an `.env` file to your repo with the following contents:

Add a `.env` file at the root of your Nx workspace and add the connection string like so:

```
DATABASE_URL="postgresql://postgres:[YOUR-PASSWORD]@db.[YOUR-SUPABASE-REFERENCE-ID].supabase.co:5432/postgres?schema=public"
```

And make sure to run the following script in your Supabase editor to set up the necessary tables:

```sql
create table
  public.note (
    id bigserial,
    title text not null,
    content text null,
    created_at timestamp with time zone null default current_timestamp,
    constraint notes_pkey primary key (id)
  ) tablespace pg_default;
```

> [!NOTE] > `.env` should be added to `.gitignore`

## Understand this workspace

Run `pnpm nx graph` to see a diagram of the dependencies of the projects.

## Documentation

- [Introduction](https://www.spartan.ng/documentation/introduction)
- [Installation](https://www.spartan.ng/documentation/installation)
- [CLI](https://www.spartan.ng/documentation/cli)
- [Theming](https://www.spartan.ng/documentation/theming)
- [Components](https://www.spartan.ng/components)
- [Blocks](https://www.spartan.ng/blocks)

## Community

- [Discord](https://discord.gg/EqHnxQ4uQr)
- [GitHub](https://github.com/spartan-ng/spartan)
- [Sponsor the project](https://github.com/sponsors/goetzrobin)

Run into an issue or have a question? Open an issue on [GitHub](https://github.com/spartan-ng/spartan/issues) or say hi in [Discord](https://discord.gg/EqHnxQ4uQr).

## License

MIT © [goetzrobin](https://github.com/goetzrobin) and the [spartan contributors](https://github.com/spartan-ng/spartan/graphs/contributors)
